Appendix B
Appendix B
11. (a) (i) Explain how stack is used to convert the following infix expression into postfix form
a+b*c+(d*e+f)*g. (8)
(ii) Give the linked list implementation of stack. (8)
Or
(b) Explain and write the routine for insertion, deletion and finding element in then cursor
based linked list. (16)
12. (a) (i) Construct an expression tree for the expression ab+cde+** (10)
(ii) Give a precise expression for the minimum number of nodes in an AVL tree of height
h and what is the minimum number of nodes in an AVL tree of height 15? (6)
Or
(b) (i) Write function to perform delete min in a binary heap. (8)
(ii) Show the result of inserting 3; 1; 4; 6; 9; 2; 5; 7 into an initially empty binary search
tree. (8)
13. (a) Given input {4371,1323,6173,4199,4344,9679,1989} and a hash function h(x)=x mod 10.
Show the resulting: (16)
91
Appendix B - University Question papers
Or
(b) (i) Write a routine to implement kruskals’ algorithm. (8)
(ii) Discuss in detail about biconnectivity. (8)
15. (a) (i) Explain in detail about branch and bound algorithm design technique with an example.
(10)
(ii) Write a routine for random number generator algorithm. (6)
Or
(b) (i) Explain in detail about asymptotic notations. (6)
(ii) Discuss in detail about NP-complete problem with example. (10)
92
Appendix B - University Question papers
93
Appendix B - University Question papers
Fig.2
13. (a) Write the algorithm to find the shortest path between 2 nodes. Trace the algorithm to find
the minimum distance between node A and G in the graph shown in Fig.2. (16)
Or
(b) Explain the steps involved in Branch and Bound algorithm design technique. Apply this
technique to solve the following instance of knapsack problem. Draw the state space tree.(16)
ITEM PROFIT WEIGHT
0 0 0
1 11 1
2 21 11
3 31 21
4 33 23
5 43 33
6 53 43
7 55 45
8 65 55
14. (a) What is hashing? Explain any two methods of hashing. What is meant by collision
resolution? What are the methods used to resolve collisions?
Or
(b) Explain the principles of dynamic programing. Given a list of words a, am, and, egg, if,
the, two and their corresponding probabilities 0.22, 0.18, 0.20, 0.05, 0.25, 0.02, 0.08 respectively.
Construct an optimal binary search tree. (16)
15. (a) Write an algorithm for basic operations on stack. Formulate an algorithm to check for
balanced parenthesis. (16)
Or
(b) What is max heap? Explain the steps involved in inserting elements into a heap with an
example. Write an algorithm to insert am element into max heap.
94
Appendix B - University Question papers
11. (a) (i) Explain the operations of queue with C function. (8)
(ii) Explain the array implementation of stacks. (8)
Or
(b) Explain the cursor implementation of linked list. (16)
12. (a) Explain the traversals of binary tree with examples. (16)
Or
(b) Describe the operations of binary search tree with functions. (16)
13. (a) Briefly explain the single rotation and double rotation of AVL tree with examples. (16)
Or
(b) Explain the binary heap operations with examples. (16)
14. (a) For the given input (4371,1323,6173,4199,4344,9679,1989) and a hash function n(X) = X
mod 10. Show the resulting:
(i) Seperate chaining hash table.
(ii) Open addressing hash table using linear probing.
(iii) Open addressing hash table using quadratic probing.
(iv) Open addressing hash table with second hash function. h2(X)=7-(X mod 7). (16)
Or
95
Appendix B - University Question papers
96
Appendix B - University Question papers
11. (a) (i) What are Circular Queues? Write an ADT for c Circular Queue to perform insertion
and deletion operations. (10)
(ii) Write the deletion routine for cursor implementation of linked lists. (6)
Or
(b) (i) Write an algorithm to insert a node in the beginning and in the end of the linked list.(8)
(ii) Write an algorithm to evaluate a postfix expression. Execute your algorithm using the
following postfix expression as your input: ab+cd+*f↑ (8)
12. (a) (i) Formulate an ADT to insert and delete a node in a binary search tree. (8)
(ii) What are expression trees? Represent the following expression using a tree: (a-b)/
((c*d)+e. Comment on the result that you get when is traversed in preorder, inorder and
postorder. (1+1+6)
Or
(b) (i) Construct an AVL tree with values F, S, Q, K, C, L, H, T, V, W, M, R into an initially
empty tree. Write an algorithm for inserting into an AVL tree. (10)
(ii) Write a note on general trees with an example. (6)
13. (a) (i) The following values are to be sorted in a hash table.
25, 42, 96, 101, 102, 162, 197
97
Appendix B - University Question papers
Describe how the values are hashed by using division method of hashing with a table size of 7.
Use hashing as the method of collision resolution. (8)
(ii) What are the types of collision resolution techniques and the methods used in each of
the type? Explain the different types of collision resolution techniques. (8)
Or
(b) Explain with code, the union operations hat are performed: (4×4=16)
(i) Arbitrarily
(ii) Union by size
(iii) Union by height
(iv) Find with path compression.
14. (a) (i) Which are the two standard ways of traversing a graph? Explain each with an example.
(10)
(ii) What is minimum spanning tree? Execute Kruskal’s algorithm to find the minimum
spanning tree for a graph. (6)
Or
(b) (i) Explain Dijkstra’s algorithm for finding the shortest path in a graph. (10)
(ii) Consider the following specification of a graph G.
V(G)= {1, 2, 3, 4}
E(G) = {(1,2), (1,3), (3,3), (3,4), (4,1)}
(1) Draw an undirected graph.
(2) Draw its adjacency matrix. (6)
15. (a) (i) Explain how the Divide and Conquer technique is applied in Merge Sort. (8)
(ii) What does dynamic programming have in common with divide and conquer. Describe
about it. (6)
Or
(b) (i) Explain greedy algorithm for the change making problem. (10)
(ii) Describe about randomized algorithms. (6)
98
Appendix B - University Question papers
99
Appendix B - University Question papers
12. (a) (i) Discuss how a node could be inserted in a binary tree? (8)
(ii) Write a procedure in C to find the Kth element in binary tree. (8)
Or
(b) (i) Derive the expression tree for the expression (a + b + c) + ((d ∗e + f ) ∗ g ) . Briefly
explain the construction procedure for the above. (6)
(ii) Write routines to implement the basic binary search tree operations. (10)
13. (a) Explain with algorithm how insertion and deletion is performed in a AVL tree. Explain
how the tree is balanced after the operation. (16)
Or
(b) (i) Write a procedure in C that will traverse a linked B-tree, visiting all its entries in order of
keys (smaller to larger). (10)
(ii) What is meant by collision in hashing? Explain the separate chaining collision resolution
100
Appendix B - University Question papers
strategy. (6)
14. (a) (i) Define Graph. Briefly explain the graph traversal algorithms with an example.
(8)
(ii) Find the shortest path from node 1 to 7 using shortest path algorithm. (8)
Or
(b) With an example, explain Kruskal’s algorithm for finding minimum spanning tree.
(16)
15. (a) (i) Develop an algorithm for binary search using divide and conquer method. Analyze its
time and space complexity. (8)
(ii) Write a greedy algorithm to solve job sequencing with deadline problem. (8)
Or
(b) (i) Explain any one algorithm to solve bin packing problem. (6)
(ii) Explain backtracking algorithm design technique with an example. (10)
101
Appendix B - University Question papers
PART B — (5 × 16 = 80 Marks)
11. (a) Describe the data structures used to represent lists. (Marks 16)
Or
(b) Describe circular queue implementation in detail giving all the relevant features. (Marks 16)
12. (a) Explain the tree traversals. Give all the essential aspects. (Marks 16)
Or
(b) Explain binary search tree ADT in detail. (Marks 16)
13. (a) Discuss in detail the B-tree. What are its advantages? (Marks 16)
Or
(b) Explain binary heaps in detail. Give its merits. (Marks 16)
14. (a) Explain separate chaining and extendible hashing. (Marks 16)
Or
(b) Explain in detail the dynamic equivalence problem. (Marks 16)
15. (a) Consider the following graph
(i) Obtain minimum spanning tree by Kruskal's algorithm. (Marks 10)
(ii) Explain Topological sort with an example. (Marks 6)
Or
(b) (i) Find the shortest path from 'a' to 'd' using Dijkstra's algorithm in the graph in Figure 2
given in question 15(a). (Marks 10)
(ii) Explain Euler circuits with an example. (Marks 6)
102
Appendix B - University Question papers
PART B — (5 × 16 = 80 Marks)
11. (a) (i) Derive an ADT to perform insertion and deletion in a singly linked list. (8)
(ii) Explain cursor implementation of linked lists. Write the essential operations. (8)
Or
(b) (i) Write an ADT to implement stack of size N using an array. The elements in the stack are
to be integers. The operations to be supported are PUSH, POP and DISPLAY. Take into account
the exceptions of stack overflow and stack underflow. (8)
(ii) A circular queue has a size of 5 and has 3 elements 10, 20 and 40 where F = 2 and R = 4.
After inserting 50 and 60, what is the value of F and R. Trying to insert 30 at this stage what
happens? Delete 2 elements from the queue and insert 70, 80 & 90. Show the
sequence of steps with necessary diagrams with the value of F & R. (8)
12. (a) (i) Write an ADT to construct an AVL tree. (8)
(ii) Suppose the following sequences list nodes of a binary tree T in preorder and inorder,
respectively:
Preorder : A, B, D, C, E, G, F, H, J
Inorder : D, B, A, E, G, C, H, F, J
Draw the diagram of the tree. (8)
Or
(b) (i) Write an ADT for performing insert and delete operations in a Binary Search Tree. (8)
103
Appendix B - University Question papers
(ii) Describe in detail the binary heaps. Construct a min heap tree for the following :
5, 2, 6,7, 1, 3, 8, 9, 4 (8)
13. (a) (i) Formulate an ADT to implement separate chaining hashing scheme. (8)
(ii) Show the result of inserting the keys 2, 3, 5, 7, 11, 13, 15, 6, 4 into an initially empty
extendible hashing data structure with M = 3. (8)
Or
(b) (i) Formulate an ADT to perform for the Union and find operations of
disjoint sets. (8)
(ii) Describe about Union-by-rank and Find with path compression with code. (8)
14. (a) (i) Write routines to find shortest path using Dijkstra’s algorithm. (8)
(ii) Find all articulation points in the below graph. Show the depth first spanning tree and the
values of DFN and Low for each vertex. (8)
Or
(b) (i) Write the pseudo code to find a minimum spanning tree using Kruskal’s algorithm. (8)
(ii) Find the topological ordering of the below graph. (8)
15. (a) (i) Discuss the running time of Divide-and-Conquer merge sort algorithm. (8)
(ii) Explain the concept of greedy algorithm with Huffman codes example. (8)
Or
(b) Explain the Dynamic Programming with an example. (16)
104
Appendix B - University Question papers
105
Appendix B - University Question papers
106
Appendix B - University Question papers
Or
(b) (i) Show the result of inserting the nodes 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty Binary
Search tree. (6)
(ii) Write down the functions to insert into an AVL tree by calling appropriate functions to
perform double and single rotations also.(10)
13. (a) (i) Given the input {4371, 1323, 6173, 4199, 4344, 9679, 1989} and a hash function of
h(X) = X (mod 10) show the resulting
(1) Separate Chaining hash table (5)
(2) Open Addressing hash table using linear probing (5)
(ii) What are the advantages and disadvantages of various collision resolution strategies? (6)
Or
(b) (i) State and explain the dynamic equivalence problem. (6)
(ii) Explain the path compression algorithm and analyse the Union/Find algorithm used. (10)
14. (a) (i) Give the Prim’s algorithm for determining minimum spanning tree and analyse this
algorithm for its worst case time complexity. (10)
(ii) Determine the minimum spanning tree for the following graph using Prim’s algorithm. (6)
Or
(b) (i) Write an algorithm to determine the biconnected components in the given graph. (10)
(ii) Determine the biconnected components in the following graph. (6)
15. (a) What is a greedy algorithm? Give two examples that can be solved using greedy
algorithm and explain them with example. (16)
Or
(b) What is NP completeness? Explain an NP complete problem with example. (16)
107
Appendix B - University Question papers
1. List out the areas in which data structures are applied extensively.
2. Convert the expression ((A+B)*C-(D-E)^(F +G)) to equivalent Prefix and Post fix notations.
3. How many different trees are possible with 10 nodes?
4. What is an almost complete binary tree?
5. In an AVL tree, at what condition the balancing is to be done?
6. What is the bucket size, when the overlapping and collision occur at same time?
7. Define graph.
8. What is a minimum spanning tree?
9. Define NP hard and NP complete.
10. What is meant by dynamic programming?
PART B — (5 × 16 = 80 Marks)
11. (a) (i) What is a linked list? Explain with suitable program segments any four operations of a
linked list. (Marks 12)
(ii) Explain with a pseudo code how a linear queue could be converted into a circular queue.
(Marks 4)
Or
(b) (i) What is a stack ADT? Write in detail about any three applications of stack. (Marks 11)
(ii) With a pseudo code explain how a node can inserted at a user specified position of a doubly
linked list. (Marks 5)
12. (a) (i) Discuss the various representations of a binary tree in memory with suitable example.
(Marks 8)
(ii) What are the basic operations that can be performed on a binary tree? Explain each of them
in
detail with suitable example. (Marks 8)
Or
(b) (i) Give an algorithm to convert a general tree to binary tree. (Marks 8)
(ii) With an example, explain the algorithms of in order and post order traversals on a binary
108
Appendix B - University Question papers
109
Appendix B - University Question papers
PART B — (5 × 16 = 80 Marks)
11. (a) (i) Write the insertion and deletion procedures for cursor based linked lists. (8)
(ii) Write the algorithm for the deletion and reverse operations on doubly linked list. (8)
Or
(b) (i) Write an algorithm for Push and Pop operations on Stack using Linked List. (8)
(ii) Explain the addition and deletion operations performed on a circular queue with necessary
algorithms. (8)
12. (a) (i) Write the algorithm for pre-order and post-order traversals of a binary tree. (8)
(ii) Explain the algorithm to convert a postfix expression into an expression tree with an
example. (8)
Or
(b) (i) Write an algorithm to insert an item into a binary search tree and trace the algorithm with
the items 6, 2, 8, 1, 4, 3, 5. (8)
(ii) Describe the algorithms used to perform single and double rotation on AVL tree. (8)
13. (a) Discuss the common collision resolution strategies used in closed hashing system. (16)
Or
(b) (i) What is union-by-height? Write the algorithm to implement it. (8)
(ii) Explain the path compression with an example. (8)
14. (a) (i) What is topological sort? Write an algorithm to perform topological sort. (8)
110
Appendix B - University Question papers
(ii) Write the Dijkstra’s algorithm to find the shortest path. (8)
Or
(b) Write the Kruskal’s algorithm and construct a minimum spanning tree for the following
weighted graph. (16)
15. (a) (i) Formulate an algorithm to multiply n-digit integers using divide and conquer approach.
(8)
(ii) Briefly discuss the applications of greedy algorithm. (8)
Or
(b) Find the optimal tour in the following traveling salesperson problem using dynamic
programming : (16)
111
Appendix B - University Question papers
PART B — (5 × 16 = 80 Marks)
11. (a) Explain the following operations in a doubly linked list.
(i) Insert an element (6)
(ii) Delete an element (5)
(iii) Reverse the list. (5)
Or
(b) (i) Discuss the algorithms for push and pop operations on a stack. (8)
(ii) Write an algorithm to insert and delete a key in a circular queue. (8)
12. (a) (i) Construct all possible tree structure with 4 nodes. (8)
(ii) Perform preorder, inorder and postorder traversals of the given tree. (8)
Or
(b) Explain the following operations on a binary search tree with suitable algorithms.
(i) Find a node (5)
(ii) Insert a node (5)
(iii) Delete a node. (6)
13. (a) (i) Discuss how to insert an element in an AVL tree. Explain with algorithm. (10)
(ii) What is B-Tree? Explain its properties. (6)
Or
112
Appendix B - University Question papers
(b) (i) Describe the different hashing functions with an example. (8)
(ii) Explain the common collision resolution strategies in open addressing hashing. (8)
14. (a) (i) Explain the breadth first search algorithm. (8)
(ii) Write and explain the Prim’s algorithm with an example. (8)
Or
(b) (i) What is a strongly connected graph? Give an example. (4)
(ii) Write the algorithm to compute lengths of shortest path. (4)
(iii) Explain the depth first search algorithm. (8)
15. (a) Find the optimal tour in the following traveling salesperson problem using dynamic
programming. (16)
Or
(b) (i) Explain the method of solving N queens problem by back tracking.(10)
(ii) Discuss briefly the various asymptotic notations used in algorithm analysis. (6)
113