2024_Data_Structures
2024_Data_Structures
a [iD x=afi]: return x; (c) Consider a stack S implemented using a singly Linked List. Stack S implements Push() and Pop() operations using add_to_Tail() and remove_from_tail() methods. (5) (i) Give the running time of Push() and Pop() operations for the above stack S. 4343 a (ii) Can the efficiency of these operations be improved using any alternate implementation strategy using a singly Linked List? Justify your answer by comparing running times. (d) Create a Multiway Search Tree of order two and show all the steps involved ; 50, 35, 40, 24, 65, 56 Write a function to find the inorder successor of the root node of the above tree. (5) (e) Consider a scenario where every node of a doubly (f) linked list stores a character with given head and tail pointers. Write a function that visits each node of the list exactly once to check whether the contents of the doubly linked list form a palindrome or not. The function should also report the number of characters in the list without using any further traversal. A palindrome is a string that reads the same backward as forwards. For example, ‘madam and ‘ABBA’ are palindromes. (5) Consider a circular queue created using an array of size 4, Perform the following operations in the given order and show the status of the queue after every operation ; PTO.4343 (g) 4 Enqueue(4), dequeue(), dequeue(), enqueue(5), enqueue(6), enqueue(8), enqueue(10). enqueue(9), dequeue (), enqueue(11) If the above queue was linear, show the final contents of the queue after performing all the above operations. (5) A lottery game generates |0-digit ticket numbers. These tickets are to be stored in a square matrix (5X5) based on the ticket number. The summation of the first five digits of a ticket number (modulo the number of rows in the square matrix) is used to identify the row number and the summation of the last five digits of the ticket number (modulo the number of columns in the square matrix) is used to identify the column number of the square matrix to store that ticket. Two tickets may hash to the same location in the square matrix, in which case, the location becomes a bucket that can hold multiple tickets. Demonstrate the working of the above game on the following ticket numbers: 1234567890, 0123456789, 0234516789, 0134526789, 0124536789, 0123546789, 0123465789, 9012345678 (5) 4343 5) (a) Consider a scenario where the students are Submitting their answer scripts one by one to a teacher. The teacher is maintaining the collected answer sheets in order always. Suggest the algorithm that can be used by the teacher. Use this algorithm to arrange the following 5 answer seripts that are numbered as follows and show all the steps: 23, 14, 56, 2, 10 Compute the number of comparisons that the teacher must have performed (5) (b) Find the preorder traversal of a Binary Search Tree (BST) if its postorder traversal is given below. Show all the steps performed. 2 20 17 25 15 48 45 50 40 (5) (a) An upper triangular integer matrix A with nXn dimension is to be stored as a one-dimensional array B in column-major order. If the base address of the array B is 200 and each integer takes 4 bytes of memory, find the address of A[1][2]. Also, give the formula to map the ALfi[i] element of array A into array B. Assume that the indexing for array A starts with 1 and that of B from 0. (6) Pal.O.4343 6 (b) Assuming a class is already defined for a singly linked list, write a member function to display the middle node of the list by traversing the list exactly (4) once. 4. (a) For the given Priority Queue implemented using Heap, illustrate the following operations one after (6) the other: (i) insert new element (3, T) (ii) removeMinQ) (b) Insert the given keys one by one in a multiway search tree of order 5 such that the search time is always logarithmic. Show all the steps involved. Thereafter, delete the key 16 and show the resulting tree. 24, 30, 16, 43, $1, 65, 48, 75, 34 (4) 4343 7 5. (a) Give a class definition for an ordered singly linked list. Write a member function to insert a node in this linked list such that the list remains in order, (6) (b) Write a recursive function to find the maximum key valuc in a Binary Search Tree (4) 6. (a) Consider an array with the following elements: 102, 280, 405, 513, 632, 746, 910, 958, 1000 Which searching technique (linear/binary) is better suited and why? Will this technique be appropriate if the given data is stored using a linked list? Why/ ‘Why not? (5) (b) Discuss the minimum and maximum height of a Binary Search Tree having n nodes. State the advantage of using a height-balanced tree like an AVL Tree over a Binary Search Tree. (5) 7. Consider an electronic calculating device named FastCal, On receiving a mathematical expression, A, as input, FastCal converts that expression into a parenthesis-free notation and evaluates it using some suitable data structures. Answer the following : P.T.0%4343 10) (ii) 8 Which data structures FastCal must use for the conversion and evaluation of the expression? Give the complete algorithm for the above- mentioned functioning of FastCal. (10) (1000)