depth first traversal And breadth first traversal

124 views
Skip to first unread message

Hafsa Tariq

unread,
May 29, 2015, 1:33:41 PM5/29/15
to dsfas...@googlegroups.com




starting with = 30

DFS: 30,5,10,20,7,6,2,1,11,16

BFS: 30,5,7,20,10,6,2, 1,11,16

Ma'am, I just want to confirm whether these answers are correct or not? 


Mehreen Saeed

unread,
May 30, 2015, 4:24:05 AM5/30/15
to Hafsa Tariq, dsfas...@googlegroups.com
Hafsa

Both are incorrect.  YOU CANNOT START WITH 30.  You have to start with the lowest key, which is 1.  Please do the traversal again and post your solution.

Mehreen

--
You received this message because you are subscribed to the Google Groups "DSFAST2015" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsfast2015+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dsfast2015/9c425301-69a3-470d-b4e0-29cb080805d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hafsa Tariq

unread,
May 30, 2015, 5:13:22 AM5/30/15
to Mehreen Saeed, dsfas...@googlegroups.com
DFS : 1, 16,11,2,6,7,30,5,10,20
BFS: 1,11,16,2,6,7,30,5,20,10
--
Regards
Hafsa Tariq Javed

L13-4191

unread,
May 30, 2015, 1:28:12 PM5/30/15
to dsfas...@googlegroups.com, courses...@gmail.com
Ma'am, can you please specify the conditions for traversing a graph? Even if it is a BFS or DFS, why should or shouldn't we choose vertex 11 from the immediate successors of 1 after starting from 1 in the home work and not vertex 16 to enqueue or push in the data structure?

Mehreen Saeed

unread,
May 30, 2015, 2:07:20 PM5/30/15
to Hafsa Tariq, dsfas...@googlegroups.com
This is again not correct. Whenever you have adjacent nodes lowest key should be printed first. Please redo and post again. Specifically, look at adjacent to 1 nodes. Lower key to print first. 

Mehreen



-------- Original message --------
From Hafsa Tariq <hafsata...@gmail.com>
Date: 30/05/2015 14:13 (GMT+05:00)
To Mehreen Saeed <courses...@gmail.com>
Cc dsfas...@googlegroups.com
Subject Re: depth first traversal And breadth first traversal

Mehreen Saeed

unread,
May 30, 2015, 2:08:53 PM5/30/15
to L13-4191, dsfas...@googlegroups.com
Taimur, see the rule in my previous mail. You can also try traversals on graph posted by Hafsa. 

Mehreen



-------- Original message --------
From L13-4191 <taz.t...@gmail.com>
Date: 30/05/2015 22:28 (GMT+05:00)
To dsfas...@googlegroups.com
Cc courses...@gmail.com
Subject Re: depth first traversal And breadth first traversal


L13-4191

unread,
May 30, 2015, 4:58:06 PM5/30/15
to dsfas...@googlegroups.com, taz.t...@gmail.com
Ma'am, should we consider the above graph as two sub graphs? one starting from the vertex 1 and the other starting from vertex 2 ?

Salman Afzal

unread,
May 31, 2015, 6:15:30 AM5/31/15
to L13-4191, dsfas...@googlegroups.com
1,11,16,2,6,7,5,10,20,30(DFS)  and 1,16,11,2,6,7,30,5,20,10 (BFS) for the above graph.Are they right?

On Sat, May 30, 2015 at 1:58 PM, L13-4191 <taz.t...@gmail.com> wrote:
Ma'am, should we consider the above graph as two sub graphs? one starting from the vertex 1 and the other starting from vertex 2 ?

--
You received this message because you are subscribed to the Google Groups "DSFAST2015" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsfast2015+...@googlegroups.com.

Hafsa Tariq

unread,
May 31, 2015, 12:41:36 PM5/31/15
to Mehreen Saeed, L13-4191, dsfas...@googlegroups.com
DFS : 1,11,16,2,6,7,30,5,10,20
BFS: 1,11,16,2,6,7,30,5,20,10
> https://groups.google.com/d/msgid/dsfast2015/CABgdOkWfa4doU2DO1Uv9w64UqSFSC9z_2EEX3aFX%2Bh_xvm6C9Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



Mehreen Saeed

unread,
Jun 1, 2015, 2:07:24 AM6/1/15
to Hafsa Tariq, L13-4191, dsfas...@googlegroups.com
Great.  Hafsa, your answer is correct.

DFS : 1,11,16,2,6,7,30,5,10,20
BFS: 1,11,16,2,6,7,30,5,20,10

Salman, your answer is not correct.  Please do the traversal again.

Mehreen
Reply all
Reply to author
Forward
0 new messages