0% found this document useful (0 votes)
18 views3 pages

Dijk Stra

The document provides information about Dijkstra's algorithm and binary search trees. It includes example graphs and binary search trees, with questions about traversing the trees, converting expressions between infix, prefix and postfix notation, and evaluating postfix expressions.

Uploaded by

fofo1975
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Dijk Stra

The document provides information about Dijkstra's algorithm and binary search trees. It includes example graphs and binary search trees, with questions about traversing the trees, converting expressions between infix, prefix and postfix notation, and evaluating postfix expressions.

Uploaded by

fofo1975
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Dijkstras algorithm

01

9
B

7
1

C
2

8
E

Draw a picture of the directed graph specified below:

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

Write the order of visiting node using:


A. DFS

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

Using the above tree diagram answer the following questions:

1. How many leaves does it have?


_____________________________________________________________________

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?

6. What is the ancestors of node 10?

. Make a Binary Search tree for the following sequence of numbers:


1. 55, 34, 76, 50, 80, 25, 10, 85,15, 60
- . Traverse the BST created in previous question in PreOrder, PostOrder and
InOrder

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.Using the following infix expressions convert them to postfix and


prefix :
1. (a + b) * (c d) / (e + f)
( Ab+)(cd-)*( ef+)/ ------------ / * ( +Ab)( -cd) (+ef)
2. A * (B + C / D)
A(bcd/+)*--------------------

* A(+/bcd)

3. a + b * c d/ (e + f)
4. a+b*c-d/e*f
5. a+(b*c)-(d/e)*f

1. Evaluate the following postfix expressions z


a. 4, 2 ,+, 3, * ,8, 2, / -

b. 4, 25, 5, 1, /, /, *, 8, 7, +, -

You might also like