Run Dfs Grid Stating 1 1 Show Order Discovery Q37237039

media%2F56d%2F56d78127-87d3-47ad-ac3e-75

Run DFS on this grid stating at (1,1). Show order ofdiscovery.


Answer


DFS: Step1:             

(5,5) (1,2) O-一中一一

Output: (1,1),(1,2)                              

Step 2:   

(5,5)                                               

Output: (1,1),(1,2),(1,3)

Step 3:  

(5,5) (14O

Output: (1,1),(1,2),(1,3),(1,4)  

Step 4:      

(5,5) (14O                                             

Output: (1,1),(1,2),(1,3),(1,4),(1,5)

Step5:         

(5,5) 15)O 1)0                                        

Output: (1,1),(1,2),(1,3),(1,4),(1,5),(2,5)

Step 6:    

(5,5)

Output: (1,1),(1,2),(1,3),(1,4),(1,5), (2,5),(3,5)

Step 7:

(5,5) 14)O                                          

Output: (1,1),(1,2),(1,3),(1,4),(1,5), (2,5), (3,5) ,(3,4)

Step8:                 

(5,5) 14)O                                 

Output: (1,1),(1,2),(1,3),(1,4),(1,5), (2,5), (3,5) ,(3,4), (3,3)

Step 9:   

(5,5) 15)O 14)O                                     

Output: (1,1),(1,2),(1,3),(1,4),(1,5), (2,5), (3,5) ,(3,4), (3,3), (3,2)

Step10:         

15)O (5,5) 14                                             

Output: (1,1),(1,2),(1,3),(1,4),(1,5),

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.