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

Data Structure

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

Data Structure

Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 39
CS/B.Tech(CSE-N/ IT-N)/SEM-3/CS-302/2011-12 2011 DATA STRUCTURES & ALGORITHM Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers in their own words : as far as practicable. GROUP -A (‘Multiple Choice Type Questions ) 1. Choose the correct alternatives for the following: 10 x 1 = 10 i) . Which of the following traversal techniques lists the elements of a binary search tree in ascending order ? a) Pre-order b) Post-order c) Inorder d) None of these. i) The list data structure can be defined recursively. , a) True i b) False. ii) Best case time complexity of insertion sort is a O(1) b) O(n) ce) O(nlogn). ad) O(n?). 3202(N) { Turn over CS/B.Tech(CSE-N/IT-N) /SEM-3/CS-302/201 1-12 iv) vy) vi) vii) viii) 3202(N) In C language, arrays are stored in which representation ? a) Column major b) Row major ce) Layer major d) None of these. The number of stacks required to implement mutual recursion is a) 3 b) 2 do 1 : d) none of these. Priority queue can be implemented using a) . array b) linked list c) heap d) all of these. Binary search cannot be used in linked lists. a) True b) False. A complete directed graph of 5 nodes has number of edges a 5 b) 10 ce) 20 d) 25. Breadth-first-search algorithm uses ............. dat structure a) stack b) = queue c) binary tree @) none of these. Which of the following is not related to hashing ? ®) Synonyms b) Collision ©) Balance factor @) Lead factor CS/B.Tech(CSE-N/IT-N)/SEM-3/CS-302/2011-12 GROUP - B (Short Answer Type Questions ) Answer any three of the following. 3x5=15 What is an Abstract Data Type ?. What do you mean by a Dynamic Data Structure ? 3+2 Write a C language function to delete the nth node of a singly-linked list. The error conditions are to be handled properly. Write a C language function to find the in-order successor of the root of a binary tree. Write an algorithm to test whether a given binary tree is a binary search tree. Convert the following infix expression to postfix notation by showing the operator stack and output string after reading each input token : A*B+C*(D-E)—F#G GROUP - C (Long Answer Type Questions ) Answer any three of the following. 3x 15 = 45 Explain the mergesort algorithm. Why does it run faster than bubble sort in most of the cases ? Show how the mergesort algorithm will sort the following array in increasing order : 100, 90, 80, 70, 60, 50, 40, 30, 20. Analyse the time complexity of the mergesort algorithm. 3+2+5+5 $202(N) a { Turn over CS/B.Tech(CSE-N /IT-N)/SEM-3/CS-302/2011-12 8. What are the problems of binary tree - Explain, improvement of performance by the use of height-balay, i tree. Explain how a height-balanced tree can be formeg inserting the following elements in the given order : 1, 2, 3, 4, 5, 6, 8, 9, 10, 7, 11 Show the root element the can be deleted from the ab, 3 tree. 2+348,. 9. Define the ADT for stack. Show the implementation of the , stack data structure using linked list. 5 + 10. a) Write an algorithm for deletion of a node from a doubly linked list. b) What is a threaded binary tree ? Write an algoritiim fe for non-recursive’ in-order traversal of a threaded binan tree. 2431 c) Write an algorithm to left rotate a binary tree. q 11. a) What do you mean by hashing ? What are the applications where you will prefer hash tables to other data structures ? What do you mean by collision ? How is it handled ? 24+2+2 b) What is a B-tree ? Show how the letters A to P of English alphabet can be entered into a B-tree of order 4, S+eé 12. Arat has entered a checkerboard maze through one corner. whose the white boxes are open and black boxes represent obstacles. Develop an algorithm by which the rat can exit the maze through the opposite corner. Clearly ‘explain the representation of the maze and any specific data structure you have used for the algorithm. $202(N) 4 ¢S/B.Tech/ECE(0),EE(0),EEE(O), ICE(0),CSE(O),IT(0)/ SEM- 3/CS-302/2011- 12 : 2011 I ATA STRUCTURE AND ALGORITHMS . lotted :3 Hours ' Full Marks : 70 The figures in the margin indicate. full marks. didates are required to give their answers in their own words as far as practicable. GROUP -A ( Multiple Choice Type Questions ) ~ Choose the correct alternatives for any ten of the following : 10x 1=10 The number of edges in a complete graph with 'n' vertices is a) n(n-1) b) n(n-1)/2 ec) n2 d) 2n-1. Which of the following data structures is used to implement recursion ? a) Arrays b) Stacks c) Queues d) Linked list. 3001-(0) { Turn over (©8/B.Teeh/BCR{O) BELO), WEE(O),1C8(0},C8E{0).T(0)/8EM-3/C8-004 iti) viv) v) vi) 3001-(O) (2011-12 In what tree. for every node the heights of its left sub. tree and right sub-tree differ at least by one ? a) Binary search tree b) AVL tree c) Complete tree d) . Threaded binary tree. “Which traversal technique lists the nodes of a binary search tree in ascending order ? a) Post-order © : b) bie order °) Invorder se eee d) Linear’ order. ” The equivalent postfix expression for d/( ee fle b*: ie " 2 a a) defbe/+i- utes b) -def+/be+ * c) def+/be*+ ~d) none of these. If the postfix form of a string is ABC + - D*, the actua string is 3 a) (A-(B+C))*D b) ((A-B)+#.C)*D o) (((A+B)-C)"D d) (A+(B-C)*D). ’ ish(2), pop. ‘ oe e.sequene of popped out values is 2 2)1,2, 1 Bb 2,21,1,2 2,1, 2,2, 1 d 21,2, 2, 2. A linear collection of data elements where: the linear /- node is given by means of pointer is called : a) -Linked list b) . Node list “Primitive list 4) “None of these. - pis a pointer to the structure. A member "mem" of that structure is referenced by a , *p.mem b) (*p).mem c) *(p.mem) d) none of these. In linked list representation a node contains at leas! a) node address field, data field b) node number field, data field c) next address field, information field a) none of these. 3 (Turn over ©8/B.Tech/BCE{O),8B(0),EEE(O),1C8(0),C8E(0),17(0]/SEM-3/C8-302/2011-12 x) In quick sort a desirable choice for the partitioning element will be 8) first element of the list b) last element of the list ©) median of the list d) none of these. xii) An adjacency matrix representation of a graph cannot contain information of a) ‘nodes b) edges c) direction of edge d) parallel edge. GROUP - B (‘Short Answer Type Questions ) Answer any three of the following. 3x5 =15 2. Given a strictly binary tree with N leaves, Let 1 ( i) for i= 1 to N equals the level of ith leaf. Prove that D 1/(pow(2,1(0) = 1. 3. Discuss the advantages of doubly linked list as compared to single linked list. Write an algorithm to append a new node . after the specified node in a doubly linked list. 1+4 4. What are row-major order and column-major order representations ? Find the address of element @» in both representations. Given Base address : B Width of each element : w Row index ‘f is specified as: L,.1, tree consists of a root with the Fibonacci tree of order n - 1 as left subtree and the Fibonacci tree of ‘order n- 2 as right subtree. y Is such tree a strictly binary tree ? ii) What is the number of leaves of such tree for any value n? iii) What is the depth of the tree ? iv) Write a recurrence relation to calculate the total number of nodes in the tree with proper initial condition. 142+2+2 What is DAG ? What do you mean by topological ordering ? 2+2 Draw the DAG to represent the following arithmetic expression : 4 ((La+b)*c)-(d/(a+b)))T((a+b)*e). 3001-(0) z, CS/B.TECH/CSE (N)/IT (N)/SEM-3/CS-302/2012-13 2012 DATA STRUCTURE & ALGORITHMS [ime Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers in their own words as far as practicable. GROUP - A ( Multiple Choice Type Questions ) 1. Choose the correct alternatives for any ten of the following : 10x 1=10 i) Reserve Polish notation is often known as a) Infix b) Prefix c) Postfix d) none of these. ii) Which of the following algorithm should execute the : slowest for large values of N ? a O(N). b) 0(N2) co) 9(log2N) d) None of these. 3202 (N) { Turn over CS/B.TECH/CSE (N)/IT (N)/SEM-3/C! iti) iv) v) oo] S-302/2012-13 The evaluation of the postfix expression 3,5, 7, #, + 512) % 4s a), 2 b) 3 od 0 d) 3-17. A machine needs a minimum of 100 sec to , 1000 names by quick sort. The minimum time neg to sort 100 names will be approximately a 72-7 sec b) «11-2 sec c) 50-2 sec d) 6-7 sec. Linked list are not suitable for a) Stack b) Deque c) AVL Tree d) Binary search What will be the time complexity for selection > sort an array of n elements 7 a) Ollogn) bb Ol nlog n) 9 Oin) @ O(n?) The depth of a complete binary wee with m node @ Weiasi)-t Bo login) a bngia-i}er & lgini«! viii) xi) 3202 (N) CS/B.TECH/CSE (N)/IT (N)/SEM-3/CS-302/2012-13 In a binary search tree, if the number of nodes ‘of a tree is 9, then the minimum height of the tree is a 9 b) 5 cd 4 d) none of these. Dynamic memory allocation use a) Calloc b) = Malloc c) Free d) all of these. A vertex with degree one in.a graph is.called a) Leaf b) Pendant vertex c) End vertex d) None of these. Adjacency matrix of a diagraph is a) Identity matrix b) Symmetric matrix c) Asymmetric matrix d) None of these. CS/B-TRCH/CBE (N/T (N\/SEM-3/C3-302/2012-13 xii) 2. a) b) 3. a) b) 4. a) b) 3202 (N) Which method of traversal does not use Slack to ' nodes that are wailing to be processed : a) Breadth-first b) Depth-first c) D-search d) None of these. GROUP - B (Short Answer Type Questions ) Answer any three of the following. 3x5: Define big O notations. T (n) =4n? + 3n log n, express T(n) in Big (0 notations, 24 How the polynomial 4x°- 10x24 3 can be represent: using a linked list ? Compare and contrast between an array and a sin: linked list. 2+ Consider the array int a'{ 10 } £10 ] and the be address 2000, then calculate the address of the a {21131 in the row and column major ordering. Write the advantage of circular queue over 10 queue. 3 CS/B.TECH/CSE (N)/IT (N)/SEM-3/CS-302/2012-13 5. What do you mean by recursion ? Write down a C function to find out the GCD of two nos. using recursive technique. 1+4 6. What is binary tree ? Construct a binary tree using the inorder and postorder traversal of the node given below : Inder: D B F E AGCULdJH XK Postorder: D F E B GLdJIK HCA ; 14+4 GROUP - C ( Long Answer Type Questions ) Answer any three of the following. 3x 15=45 7. a) Drawa minimum heap tree from the below list : 12, 11, 7, 3, 10, -5, 0, 9, 2 Now do the heap sort operation over the heap tree which you have formed. Write the insertion sort algorithm. 24+24+3 b) What is a minimum spanning tree ? Describe Huffman's Algorithm. $34 c) What are the differences between AVL Tree & Binary Search Tree ? 1 3202 (N) 5 { Turn over CS/B-TECH/CSE (NAT ()/SEM-3/CS-202/2012-13 Bia a), b) °) b) o) d) 10. a) b) o) d) e) 3202 (N) Radix Sort the following list : 189, 205, 986, 421, 97, 192, 535, 839, 562, 674 Write the Radix sort algorithm. 3+: Find the time complexity of Binary Search Algorithm. What is hashing ? Construct an AVL tree using the below list. Show all the steps 12, 11, 13, 10, 09, 15, 14, 18, 7, 6, 5, 4. 5 What is a priority queue ? Write the recursive algorithm to find xq n. 4 Find the postfix notation of (a+b*x)\(al-d)s-ca y (show all steps). 4 Write the advantage of circular queue over linear queue. 4 What is a self referential structure ? 2+2 Describe a string reversal algorithm. 3 Write the difference between al] [ ] and ## a. 2 What is difference between Union & Structure ? a 6 5 CS/B.TECH/CSE (N)/IT (N)/SEM-3/CS-302/2012-13 11. Write short notes on any three of the following : 3x5 a) Abstract Data type b) «BFS c) BTree d) = Tail recursion e) Merge Sort. * CS/B.TECH (CSE-OLD)/ IT (0),ECE (0), EE (0), EEE (0), ICE (0)/SEM-3/CS-302/2012-13 2012 DATA STRUCTURE & ALGORITHMS Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers in their own words as far as practicable. 5 GROUP -A ( Multiple Choice Type Questions ) 1. Choose the correct alternatives for the following : 10x 1=10 i) Inserting a new node after a given node in a doubly linked list requires a) four pointer exchanges b) two pointer exchanges c) one pointer exchanges d) np pointer exchange. 3001 (0) | Turn over ), ICE C878 TECH (CSE-OLDy/ IT (OLECE (0). EE (0). EEE (0) ii) iii) iv) v) vi) 1 (0) (OWVSEM-V/CS-302/201.,, A complete binary tree with jeaves Contains b) logy n nodes a) nnodes n ©) 2n-1 nodes qd) 2" nodes. A vertex of degree one is called a) Isolated vertex b) Pendant vertex Coloured vertex d) Null vertex. ce) A sort, which iteratively passes through a list exchange the first element with any element less jh,, and then repeats with a new first element, is calleq a) . Bubble sort b) Selection sort c) Heap sort d) Quick sort. The postfix equivalent of the prefix * + ab — cd is a) ab+cd-* b) ab+ca* ©) ab+ca*- @ abcd + - « A linear list that allows elements to be added removed at either end but not in the middle is calle a) stack b) ¢) priority queue a ef these CSB.TECH (CSE-OLDY IT (O),ECE (0), EE (0), EEE (0), ICE (OVBEM-4109-00272012-13 vii) Which of the following methods had the best average case complexity for searching ? a) Hashing b) Sequential search c) Random search d) Binary search. viii) The technique of linear probing for collision resolution can lead to a) clustering b) _ efficient storage utilization c) underflow d) overflow. ix) Ifa binary tree is threaded for in-order traversal a right NULL link of any node is replaced by the address of its a) successor b) predecessor c) root d) own, x) Fora function f(n) = 1000 n log n + 500 n4 +052", we can say that f(n) is a) O(n*) b) O(nlogn) od O(2") d) none of these. 3001 (0) 3 [ Turn over CS/B.TECH (CSE-OLD)/ IT (0),ECE (0), EE (0), EEE (0), ICE (O/SEM-3/CS-302/2012-13 GROUP - B ( Short Answer Type Questions ) 2. Answer any three of the following. 3x55); Discuss the advantages and disadvantages of linked list ove, descending order. function to insert an element into a sorted array of array as linear data structure and:also write down the 3. addressing. Define hashing. Explain with a suitable example the collision 4. resolution technique using linear probing with open LIFO ? Define big O notation, What-is stack-and why is this called 5. binary tree. Write the algorithm for in-order traversal of a threadei 6. Prove that for any non-empty binary tree T, if ng i3 the number of leaves and ng be the number of nodes havin, 5 degree 2 then prove % Ng =Ngtl. rae Y y Write an algorithm to delete a node from a doubly linked lis » B where a node contains one data and two address revious and next ) portion. CSIB.TECH (CSE-OLDY/IT (0),ECE (0), EE (0), EEE (0), ICE (OSEM-31CS-2022012-13 b) c) FRONT = 2, REAR = 4 & QUEUE: ...... ,A,C, D, 3001 (0) GROUP - c (Long Answer Type Questions ) Answer any three of the following. 3 x 15 = 45 Write the algorithm of binary search and calculate the complexity for best, worst and average cases. Why is queue data structure called FIFO ? Construct the following queue of characters where queue is a circular array which is allocated six memory cells. Describe the queue as the following operations take place : i) Fis added to the queue. ii) Two characters are deleted from the queue. ii) K, L, Mare added into the queue. iv) Rts added to the queue. v) One character is deleted from the queue. 5 { Turn over CSIB.TECH (CSE-OLD)’ IT (0),ECE (0), EE (0), EEE (0), ICE (OVSEM-9/CS-302/2012-13 9. a) Howcana polynomial such as 5x8 + 600x5 + 45x2 - 5x + 56 be represented by a linked list. b) Write the algorithm to reverse linked list. ©) What is dummy node in a linked list. d) Write the function in c language to find the predecess,, of a node in linked list. 10. a) The in-order & pre-order traversal sequences of node in a binary tree are given as follows : pee a fae Fe c Draw the binary tree. State the algorithm to constr the tree. b) Insert the following keys in order given below to bu them into an AVL tree: gh, s, 1, e, m, t, u. c) What is two-way threading ? 11. a) What is stack ? b) Write the algorithm to evaluate postfix expression us: stack data structure, and hence evaluate follow postfix expression : 5+ 67+- c) Convert the following infix expression into equiv.: postfix expression : a+bacr(deerfleg, 40) 6 CSIB.TECH (CSE-OLDY IT (0),ECE (0), EE (0), EEE (0), ICE (OVSEM-3/0S-302/201213 12. Write short notes on the following : a) b) 9 d) ei Quick sort B-tree Tail recursion AVL Tree. qpERICSDAT/OAVSe-3rd/CS-302/2014.15 CS-302 DATA STRUCTURE & ALGORITHM Time Allotted: 3 Hours Full Marks: 70 The questions are of equal value. ; The figures in the margin indicate full marks. Candidates are required to give their answers in their own words as far as practicable. GROUP A (Multiple Choice Type Questions) 1, Answer any fen questions. 10x1 = 10 (i The number of swapping needed to sort numbers 8,22,7,9,31,19,5,13 in ascending order using bubble sort is (A) 11 () 12 © (D) 14 (ii) Binary search uses : (A) divide and reduce strategy (B) divide and conquer strategy (C) heuristic search (D) both (A) & (B) (iii) The following sequence of operations is performed on a stack: push(1), push(2), pop, push(1), push(2), pop, pop, pop, push(2), pop. The sequence of popped out values are (A) 2,2,1,1,2 (B) 2,2,1,2,2 (C) 2,1,2,2,1 (D) 2,1,2,2,2 (iv) The postfix expression for *+ a bc dis (A) ab+ed—* (B) abcd +-* (C)ab+cd*- (D) ab+-cd * 3152 1 CS/B.tech/CSE/T/odd/Sem-3rd/CS-302/2014-15 (v) Adjacency matrix for a digraph is- (A) unit matrix (B) symmetric matrix (C) asymmetric matrix (D) none of these (vi) Which of the following is a hash function? (A) quadratic probing (B) chaining (C) open addressing (D) folding (vii) Linked list is not suitable data structure for which one of the following problems? (A) insertion sort (B) radix sort (C) binary search (D) polynomial addition (viii) Number of all possible binary trees with 4 nodes is- (A) 13 (B) 12 (C) 14 (D) 15 (ix) If the inorder and preorder traversal of a binary tree are D,B,F,E,G,H,A,C and A,B,D,E,F,G,H respectively then, the postorder traversal of that tree is- (A) D,F,G,A,B,C,H,E (B) F,H,D,G,E,B,C,A (C) C,G,H,F,E,D,B,A (D) D,F,H,G,E,B,C,A (x) The heap(represented by an array) constructed from the list of numbers 30,10,80,60,15,55,17 is- (A) 60,80,55,30,10,17,15 (B) 80,55,60,15,10,30,17 (C) 80,60,30,17,55,15,10 (D) none of these (xi) In array representation of Binary tree, if the index number of a child node is 6 then the index number of it’s parent node is: \ A)2 (B)3 \ (4 (D)5 , 7) BFS constructs (A) a minimal cost spanning tree of a graph (B) a depth first spanning tree of a graph {C) a breadth first spanning tee of a graph {D) none of these _gbeelOSEATIO‘ASerm-3PA/CS-3022014.1 s GROUP B (Short Answer Type Questions) 4 Answer any three questions. _ Differentiate between Linear and Non Linear data structures? Give two examples ‘ofeach. 3, _ Write an algorithm to find the largest and smallest element in a single linear list. 4, @) Suppose one 2-D array is initialized as int a [5] [7]; Base address is 4000: Find the location of element a [2] [4] in row major form and column major form. (0) Define Sparse Matrix. 5, @) Prove that the maximum no. of nodes in a binary tree of depth k is 2*—1. (0) What are the characteristics of algorithm? 6 Drawa minimum heap tree from the list below: 12,11,7,3,10,-5,0,9,2 Now do the heap sort operation over the heap tree. GROUP C (Long Answer Type Questions) Answer any three questions. 1 (a) Ry resent the given polynomial using a link list. xt xP Sx +2 ® Writ the pseudo code / C code for adding two polynomials (already given by user, no need to take input). Also comment on the complexity of your algorithm. (©) Write the Pseudocode or C code to implement Tower of Hanoi problem. Also find the complexity of your procedure. . (a) Insert the following numbers into a binary search tree in the order,that they are given and draw the resulting tree. 87;36;22515;56;85;48;91;72;6 Delete 48 and draw the resulting tree. Delete 15 and draw the resulting tree. (0) Write an algorithm to insert an element into binary search tree. 52 3 3x5 =15 342 342 3+2 3x15 =45 442 3+4 946 CS/B.tech/CSE/T/odd/Sem-3rd/CS-302/2014-15 9. (a) Define sorting. (b) What is a stable sorting? What is In-Place sorting? R soe gabe (c) Write the Preudcode for Merge sort implementation. What is its time complexity? (d) If the existing array is sorted and you want to insert a ne\ without disrupting the sortedness then which sorting techni Why? (¢) What is Hashing? ww element in the list ique you should use? 10.(a) Show the stages in growth of an order -4B- Tree when the following keys are inserted in the order given:- 84 82 29 97 61 10.45 28 49 70 86 68 19 55.22 11 557716 ‘ (b) How does an AVL tree differ from a binary search tree? Insert the following keys in the order given below to build them into an AVL tree:- i 8 1291176662144 Clearly mention different rotation used and balance factor of each node. (c) Write the Prim’s algorithm for finding MST from a graph. 11. _ Write short notes on any shree of the following (a) Radix Sort. () Index sequential File Organization. (c) DFS in graph. (d) Interpolation search. (e) Threaded binary tree. 5+6 g/B.THCH/CSE/IT/ODD SEM/ SEM-3/CB-302/2016-17 \WAULANA ABUL KALAM AZAD UNIVERSITY OF TECHNOLOGY, WEST BENGAL Paper Code : CS-302 DATA STRUCTURE AND ALGORITHM ne Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Sandidates are required to give their answers in their own words as far as practicable. GROUP -A ( Multiple Choice Type Questions ) Choose the correct alternatives for the following : ii) 0151 10x1=10 The postfix equivalent of the prefix * + ab — cd is a) ab+cd-* b) abcd +-* ce) -ab+cd*—- d) ab+-cd* If a binary tree is threaded for inorder traversal a right NULL link of any node it is replaced by the address of its a) successor b) predecessor c) root d) own. { Turn over CS/B.TECH/CSE/1T/ODD SEM/ SEM-3/CS-302/2016-17 iit) Adjacency matrix of a digraph is a) Identity matrix b) Symmetric matrix ©) Asymmetric matrix d) None of these. iv) Linked lists are not suitable for a) Stack b) Dequeue i c) AVL tree d) Binary Search v) The ratio of items present in a hash table to the total size is called a) balance factor b) ‘load factor ¢) item factor d) weight factor. vi) Maximum possible height of an AVL tree with 7 nodes is a) 3 ; b) 4 as) »a)-6. vii) The deque can be used a) asastack b) asa queue c) both as a stack and asa queue d) none of these. vill) Inserting a node. after a given node: ina doubly linked list requires a) four pointer exchanges b) two pointer exchanges c) ‘6ne pointer exchange d) no pointer exchange. tx) The minimum height of a binary tree of Nn nodes is a)oon b) n/a ce) n/2-2 - da) log in +1) x) What will be the time complexit 7 to sort an array of n elements ? a) O(logn) ‘c) O(n) ty for selection sort b) O( niogny ad) O(n?), ‘ 3/30151 2

You might also like