0% found this document useful (0 votes)
12 views

3rd Semester, B.tech, Data StructuresData Structures and Algorithms ,CS 21001CS 2001, Autumn End Semester Examination 2023

Assignment of University

Uploaded by

Danish
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
12 views

3rd Semester, B.tech, Data StructuresData Structures and Algorithms ,CS 21001CS 2001, Autumn End Semester Examination 2023

Assignment of University

Uploaded by

Danish
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Semester: 3 Qn. Set Code-1 Programme: B.Tech ar Sé Branch: CSE, IT. CSCE, AUTUMN END SEMESTER EXAMINATION-2023 3"! Semester B.Tech DATA STRUCTURES (CS21001) / DATA STRUCTURES & ALGORITHMS (CS-2001) (For 2023 (L.E), 2022 & Previous Admitted Batches) Time: 3 Hours Full Marks: 50 Answer any SIX questions, Question paper consists of four SECTIONS i.e. A, B, C and D. Section A is compulsory. Adtempt minimum one question each from Sections B, C, D. The figures in the margin indicate full marks All parts of a question should be answered at one place only. SECTION-A 1, Answer the following questions: [1 x 10] (a) Write a function with arguments whose worst case time complexity is O(m* +n (log my ). (b) An array X[-15...10, 15...40] is presented in row- major format, Each element in the array requires nvo bytes of storage. If the beginning location of the array is 2500, determine the location of X[8][25]. (c) Let P(x) denote the polynomial: P(x) = 5x° — 3x) + 2x? + 7x +10. Visually depict it using a header linked list by articulating the assumptions, if any. (d) Consider a deque of size 6. Illustrate the step-by-step pros for insertion of elements 10, 20, 30, 50, 60, and 70 at front end, wherein each step has to capture the current state of the deque, front, and rear. RATT-DU 2023 SOT Autunn End Semester Examination-2 (e) (p (g) (h) (i) dQ) Let G (as shown below) be an unweighted directed graph with 5 vertices. Represent it using an adjacency list. Given an array of characters. Write a function to sort the array using bubble sort. The comparisons should be made using the ASCII values of the characters. Consider the following In-order and Post-order traversal of a binary tree. Find the preorder sequence by constructing the tree. In-order: B+ D—-A—+G>E>C>H>F-I Post-order ; D> B—+G—+E->+H>I>F-+C>A Draw the binary tree for the expression ((IS*A+B)*(S*C+D+E))%7. (The operator *%* and ‘** have same precedence and higher than the precedence of ‘+’) Write a function to count the number of digits of a given integer using recursion. The signature of the function is intnoOfDigits(int n), and the function should display an error message if the value of n is less than 0. The keys 12, 13, 22, and 23 are to be inserted into an initially empty hash table of length 10 using linear probing with the hash function h(k) = k mod 10. For each insertion, display the state of the hash table by capturing the key, address, address after linear probing, and the number of probes. KIFT-DU 2023 SOT Autumn bind Semester Exannination-2023 (2) Vv 4. (a) (b) (a) (b) (a) SECTION-B Write a function to subtract a sparse matrix from another. The matrices are represented in row triplet form. Write a function to reverse the order of the words in a String. Example: Input: “T love DS” Output: “DS love [” Given a pointer head pointing to the header node of a singly linked list. Write a function to reverse the list by reversing the links between the nodes. There are two doubly linked lists. By some programming error, the node of one of the double linked lists got linked to the second list, forming an inverted Y-shaped list (see the below figure for reference), Write a function to display the value of the node where two double linked lists merge. As per the below diagram, the inverted Y-shape occurs at the node value 25 head1 SECTION-C Convert the following infix expression to its corresponding postfix expression using the suitable data structure. Illustrate neatly each step of the conversion. SOT Autunn Ene Semester Examination2023 (3) [4] [4] (4 A+(B*C-(D/E *F)*G)*H The precedence of ‘*’ is highest followed by the ‘** and ‘/’ who have the same precedence. The precedence of ‘+ and *-* is same and it is the lowest. (b) Create two stacks using a static array that is, both [4] stacks will use the same array for storing elements. The stacks must grow towards each other. Write the following functions to implement the stacks: 1. push1 (int x) > pushes x to the first stack. 2. push2(int x) —> pushes x to the second stack. 3. intpopl() — pops an element from the first stack and returns the popped element. 4. intpop2() —> pops an element from the second stack and returns the popped element. 5. (a) Write a function to determine whether the two binary [4] trees are identical or not. Two binary trees are identical when they have the same data at the same position Examples: Input: 1 1 i \ i \ 2 3 2 3 ! / 4 4 Output: Both binary trees are identical Input: 1 1 /\ 1 \ 5 3 2 3 / / 4 4 Output: Binary trees are not identical KINT-DU 2023 SOT Autunnn Fd Sernester Examiination-2023° (A) (b) Write the recursive functions for finding the minimum [4] and maximum key in a Binary Search Tree. 6. (a) Why do we need an AVL tree? Insert the given keys in [4] the order: 70, 65, 85, 60, 80, 90, 75, 95 into an empty AVL tree. Clearly Illustrate the AVL tree after each insertion, showing the resulting tree structure, the balance factor at each node and the rotations performed at each step to maintain the AVL tree. (b) Let G (as shown below) be an undirected Graph, Show [4] the step-by-step process to display the output sequence using breadth-first and depth-first searches, considering node with the value of 0 as the starting point. SECTION-D 7. (a) What constitutes a good hash function? Demonstrate [4] the insertion of keys: 50, 700, 76, 85, 92, 73, 102, 150, 783, 23. 167, 92, and 23 into a hash table with the separate chaining collision resolution technique. The hash table has 10 slots, and it uses the division method. (b) In reference to quadratic probing, write functions to [4] insert and search a key in the hash table. KITT-DU 2023 SOT Aum End Semester Beammation-2023 (5) 8. (a) Describe an optimized version of the Bubble Sort [4] algorithm that includes enhancements to reduce the number of unnecessary comparisons and swaps. Provide the modified algorithm and analyze the impact on the time complexity. (b) What is the divide & conquer principle? Explain it in [4] the context of Merge sort with a suitable example. HE KUT-DU! 2023 SOT Auaionn Bnd Semester Exammvation-2023 (6)

You might also like