Helsinki University of Technology
Laboratory of Information Processing Science
Tik-76.122 Data Structures and Algorithms
demo

Assignment 2 (2 points)

Below is a adjacency list of an undirected graph. Traverse through the graph from the given node. Use a non-recursive depth-first algorithm that uses a stack (see the lecturer notes).

You can send an answer to this assignment at most 3 times.



Your browser can't run 1.0.2 Java applets.

Possible reason: Java language is disabled. For example with Netscape Navigator 3.x the Java language could be enabled in options-menu choosing Network Preferences/Languages/Enable Java.


Example

Consider the following adjacency list:

		A:  F  C  B  G
		B:  A
		C:  A
		D:  F  E
		E:  G  F  D
		F:  A  E  D
		G:  E  A
		H:  I
		I:  H
		J:  K  L  M
		K:  J
		L:  J  M
		M:  J  L

Using non-recursive depth-first algorithm the stack would be as following (starting from node A representing the stack after each visit.

		A
		F C B G
		F C B E
		F C B D
		F C B
		F C
		F
		H
		I
		J
		K L M
		K L
		K