Uploaded by 302 365 Moddasir Ahmed

Midterm Assignment - Section 9

CSE225L: Data Structures and Algorithm Lab
Midterm Assignment (Up to Lab 9)
Total Marks: 32
Deadline: 19th December, 2020 (06:00 AM)
North South University
Read the following instructions carefully before proceeding to the questions.
1. You may download and use the implementation codes from google classroom and modify them as
necessary for this assignment.
2. There will be partial marking. So even if you do not manage to solve the whole problem, try to solve as
much as you can.
3. There will be no mark for plagiarizing. If you plagiarize in any way, your submission will be rejected and
you will get 0 for that task.
4. You need to submit your code in google classroom like any other assignments. Make sure that you have
saved everything before submitting.
5. Please make sure to put all your projects in a single folder and then zip it. Now rename the zip file
according after your own full name. If your name is Abcd Xyz then your zip file name should be “Abcd
Xyz.zip”. Now submit this file in google classroom. If you do not follow this instruction, I am going to
deduct marks.
* Penalty for not following Instruction 5 will be severe.
Every one of the tasks is worth 8 Points each.
Happy coding!!!
1. Modify the implementation of SortedList (linked list based implementation) class and do the followings:
a. Make sure that no duplicate value is allowed.
b. Introduce a function called Reverse() that returns an array with values in reverse order.
In the driver file create a list and insert some values. Now call the Reverse function and print the values
of the returned array.
2. Use a Queue to determine whether an integer number is palindrome or not. The integer number should
be taken from the user.
3. Use a stack to determine whether a string of parenthesis is balanced or not? If the string is not balanced,
then print the longest substring that is balanced. If the length of the longest substring is less than 2, print
“Totally unbalanced”.
Test case 1:
Input: ()((()((()()()
Output: ()()()
Test case 2:
Input: ()(()())
Output: Balanced
Test case 3:
Output: )((
Output: Totally unbalanced
4. In the following few tasks you will be tested on your understanding of dynamic allocation.
a. Create a 1-d array of integer pointers dynamically. Size of the array, n should be taken from the
b. Take n integer inputs from the user and store them using dynamic allocation. You should store
their addresses in the array created in task 4.a.
c. Now print the integers.
d. Finally, deallocate everything that has been dynamically allocated.