15
Pad. D. Y. Patil Institute of Engineering, Management and Research, Akurdi, Pune – 44 Department of Computer Engineering Advance data Structure Question Bank UNIT -1 to 6. Academic Year: 2016-17 Date: 1. (a) List and explain in brief applications of binary tree. [4] (b) What are properties for binary trees that distinguish them from general tree ? [6] (c) Write algorithm for traversal of binary tree and give suitable example for the same : [8] (i) Inorder (ii) Preorder (iii) Postorder. 2. (a) Write algorithm to delete node from BST. [8] (b) Write algorithm for inorder traversal of a threaded binary tree and give its time complexity. Also give example for the same. [10] 3. (a) What are graph storage structures ? Explain in detail. [8] (b) Write algorithm for Depth First Traversal of the graph and give suitable example for the same. [8] 1. (a) Write an algorithm for non-recursive in-order traversal of Binary tree. [8] (b) Create an AVL tree for the following elements. Show all steps with rotation :[6] 1 2 3 4 8 7 6 5. (c) Differentiate between linear and non-linear data structures. [4]

datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

  • Upload
    lycong

  • View
    219

  • Download
    1

Embed Size (px)

Citation preview

Page 1: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

Pad. D. Y. Patil Institute of Engineering, Management and Research, Akurdi, Pune – 44

Department of Computer Engineering

Advance data StructureQuestion BankUNIT -1 to 6.

Academic Year: 2016-17

Date:

1. (a) List and explain in brief applications of binary tree. [4](b) What are properties for binary trees that distinguish them from general tree ? [6](c) Write algorithm for traversal of binary tree and give suitable example for the same : [8](i) Inorder (ii) Preorder(iii) Postorder.

2. (a) Write algorithm to delete node from BST. [8](b) Write algorithm for inorder traversal of a threaded binary tree and give its time complexity. Also give example for the same. [10]3. (a) What are graph storage structures ? Explain in detail. [8](b) Write algorithm for Depth First Traversal of the graph and give suitable example for the same. [8]1. (a) Write an algorithm for non-recursive in-order traversal of Binary tree. [8] (b) Create an AVL tree for the following elements. Show all steps with rotation :[6]1 2 3 4 8 7 6 5.(c) Differentiate between linear and non-linear data structures. [4]

4. (a) Write an alogrithm for deleting leaf nodes and nodes with only one child from a Binary Search Tree. [8](b) What are threaded trees ? Explain with example. [6](c) Construct a Binary Search Tree for given numbers, show all steps : [4]14, 15, 4, 9, 7, 18, 3, 5, 7.5. (a) Write a function to create GRAPH using adjacency matrix method. [6](b) For the graph given in Fig. 1, draw minimum cost spanning tree using Prim’s algorithm, show all steps : [6]

Page 2: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

(c) What is in-degree, out-degree and degree of a vertex ? Explain with example. [4]

6. (a) Write an algorithm for generating minimum cost spanning tree using Kruskal’s method. [6] (b) Find the shortest path from vertex 1 to all other vertices in the graph of Fig. 2 using Dijkstra’s algorithm :

(c) Explain with example inverse adjacency list representation of graph. [4]

7. (a) Write Prim’s algorithm and explain stages of the algorithm for the following example : [8](b) Write pseudo code to find the shortest path in weighted graph.Find the shortest path in the following graph from node 0 to node 4. [8]8. (a) Write and explain algorithm to insert node into AVL tree. [8](b) Explain with example LL, LR, RR, RL rotation for AVL tree. [8]

Page 3: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

9. (a) What is bucket hashing ? Explain with example. [8](b) What is hash function ? Explain the following hash functions : [8](i) Mid-square(ii) Modulo Division(iii) Folding Method(iv) Digit Analysis.

10. (a) Write an ADT for a binary heap. Explain different operations on MAX heap in brief with example (any three). [10] (b) What is multiway tree ? State need of multiway trees. Explain B+ tree in brief. [8]

11. (a) Construct a B tree of order 5 for the following data : [10]50, 85, 12, 10, 6, 60, 70, 80, 37, 100, 120, 65,150, 62, 30, 17, 15, 28, 75, 78. (b) Write an algorithm to arrange numbers in ascending order using heapsort. Arrange the following numbers in ascending order using heapsort : [8]48, 0, –1, 82, 10, 2, 100.12. (a) Write a C/C++ program to perform create, insert, display and search operations for sequential file organization. [8](b) What is index sequential file organization ? State its advantages and disadvantages. [8]

13. (a) List different file organizations. State the need of file organizations. List different primitive operations on files. Compare sequential file with index sequential file organization. [10] (b) Explain in brief direct access file organization with example. [6]

14. (a) What is static and dynamic hashing ? Show that the hash function h(k) = k% 17 does not satisfy the one way property, week collision resistance or strong collision resistance. [8](b) Differentiate between sequential and index sequential file.Write a pseudocode to read and write contents using indexsequential file. [8]15. (a) Assume a hash table of size 15 and hash function H(X) =X Mod 15 performs linear probing with and without replacement for the given set of values. [8]0, 1, 2, 4, 72, 65, 85, 87, 90, 58, 52, 53, 42, 44, 91.(b) Write a program in ‘C’ for sequential file and perform the following operations : [8](i) Copying all data from one file to another(ii) Count number of characters in a file

Page 4: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

(iii) Count number of words in file(iv) Search a particular word in a file. 16. (a) Define the following with examples : [8](i) Complete Binary Tree(ii) Predecessor and Successor(iii) Graph(iv) OBST.(b) What is the necessity of converting a tree into binary tree ? Convert the following tree into a binary tree and list down the steps for the same. [8]

17. (a) Write functions for non-recursive pre-order and in-order traversal algorithms for a in-order threaded binary tree. [8](b) Construct a binary tree from the given traversals : [4]Pre-order : * + a – b c / – d e – + f g hIn-order : a + b – c * d – e / f + g – h(c) Write a function for creating binary search tree. [4][4162]-215 618. (a) Write an algorithm to perform DFS traversal for a graph. Perform DFS & BFS for the following graph : [10](b) Write short notes on Dijkstra’s algorithm. [4](c) Define Minimum Spanning Tree with an example. [2]

19. (a) Write an algorithm for Prim’s method.Find minimum spanning tree using Prim’s and Krushal’s method. [10](b) Describe the different ways of graph storage structure with an example. [6]20. (a) Construct an AVL search tree by inserting the following elements in the order of their occurrence. Show the balance factor and type of rotation at each stage : [12]148 153 158 1000 112 145 120 149 128 146(b) Explain symbol table with its applications. [6]

21. (a) Draw a Huffman tree for the given data set and find the corresponding Huffman codes : [8]

Page 5: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

22. (a) Given the following inorder and postorder traversal construct the binary tree : [6]Inorder — D B F E G A H I CPostorder — D F G E B I H C A .(b) What is AVL Tree ? Explain the RR, LL, RL and LR rotations with example. [6](c) Write a non-recursive C function to search an element in BST. [6]23. (a) What is Threaded Binary Tree ? Explain advantages and disadvantages of Threaded Binary Tree. [6](b) Construct BST for the following : [6]MAR, MAY, NOV, AUG, APR, JAN, DEC, JUL, FEB, JUN, OCT, SEPT(c) Write and explain non-recursive inorder traversal of Binary Tree. [6]24. (a) For the following construct : [8](i) Adjacency Matrix(ii) Adjacency List(iii) DFS search(iv) BFS search.

Page 6: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

(b) Use Dijkstra’s algorithm to obtain in non-decreasing order the lengths of the shortest paths from vertex 1 to all remaining vertices in the diagraph. [8]

25. (a) Find minimum spanning tree for the following using Prims and Kruskal algorithm. [6]

(b) Explain difference between DFS and BFS. [6]

Page 7: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

(c) Explain the following terms with example : [4](i) Path(ii) Simple path(iii) Cycle(iv) Loop.

26. (a) Explain the following : [9](i) Full and complete binary trees.(ii) List and explain in brief applications of binary tree.(iii) Explain class & object in OOP concept.(b) Write non-recursive algorithm for traversal of binary tree : [9](i) Inorder(ii) Preorder.27. (a) Draw binary search tree for data 12, 18, 20, 30, 35, 40, 42,48, 52. If root is 40 and leafs are 12, 52, write Binary Search Tree (BST) search algorithm. [10](b) Explain the following : [8]

(i) What is array representation of given binary tree ?(ii) What is linked representation of given binary tree ?What are important observations of linked representation ?28. (a) Write algorithm for Breadth First Traversal of the graph. Also write its complexity. [8] (b) Explain the following : [8](i) State the difference between Kruskal’s and Prims algorithm for minimum spanning tree (MST). (ii) Graph as an ADT.

29. (a) Write Kruskal’s Algorithm for MST and explain it with example. [8](b) Explain the following : [8](i) What are graph storage structures ?(ii) Topological sort.

Page 8: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

30. (a) Write and explain algorithm to delete node from AVL tree. [8](b) What is hash function ? Explain the different types of hash functions. [8]

31. (a) Explain different types of rotation for AVL tree with suitable example. [8](b) What are hashing methods ? Explain in brief. [8]

32. (a) Define heap. Explain types of heap. Write an algorithm to insert an element into heap. [8](b) Construct a B tree of order 5 for the following data : 50, 85, 42, 10, 16, 60, 70, 80, 87, 100, 120, 65, 150, 62, 30, 17, 18, 28, 75, 78.What is the best and worst case complexity of insert and delete operation on B tree ? [10]

33. (a) What is B tree ? Explain the process for deleting a particular value from B tree. [8](b) State algorithm to sort elements of a given array in ascending order using heapsort. Sort the following numbers using heapsort in ascending order :38, –10, –11, 72, 98, 62, 44. [10]34. (a) Write an algorithm to perform create, insert, display and search operations for sequential file organization. [8] (b) What is index sequential file organization ? State its advantages and disadvantages. [8][4262]-207 5 P.T.O.

35. (a) What is file ? List different file opening modes. Explain Index sequential file organization in brief. [8](b) Explain in brief : [8](i) Linked file organization(ii) Direct file organisation.

36. (a) Compare index sequential and direct access files. [6](b) Create a Hash table and resolve collisions using linear probing with and without replacement : 9, 45, 13, 59, 12, 75, 88, 11, 105, 46Hash table size = 11 and Hash function = key mod 10. [8](c) Write a note on re-hashing. [4]

37. (a) Write pseudo-code for implementation of primitive functions of index-sequential file. [8](b) Write a note on characteristics of good hash function. [4](c) Write a ‘C’ program using command line arguments to perform the following operations on a file :(i) Count number of white spaces

Page 9: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

(ii) Count number of special characters. [6]

38. (a) Implement stack as an ADT using sequential organisation. [8](b) Write a ‘C’ code to create an expression tree and performnon-recursive in-order traversal. [8]39. (a) What is the necessity of converting a tree into binary tree ?Convert the following tree into a binary tree and list down the steps for the same. [6](b) Implement binary tree as an ADT. [8](c) Write a ‘C’ function to implement post order traversal on threaded binary tree. [4]40. (a) Write a recursive function to find the height of a binary tree. [6](b) Given the following traversals build a binary tree from them : [6](i) In-order : 15, 22, 25, 30, 33, 40, 44, 50, 60, 75, 80, 90(ii) Pre-order : 50, 25, 22, 15, 40, 30, 33, 44, 75, 60, 90, 80.(c) Write a ‘C’ function to delete a node from a binary search tree. [6]41. (a) For the graph given draw the adjacency list and matrix : [4]

(b) Write pseudo-code for Prim’s method for finding MST of graph and explain the same for the graph whose weight matrix is given : [8]

(c) Define the following w.r.t. graphs with examples : [4](i) Degree of node(ii) Isolated node(iii) Path(iv) Cycle.

Page 10: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

42. (a) Write pseudo-code for Kruskal’s method for finding MST of graph and explain the same for the graph whose weight matrix is given in Fig 2. [8](b) Write a ‘C’ function to find the shortest path in a graph using Dijkstra’s algorithm with an example. [8]43. (a) Construct an AVL search tree by inserting the following elements in the order of their occurrence. Show the balance factor and type of rotation at each stage : [10]64 1 44 26 10 110 98 85 13 20(b) Explain the mechanism to create Huffman’s tree and use it for encoding and decoding. Assume suitable data. [6](b) Create a Huffman’s tree for the given data set and find the corresponding Huffman’s codes : [8]

Data WeightA 10B 3C 4D 15E 2F 4G 2H 3

44 (a) What is file? Explain the different types of file organization? [8](b) What is collision? Explain linear probing with and without replacement for student database with roll numbers:55, 88, 26, 37, 70, 60, 62, 41, 86, 64Hash Table Size =11 and Hash Function = Key mod 11.[8]45 (a) Write a pseudo code to perform the following operations on Direct Access files:(i) To modify record with given key value(ii) To delete record with given key value(iii) Insert record at specific location with given key value [8](b) What do you understand by Hash Table? Why they came into existence? Discuss different Hash functions.

46 (a) What is Binary search tree? Write a pseudo for deletion and insertion of a node in Binary search tree.[8](b) Write a non recursive function in C to traverse a binary tree in inorder traversal and preorder traversal.[8]

47 (a) What is threaded binary tree? Explain with example. [8](b) For a binary tree, the inorder and postorder traversal is as follows:Inorder:- H,D,I,B,E,A,J,F,K,C,G

Page 11: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

Postorder:- H,I,D,E,B,J,K,F,G,C.A(c)Create a binary tree & write pseudo code to print non leaf nodes of the tree and find height of the tree.[8]48 (a) Explain different types of representation of graphs with example.[4].(b) Write a non recursive pseudo code to perform DFS and BFS traversal for following a graph:[10] (c) Define:

(c) Define: (i) Complete graph (ii) Path [4]

49 (a) What is topological sorting? Explain with example. [6](b) Write a pseudo “C++” code to find minimum spanning tree using Kruskal’s algorithm for following graph:

Page 12: datastructureandalgorithm2017.files.wordpress.com…  · Web viewc) Write algorithm for ... Differentiate between linear and non-linear data structures ... Write functions for non-recursive

50. (a) The inorder and postorder traversals of a certain binary search tree are given as follows. Inorder Traversal: 10,30,40,50,52,54,55,60,90 Postorder Traversal: 40,54,52,55,50,30,60,90,10 Construct the binary search tree from above traversals and write the preorder traversal(b) Write a non-recursive pseudo C/C++ code to display the height of a binary tree(c) Define the following terms and their use with respect to the threaded binary tree with suitable example. i. Inorder threaded binary tree ii. Inorder successor iii. Inorder predecessor

51.(a) List the different depth first search traversal techniques for binary trees. Write a pseudo C algorithm for any one of the above techniques.(b) Write a non-recursive pseudo C/C++ code to generate the