3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by nchy13
0

Hi, I need to do a depth first search tree for the following undirected graph:

1-2-3
| | |
4-5 6
|   |
7-8-9

(Sorry about the graph being so unclear, the dots are just to space the lines out). It says to start at A which I'm guessing is 1?

My first attempt at the order was 1-4-7-8-9-6-3-2-5 but I'm really not sure?

Use Code tags to keep spacing.

That's not a tree.

Did you mean:

1-2-3
|   |
4-5 6
|    
7-8-9

Or in tree form:

___1___
     |       | 
   __4__     2
  |     |    |
  7     5    3
  |          |
  8          6
  |
  9

If so, it's 1-4-7-8-9-5-2-3-6
Your tree would be:

___1___
     |       | 
   __4__     3
  |     |    |
  7     6    2
  |          |
  8          5
  |
  9
0

Hi, thanks for your reply. I meant

1-2-3
| | |
4-5 6
|   |
7-8-9
0

That is not a tree as far as I can tell. 5 & 9 cannot be the child of 2 nodes. Unless you can explain how it works and I'm missing something.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.