10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

Algorithm of BFS:‐<br />

1) Choose v. Visit all neighbors of v that have not been visited.<br />

2) For each visited vertex repeat the same process until all vertices were visited.<br />

<strong>1.</strong> Enqueue the root node.<br />

2. Dequeue a node and examine it.<br />

a. If the element sought is found in this node, quit the search and<br />

return a result.<br />

b. Otherwise enqueue any successors (the direct child nodes) that<br />

have not yet been discovered.<br />

3. If the queue is empty, every node on the graph has been examined – quit<br />

the search and return "not found".<br />

4. Repeat from Step 2.<br />

5. Exit.<br />

Features of BFS:‐<br />

Space complexity:<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 90 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!