Dijk Stra
Dijk Stra
01
9
B
7
1
C
2
8
E
V(G) = {1, 2, 3, 4, 5, 6}
E(G) = {(1,2), (2, 3), (3, 4), (5,1), (5, 6), (2, 6), (1, 6), (4, 6), (2, 4)}
For the following graph starting from the vertex 1, assuming vertex with smallest
label visited first
1,9,6,7,8,5,2,3,4,
) (
B. BFS
1,2,9,3,5,6,4,7,8
) (
14
/
2
/ \
1 5
\
11
/ \
10 17
/ /
7 30
2. What is the value stored in the parent node of the node containing 30?
__________________________________________________________________
3. What is the degree of the tree?
__________________________________________________________________
__________________________________________________________________
4. How many children does the root have?
__________________________________________________________________
5. What is the sibling of node 1?
in PreOrder: 55
34 15 10 25 50 76 60 80 85 rlr
InOrder : 10 15 25 34 50 55 60 76 80 85 lrr
PostOrder: 10 25 15 50 34
85 80 60 76 55
Draw a tree for the following infix expression and then convert it to prefix and
postfix expression
Infix = a+ (b*c) / d e
Prefix :
postfix:
The following two sequences are the output of the inorder and postorder
traversals of a binary search tree. Draw this tree.
Inorder: B C D E G H
Postorder: B
* A(+/bcd)
3. a + b * c d/ (e + f)
4. a+b*c-d/e*f
5. a+(b*c)-(d/e)*f
b. 4, 25, 5, 1, /, /, *, 8, 7, +, -