Filter by year

Stacks questions

Q64

GATE DA 2025 DAData StructuresNAT2 marks

Report a problem with Q64

What is wrong?
Consider the following pseudocode.
Create empty stack S
Set x=0, flag=0, sum=0
Push x onto S
while (S is not empty){
    if (flag equals 0){
        Set x = x+1
        Push x onto S}
    if (x equals 8):
        Set flag=1
    if (flag equals 1){
        x = Pop(S)
        if (x is odd):
            Pop(S)
        Set sum = sum + x}
}
Output sum
The value of sum output by a program executing the above pseudocode is __________ (Answer in integer)
Show answer without attempting

Loading the answer…

0/10 correct0 marks

Related topics in Data Structures