0% found this document useful (0 votes)
31 views

Assignment E2

This document provides instructions for Assignment 2. Students are asked to: 1) Identify the appropriate data structure for two problems - a meeting reminder (priority queue) and a table of contents (tree). 2) Perform pre-order, in-order, and post-order traversals on a sample tree. 3) Use Dijkstra's algorithm to find the shortest path from node A to all other nodes in a weighted graph. 4) Use Ford's algorithm to find the shortest path from node A to all other nodes in a directed weighted graph. The assignment is due on September 9th, 2014 at 3pm.

Uploaded by

Sri Bathy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Assignment E2

This document provides instructions for Assignment 2. Students are asked to: 1) Identify the appropriate data structure for two problems - a meeting reminder (priority queue) and a table of contents (tree). 2) Perform pre-order, in-order, and post-order traversals on a sample tree. 3) Use Dijkstra's algorithm to find the shortest path from node A to all other nodes in a weighted graph. 4) Use Ford's algorithm to find the shortest path from node A to all other nodes in a directed weighted graph. The assignment is due on September 9th, 2014 at 3pm.

Uploaded by

Sri Bathy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 2: Given on 26/8/2014.

Please submit by 9
th
Sept 2014, 3pm.



A. Check the ADT or data structure that is most appropriate for each of the following problems:


1. You want to build a meeting reminder for a PDA that keeps track of events your schedule and
periodically checks the next event to sound an alarm to remind you of the next thing you need
to do.
o List
o Stack
o Queue
o Priority Queue

2. You want to build a table of contents for a textbook. The textbook consists of chapters, chapters
consist of sections, and sections consist of subsections.
o List
o Tree
o Binary Tree
o Stack


B. List the sequence of nodes visited by preorder, inorder and postorder traversals of the following
tree:
A

B
C
D
E
F
G
H
I J





o Pre-order Traversal : ABDGEHICFJ
o In-order Traversal : GDBHEIACJF
o Post-order Traversal : GDHIEBJFCA

C. Consider the following undirected, weighted graph:




Step through Dijkstras algorithm to calculate the single-source shortest paths from A to every
other vertex. Show your steps in the table. Cross out old values and write in new ones, from left
to right within each cell, as the algorithm proceeds. Finally, indicate the lowest-cost path from
node A to node F.

o Using Dijkstras algorithm
o Known vertices (in order marked known): A B C G E D or F D or F
Vertex Known Cost Path
A Y 0
B Y 1 A
C Y 3 2 A B
D Y 8 7 B E
E Y 6 5 B C
F Y 107 A E
G Y 3 B

o Lowest-cost path from A to F: A to B to C to E to F







D. Consider the following directed, weighted graph:
Using the appropriate algorithm, find the shortest path from A to every other vertex. Show your
steps in a table.





o Using Fords Algorithms
o Known vertices (in order marked known):A B D F C G E
Vertex Known Cost Path
A Y 0
B Y 2 A
C Y 7 A
D Y 4 B
E Y 12 9 AC
F Y 6 D
G Y 8 F





End of Questions

You might also like