Which Of The Following Code Correctly Represents The Function #1760
Which of the following code correctly represents the function to reverse stack without using recursion?
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 Recursion - Stack Reversal using Recursion - Quiz No.1.
Which of the following code correctly represents the function to reverse stack without using recursion?
#include <stack> void reverseStack(stack<int> &input, stack<int> &extra) { while(input.size()!=0) { extra.push(input.top()); input.pop(); } input.swap(extra); }
#include <stack> void reverseStack(stack<int> &input, stack<int> &extra) { while(input.size()!=0) { extra.push(input.top()); input.pop(); } extra.swap(input); }
#include <stack> void reverseStack(stack<int> &input, stack<int> &extra) { while(input.size()!=0) { input.pop(); extra.push(input.top()); } extra.swap(input); }
#include <stack> void reverseStack(stack<int> &input, stack<int> &extra) { while(input.size()==0) { input.pop(); extra.push(input.top()); } extra.swap(input); }
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