Uploaded by Devendra Bhavsar

Data Structure Assignment

advertisement
DATA STRUCTURES ASSIGNMENT
Issue Date
: November 07, 2018
Submission Date: November 15, 2018
Instructions1. Assignment submission Deadline is November 15, 2018, 04:00 PM.
2. Assignment solution should be in Hard copy (Handwritten with each step
solution).
1. Write the preorder, inorder and postorder traversals of the binary tree shown
below.
2. Use the remove algorithm discussed in class to remove a node from the binary
search tree shown below. Draw the resulting tree based on the algorithm (and
the associated code given in lecture). For each answer, show the sequence of
recursive calls made and the reference returned for each recursive call.
a.
b.
c.
d.
Remove node 65 from the original tree.
Remove node 16 from the original tree.
Remove node 12 from the original tree.
Remove node 42 from the original tree.
3. Draw the binary tree whose in-order and post-order traversals of the nodes are:
In-order: G D P K E N F A T L
Post-order: G P D K F N T A L E
4. What is a Binary Search Tree (BST)? Make a BST for the following sequence of
numbers.
45, 36, 76, 23, 89, 115, 98, 39, 41, 56, 69, 48 Traverse the tree in Preorder, Inorder
and postorder.
5. AVL tree balance violation cases:
a. Insert the following keys, in order, into an initially empty AVL tree: 12, 8,
9, 20, 10, 15, 3, 11, and 5
b. . Find a key we could insert into your resulting tree that would result in a
case 1 balance violation (left-left).
6. Draw the expression tree of the following infix expression. Convert it in to Prefix
and Postfix expressions.
7. Describe why it is a bad idea to implement a linked list version of a queue that
uses the head of the list as the rear of the queue and no tail pointer.
8. Write a program to find the minimum cost of a spanning tree.
9. Write a Program that implements depth first search algorithm and Breadth First
Algorithm?
10. Natural merge sort is to be used to sort the file of integers: 12, 37, 42, 9, 5, 7, 50,
40,
45, 92. What is order of the numbers after one pass of the sort?
11. The elements 32, 15, 20, 30, 12, 25 and 16 are inserted one by one in the given
order into a Max-heap. What is the resultant Max-heap?
12. Apply Dijkstra’s Algorithm for the given graph and find shortest path from
every node to every other node?
13. Write and explain Prim’s and Kruskal’s algorithm for finding the minimum
spanning tree. Also find the MST for the following graph-
14. Construct a binary tree whose nodes in inorder and preorder are given as
follows: Inorder : 10, 15, 17, 18, 20, 25, 30, 35, 38, 40, 50
Preorder: 20, 15, 10, 18, 17, 30, 25, 40, 35, 38, 50
15. Given the following inorder and preorder traversal reconstruct a binary tree
Inorder sequence D, G, B, H, E, A, F, I, C
Preorder sequence A, B, D, G, E, H, C, F, I
16. Write an algorithm to sort a given list using Quick sort method. Describe the
behavior of Quick sort when input is already sorted.
17. Sort the following list using Heap Sort
66, 33, 40, 20, 50, 88, 60, 11, 77, 30, 45, 65.
18. Draw the 11 item hash table resulting from hashing the keys:
12, 44, 13, 88, 23, 94, 11, 39, 20, 16 and 5
using the hash function h(i) = (2i+5) mod 11
19. The following values are to be stored in a hash table
25, 42, 96, 101, 102, 162, 197
Describe how the values are hashed by using division method of hashing with
a table size of 7. Use chaining as the method of collision resolution.
20. Sort the following sequence of keys using Bubble and selection sort.
66, 77, 11, 88, 99, 22, 33, 44, 55
21. What is quick sort? Sort the following array using quick sort and Insertion sort
method.
24 56 47 35 10 90 82 31
22. Show the result of running BFS and DFS on a directed graph given below using
vertex A as source. Show the status of the data structure used at each stage
Download