Stack
1. Stack in Data Structure is -----
   a) LILO
   b) FIFO
   c) None of these
   d) LIFO
   Answer: d
2. Process of inserting an element in stack is called -----
   a) Create
   b) Push
   c) Evaluation
   d) Pop
   Answer: b
3. Process of inserting an element in stack is called -----
   a) Create
   b) Push
   c) Evaluation
   d) Pop
   Answer: d
4. In a stack, if a user tries to remove an element from an empty stack is called -----
   a) Underflow
   b) Empty collection
   c) Overflow
   d) Garbage collection
   Answer: a
5. Pushing an element into stack already having five elements and stack size of 5, then stack
   becomes -----
   a) Overflow
   b) Crash
   c) Underflow
   d) User flow
   Answer: a
6. Entries in a stack are “ordered”. What is the meaning of this statement?
   a) A collection of stacks is sortable
   b) Stack entries may be compared with the ‘<‘ operation
   c) The entries are stored in a linked list
   d) There is a Sequential entry that is one by one
     Answer: d
7.    Which of the following is not the application of stack?
     a) A parentheses balancing program
     b) Tracking of local variables at run time
     c) Compiler Syntax Analyzer
     d) Data Transfer between two asynchronous process
     Answer: d
8. Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
   The maximum number of parentheses that appear on the stack AT ANY ONE TIME when
   the algorithm analyzes: (()(())(()))?
   a) 1
   b) 2
   c) 3
   d) 4 or more
   Answer: c
9. What data structure would you mostly likely see in non recursive implementation of a
   recursive algorithm?
   a) Linked List
   b) Stack
   c) Queue
   d) Tree
   Answer: b
10. The process of accessing data stored in a serial access memory is similar to manipulating
    data on a ________
    a) Heap
    b) Binary Tree
    c) Array
    d) Stack
    Answer: d
11. What is the result of the following operation?
    Top (Push (S, X))
    a) X
    b) X+S
    c) S
    d) XS
    Answer: a
12. Which data structure is used for implementing recursion?
    a) Queue
    b) Stack
    c) Array
    d) List
    Answer: b
13. Which of the following statement(s) about stack data structure is/are NOT correct?
    a) Linked List are used for implementing Stacks
    b) Top of the Stack always contain the new node
    c) Stack is the FIFO data structure
    d) Null link is present in the last node at the bottom of the stack
    Answer: c
14. void fun(int n)
    {
        Stack S; // Say it creates an empty stack S
        while (n > 0)
        {
            push(&S, n%2);
            n = n/2;
        }
        while (!isEmpty(&S))
        printf("%d ", pop(&S)); // pop an element from S and print it
    }
    What does the above function do in general?
    a) Prints binary representation of n in reverse order
    b) Prints binary representation of n
    c) Prints the value of Logn
    d) Prints the value of Logn in reverse order
    Answer: b
15. Which of the following is true about linked list implementation of stack?
    a) In push operation, if new nodes are inserted at the beginning of linked list, then in pop
    operation, nodes must be removed from end.
    b) In push operation, if new nodes are inserted at the end, then in pop operation, nodes must
    be removed from the beginning.
    c) Both of the above
    d) None of the above
    Answer: d
16. Consider the following pseudocode that uses a stack
    declare a stack of characters
    while ( there are more characters in the word to read )
    {
       read a character
       push the character on the stack
    }
    while ( the stack is not empty )
    {
       pop a character off the stack
       write the character to the screen}
What is output for input "geeksquiz"?
a) geeksquizgeeksquiz
b) ziuqskeeg
c) geeksquiz
d) ziuqskeegziuqskeeg
Answer: b
17. declare a character stack
    while ( more input is available)
    {
       read a character
       if ( the character is a '(' )
         push it on the stack
       else if ( the character is a ')' and the stack is not empty )
         pop a character off the stack
       else
         print "unbalanced" and exit
    }
    print "balanced"
    Which of these unbalanced sequences does the above code think is balanced?
    a) ((())
    b) ())(()
    c) (()()))
    d) (()))()
    Answer: a
18. Consider the following array implementation of stack:
   #define MAX 10
   Struct STACK
   {
   Int arr [MAX];
   Int top = -1;
   }
   If the array index starts with 0, the maximum value of top which does not cause stack
   overflow is?
   a) 8
   b) 9
   c) 10
   d) 11
   Answer: a