You are on page 1of 3
~ NAME REGISTRATIONNO DATE CLASS WARKS 1100 clo2: Topic: ‘CODEISUBJECT DFC30235 — DATA STRUCTURES WINI PROJECT i LECTURER Construct appropriate concepts of data structures and designing efficient algorithms in problem solving (P3, PLO 3) 2.2: DEMONSTRATE THE OPERATION OF LINEAR LINKED LIST 3.2: DEMONSTRATE THE OPERATION OF STACK 4.2: DEMONSTRATE THE OPERATION OF QUEUE 5.3: CONSTRUCT BINARY SEARCH TREE 6.2: DEMONSTRATE SEARCHING DURATION: 11 HOURS 30 MINUTES INSTRUCTION: ANSWER ALL THE QUESTIONS 1 Figure A shown a simple program for singly linked list. Based on Figure A, answer all the question below: ‘include include using namespace std; struct Node { Aint data; struct Node *next; h Struct Node* head = MULL; Void insert (ant new data) { ‘struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); new_node->data = newdata; new node-snext = head; head = new-node} y Youd display() { struct Node" ptrs ptr = heads Unie (per l= MULL) { coutce ptr-sdata <<" "5 ptr = ptr-snext; > > fine main() { coutce"the List of Linked list: \n"s insert(10); insert (20); insert (30); insert (40); display); return @; Figure A i, Recognize and produce an output of the code segment in Figure A. (CLO2, P1) [6 marks} ji, Based on the output from question 1 (i), transform the output into Linked List diagram based cn statement below. (CLO2, P3) (20 marks} a. _ Insert number 25 between node 2 and node 3. b. Delete node 2 c. Insert number 50 at first node d. Delete the last node e. Delete the first node 2. Using the answer from question 1 (i) (e), convert the answer from linked list to stack named XOXO with size 4 and assemble with the statement below (CLO2, P3) (14 marks) Pop (); Pop (); Push (3: Push (55); Push (88); Push (99); 3. Circular Queue is a linear data structure in which operation are performed based on FIFO principle and the last position to make a circle. itis also called ‘Ring Buffer’. Show the steps for the following. circular queue implementation based on statement below and write a suitable code to perform an enqueuer and dequeuer operation. (CLO2, P3) [20 marks} CreateQueue(myQ); // sie 8 myQ.enqueue (10); myQenqueue (20); myQ.denqueue (); myQ.enqueue (30); 5, Based on an output above, you are required to manipulate the data in tree based on employee information, Then, traverse the tree using preorder, inorder and postorder. (CLO2, P2) ***Note: Use “NAME” as the key for BST. [30 marks] From the answer Preorder in Question 4: - [20 MARKS} a. Find Muthu using Linear searching. b, Find Amita using Binary searching.

You might also like