Fall XXXXXXXXXXAlgorithm Development and Data Structures Assignment 2 Special Instructions: · All assignment shall be submitted by the deadline. Late submissions will be penalized with 10% per day for...

1 answer below »
instructions in file


Fall 2021- 20025 Algorithm Development and Data Structures Assignment 2 Special Instructions: · All assignment shall be submitted by the deadline. Late submissions will be penalized with 10% per day for up to 3 calendar days after which the assignment cannot be submitted anymore. An email must be sent should you choose to submit a late assignment. · This assignment is a group work. · Even partially copied code will be subject to regulations against academic integrity. Do NOT discuss or share your solution with anybody. Posting this assignment or solution on the Internet is a violation of the Student Code of Conduct. See the Academic Honesty at Sheridan. · Deductions will be applied if partial functionality is provided. · You’ll get zero grade if your code doesn’t compile. · Compilation warnings are considered to be major mistakes. · One .zip folder named appropriately as PROG20025_ASG_.zip., containing: · A document file for part C. · A well-documented program files for all questions. Make sure your program has no compilation error and is correct. Copy your programs to text files named [p1.txt, list.h, p2.txt, stack.h] containing your code and include a program header (I.e., a block comment at the top with your name, date, description of program). (You need to submit 4 txt files). · Submission is done in electronic format using SLATE DropBox. DO NOT email your submission. Due date for the submission is week 6. · This assignment has 2 questions on 4 pages. The assignment is out of 100. Question 1: [footnoteRef:1] [50 Marks] [1: Based on question 1.3.40 from Algorithms by Sedgewick and Wayne. ] In this Assignment you need to design, analyze, and implement algorithms to read in a sequence of characters from standard input and maintain the characters in a linked list with no duplicates. When you read in a previously unseen character, insert it at the front of the list. When you read in a duplicate character, delete it from the list and reinsert it at the beginning. The program implements the well-known move-to-front strategy which is useful for caching, data compression, and many other applications where items that have been recently accessed are more likely to be re-accessed. Requirements: 1. The program should read a sequence of characters. 2. The program should insert unseen character at the front of the list. The program should check if the character is not in the list to be inserted at the front of the list. 3. The program should delete a duplicate character and delete it from the list and insert it at the beginning of the list. The program should check if the character is already in the list and delete the character from the list and insert it again at the beginning of the list. 4. You need to implement the List ADT using Linked list implementation for the following operations in a file named “list.h”. You can add any operation if needed: a. list initialize() b. boolean IsEmpty (List) c. list insert (List and character) d. list delete(List and character) e. listPointer search (List) 5. Your report should include a write up for the following: 1. Justify and Explain briefly in at least 3 sentences the complexity of each operation in list.h file in terms of Big O notation. 2. Justify your answers and discuss if there is any way to improve the complexity of the designed algorithms. Question 2: [footnoteRef:2] [50 Marks] [2: Based on question 1.3.44 from Algorithms by Sedgewick and Wayne. ] Write a program to insert or delete characters in a buffer. You need to use stack operations to maintain operations for a buffer in a text editor. The program implements the following operations using two stacks that are represented using linked list: · Create an empty buffercreateBuffer() · Insert a character at the cursor position insert() · Get the character at the cursor position char get() · Delete and return the character at the cursor char delete() · Move the cursor k position to the left void left (int k) · Move the cursor k positions to the right void right(int k) Requirements: 1. You need to implement the Stack ADT using either Array or Linked list implementation for the following operations in a file named “stack.h”: · Stack initialize() · boolean IsEmpty (Stack) · character pop (Stack) · Stack push(Stack and character) · character top (Stack) · Integer. size(Stack) 2. The driver program interface can be either menu-based driven application that displays buffer operations, or you can select your preferred interface. 3. You need to implement the following constraints in the buffer operations: a. Can’t use the buffer before creating it. b. Can’t delete a character from an empty buffer. c. Move the cursor k positions to the right where k <= n="" and="" n="" is="" the="" number="" of="" characters-in="" the="" buffer.="" if="" k="">= n then the cursor moves to the last character in the buffer. d. Move the cursor k positions to the left where current position – k < 0="" returns="" the="" cursor="" to="" 0="" position.="" for="" example,="" if="" current="" position="" is="" 5="" and="" k="10" then="" 5-10="-5"><0 then cursor will be in position 0. e. print the contents of the buffer after each operation requested by the user. 4. your report should include a write up for the following: a. justify and explain briefly in at least 3 sentences the complexity of each operation in buffer operations in terms of big o notation. evaluation assignment 2 grading page max mark mark code [60 marks] question 1 code[50 marks] documentation including a program header with names and simple comments 5 program interface -usability, simple, helpful 5 operations for list.h 15 question 2 documentation including a program header with names and simple comments 5 program interface -usability, simple, helpful 5 operations for stack.h 5 operations for buffer editor using 2 stacks 20 report [40 marks] question 1 explain big-o for all operations in list.h 20 report [50 marks] question 2 explain big-o for buffer operations 20 fail to follow submission guidelines (-10%) 0 poor communication and presentation document organization (-10%), layout (-10%) spelling (-10%), title page including your name (-10%) 0 late submission -10% per day 0 total 100 comments 1 microsoft word - outout.docx q1: move-to-front strategy example input string: ababcdeabcb output: bcaed q2: the buffer operations can be implemented as a menu that shows the different operations on the buffer: example that shows the output after selecting the operation on the buffer. initialize buffer buffer: insert a character at the cursor: a buffer: a| insert a character at the cursor: b buffer: a b | insert a character at the cursor: c buffer: a b c| get the character at the cursor character: c delete character at the cursor buffer: a b| move the character to the left: 1 buffer: a | b move the character to the right: 3 buffer: a b | get the size of the buffer 2 then="" cursor="" will="" be="" in="" position="" 0.="" e.="" print="" the="" contents="" of="" the="" buffer="" after="" each="" operation="" requested="" by="" the="" user.="" 4.="" your="" report="" should="" include="" a="" write="" up="" for="" the="" following:="" a.="" justify="" and="" explain="" briefly="" in="" at="" least="" 3="" sentences="" the="" complexity="" of="" each="" operation="" in="" buffer="" operations="" in="" terms="" of="" big="" o="" notation.="" evaluation="" assignment="" 2="" grading="" page="" max="" mark="" mark="" code="" [60="" marks]="" question="" 1="" code[50="" marks]="" documentation="" including="" a="" program="" header="" with="" names="" and="" simple="" comments="" 5="" program="" interface="" -usability,="" simple,="" helpful="" 5="" operations="" for="" list.h="" 15="" question="" 2="" documentation="" including="" a="" program="" header="" with="" names="" and="" simple="" comments="" 5="" program="" interface="" -usability,="" simple,="" helpful="" 5="" operations="" for="" stack.h="" 5="" operations="" for="" buffer="" editor="" using="" 2="" stacks="" 20="" report="" [40="" marks]="" question="" 1="" explain="" big-o="" for="" all="" operations="" in="" list.h="" 20="" report="" [50="" marks]="" question="" 2="" explain="" big-o="" for="" buffer="" operations="" 20="" fail="" to="" follow="" submission="" guidelines="" (-10%)="" 0="" poor="" communication="" and="" presentation="" document="" organization="" (-10%),="" layout="" (-10%)="" spelling="" (-10%),="" title="" page="" including="" your="" name="" (-10%)="" 0="" late="" submission="" -10%="" per="" day="" 0="" total="" 100="" comments="" 1="" microsoft="" word="" -="" outout.docx="" q1:="" move-to-front="" strategy="" example="" input="" string:="" ababcdeabcb="" output:="" bcaed="" q2:="" the="" buffer="" operations="" can="" be="" implemented="" as="" a="" menu="" that="" shows="" the="" different="" operations="" on="" the="" buffer:="" example="" that="" shows="" the="" output="" after="" selecting="" the="" operation="" on="" the="" buffer.="" initialize="" buffer="" buffer:="" insert="" a="" character="" at="" the="" cursor:="" a="" buffer:="" a|="" insert="" a="" character="" at="" the="" cursor:="" b="" buffer:="" a="" b="" |="" insert="" a="" character="" at="" the="" cursor:="" c="" buffer:="" a="" b="" c|="" get="" the="" character="" at="" the="" cursor="" character:="" c="" delete="" character="" at="" the="" cursor="" buffer:="" a="" b|="" move="" the="" character="" to="" the="" left:="" 1="" buffer:="" a="" |="" b="" move="" the="" character="" to="" the="" right:="" 3="" buffer:="" a="" b="" |="" get="" the="" size="" of="" the="" buffer="">
Answered 1 days AfterOct 09, 2021

Answer To: Fall XXXXXXXXXXAlgorithm Development and Data Structures Assignment 2 Special Instructions: · All...

Swapnil answered on Oct 11 2021
128 Votes
93329/q1.cpp
#include
bool isBal(string expr)
{
stack s;
char a;
for(in
t i=0; i {
if(expr[i] == '(' || expr[i] == '[' || expr[i] == '{')
{
s.push(expr[i]);
continue;
}
if(s.empty())
return false;
switch(expr[i])
{
case ')':
a = s.top();
s.pop();

if(a =='{' || a =='[')
return false;
break;
case '}':
a = s.top();
s.pop();

if(a =='(' || a =='[')
return false;
break;
case ']':
a = s.top();
s.pop();

if(a =='(' || a =='{')
return false;
break;
}
}
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here