Which Of The Following Functions Correctly Represent Iterative #1276
Which of the following functions correctly represent iterative DFS?
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Graph Search - Non-recursive Depth First Search - Quiz No.1.
Which of the following functions correctly represent iterative DFS?
void DFS(int s) { vector<bool> discovered(V, true); stack<int> st; st.push(s); while (!st.empty()) { s = st.top(); st.pop(); if (!discovered[s]) { cout << s << " "; discovered[s] = true; } for (auto i = adjacent[s].begin(); i != adjacent[s].end(); ++i) if (!discovered[*i]) st.push(*i); } }
void DFS(int s) { vector<bool> discovered(V, false); stack<int> st; st.push(s); while (!st.empty()) { s = st.top(); st.pop(); if (!discovered[s]) { cout << s << " "; discovered[s] = true; } for (auto i = adjacent[s].begin(); i != adjacent[s].end(); ++i) if (!discovered[*i]) st.push(*i); } }
void DFS(int s) { vector<bool> discovered(V, false); stack<int> st; st.push(s); while (!st.empty()) { st.pop(); s = st.top(); if (!discovered[s]) { cout << s << " "; discovered[s] = true; } for (auto i = adjacent[s].begin(); i != adjacent[s].end(); ++i) if (!discovered[*i]) st.push(*i); } }
void DFS(int s) { vector<bool> discovered(V, false); stack<int> st; st.push(s); while (!st.empty()) { s = st.top(); st.pop(); if (!discovered[s]) { cout << s << " "; discovered[s] = false; } for (auto i = adjacent[s].begin(); i != adjacent[s].end(); ++i) if (discovered[*i]) st.push(*i); } }
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes