You are not logged in. Please login at www.codechef.com to post your questions!

×

DFS, BFS using Vectors

0
1

I want to implement DFS, BFS using vector of vectors. Can someone help me with that? I have never code using vector, so it is a bit tough for me i guess.

asked 05 Dec '14, 14:06

shivmohan's gravatar image

4★shivmohan
112
accept rate: 0%


Do not guess, if you never used vector before, do some tests, read some examples...

http://www.cplusplus.com/reference/vector/vector/

link

answered 05 Dec '14, 14:54

betlista's gravatar image

3★betlista ♦♦
16.9k49115225
accept rate: 11%

i have read it already. i am not able to write code for Dfs and bfs using it.

(05 Dec '14, 14:59) shivmohan4★

If you can do it with arrays you can do it with vectors. If you can't do it with arrays you need to learn dfs/bfs and solve some questions.

(05 Dec '14, 15:31) Organic-Shilling0★

ya.. i think you are right. but thanks anyways...

(05 Dec '14, 16:49) shivmohan4★
1

Try to solve this problem - http://www.codechef.com/problems/PETERSEN using BFS...

We can help you if you got stucked ;-)

Try to solve this problem - http://www.codechef.com/problems/FIRESC (DFS) also ;-)

(05 Dec '14, 17:01) betlista ♦♦3★

void bfs(int s,vector<int> adj[],bool vis[]) can someone help me ? how can i find the size of adj[] ?

link

answered 17 Aug '17, 11:42

shashank0j's gravatar image

2★shashank0j
1
accept rate: 0%

Well you have probably made a 2D vector and size of adj[i] (i.e no. of columns of a particular row) can be found simply using "adj[i].size()" whereas the size of adj[] (i.e. no. of rows of 2D vector) has to be passed in the function!

(17 Aug '17, 14:55) dishant_185★

Refer Geeks for Geeks for graph+stl solutions. Here is the link for dfs using vectors http://www.geeksforgeeks.org/graph-implementation-using-stl-for-competitive-programming-set-1-dfs-of-unweighted-and-undirected/

link

answered 17 Aug '17, 20:57

sid_somani's gravatar image

4★sid_somani
536
accept rate: 0%

Refer to this link. Probably the best if you are a beginner in graphs c++.
Graph Theory Part - 1

link

answered 23 Oct '18, 22:48

ranjan_1997's gravatar image

2★ranjan_1997
11
accept rate: 0%

Dude, see the date.

(24 Oct '18, 02:34) ay23063★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×727
×506
×368

question asked: 05 Dec '14, 14:06

question was seen: 7,332 times

last updated: 24 Oct '18, 12:03