Dsa Final Paper
Dsa Final Paper
Instructions:
i. Draw a diagram of the above list after the following lines of code have been executed:
Node* prev = head->next;
Node* nodeToInsert = new Node;
nodeToInsert->item = 4;
nodeToInsert->next = prev->next;
prev->next = nodeToInsert;
ii. Assume that the code represented above in part (a) has executed. What is the value of
prev->item?
Page 1/3
iii. In addition to the code above, assume the following code executes. Draw a diagram of the list after this
code executes as well.
prev = prev->next;
prev = prev->next;
Node* curr = prev->next;
prev->next = curr->next;
delete curr; curr = NULL;
b). Consider the following function XYZ () that takes two circular linked lists as arguments:
Page 2/3
(e) Suppose you have replaced this with Deque and you apply following operations:
pushrear(9), pushfront(4), popfront(), pushfront(6), pushrear(3), popfront(), poprear(), pushfront(5).
The array is [21, 3, 5, (your registration number) ,10, 1, 8, 2] -> if your registration number is 15 then the
array you have to sort is [21,3,5, 15,10,1,8,2].
Show the changes in values after each iteration:
Since you are an underworld boss who has studied Data Structures and Algorithms, you decide to solve
how the diamond will be delivered to you by modeling the problem as a graph and then applying an
algorithm to it. Tell me the following
i. Create a graph for this problem. (1)
ii. What algorithm will apply on it? Where will you start it from? (1)
Page 3/3
iii. Redraw the graph and highlight (make bold) the solution, i.e. make the edges and vertices of the
solution. (3)
Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function
x mod 10.
a) Show the values in each index of array by applying linear probing method.
b) Apply the changing method and draw the diagram.
Page 4/3