Iat3 Answer Key
Iat3 Answer Key
2. Define tree traversal and what is the time complexity of level order traversal?
Tree traversal is the process of visiting all nodes in a tree systematically. The time complexity of
level order traversal is O(n), where n is the number of nodes.
4. Does either Prim’s or Kruskal’s algorithm work if there are negative edge weights?
Yes, both Prim’s and Kruskal’s algorithms work correctly with negative edge weights, as they
only require non-cyclic graphs and do not depend on edge weights being positive.
7. Discuss about the AVL trees along with its properties and advantages with
suitable example
AVL Tree:
It is a self-balancing binary search tree where the difference between heights of left and
right subtrees (balance factor) is at most 1 for every node.
8a. Explain the insert and delete operations of heap with example
Heap Insert:
9. State the BST property and outline an algorithm to search BST with example
BST Property:
For each node, all keys in the left subtree are less, and all keys in the right subtree are
greater than the node’s key.
10. The adjacency matrix of a four vertex graph is shown below. List the
sequence of nodes visited starting from vertex 4, in depth first search on the
graph.
ABCD
A 0 1 0 0
B 1 0 1 0
C 0 1 0 1
D 0 0 1 0
Visit D → neighbors: C
Visit C → neighbors: B, D (D visited)
Visit B → neighbors: A, C (C visited)
Visit A → neighbor: B (visited)
DFS order: D → C → B → A
11. Consider the given undirected graph and apply Prim’s Algorithm to find the
minimum spanning tree. Illustrate the steps.
Illustration: (You should provide the graph with weights and show each step adding edges with
minimum weights.)