0% found this document useful (0 votes)
77 views7 pages

Without Stack Pointer, You Cannot Access Stack Elements

This document contains a quiz on data structures and algorithms concepts related to stacks. It includes 39 multiple choice questions testing knowledge of stacks, queues, trees, arrays, recursion, pointers, and more. The questions cover topics like postfix notation, balanced parentheses, stack operations, parameter passing in C, storage classes, and recursive functions.

Uploaded by

Sayantan Pal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views7 pages

Without Stack Pointer, You Cannot Access Stack Elements

This document contains a quiz on data structures and algorithms concepts related to stacks. It includes 39 multiple choice questions testing knowledge of stacks, queues, trees, arrays, recursion, pointers, and more. The questions cover topics like postfix notation, balanced parentheses, stack operations, parameter passing in C, storage classes, and recursive functions.

Uploaded by

Sayantan Pal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Data Structure & Algorithms (PCC-CS301)

MCQs on Stack for 2nd year CSE by NDR, August 31st, 2021

Name: SAYANTAN PAL Sec: B Class roll no. :105

1. Without stack pointer, you cannot access stack elements


(A) True (B) False
(C) Partially true (D) No need

2. A mathematical-model with a collection of operations defined on that model is called


(A) Data Structure (B) Abstract Data Type
(C) Primitive Data Type (D) Algorithm

3. If the address of A[1][1] and A[2][1] are 1000 and 1010 respectively and each element
occupies 2 bytes then the array has been stored in _________ order.

(A) row major (B) column major


(C) matix major (D) none of these

4. The smallest element of an array’s index is called its


(A) lower bound. (B) upper bound.
(C) range. (D) extraction.

5. The data structure required to evaluate a postfix expression is


(A) queue (B) stack
(C) array (D) linked-list

6. The data structure required to check whether an expression contains balanced parenthesis is
(A) Stack (B) Queue
(C) Tree (D) Array

7. What is the postfix form of the following prefix expression -A/B*C$DE


(A) ABCDE$*/- (B) A-BCDE$*/-
(C) ABC$ED*/- (D) A-BCDE$*/

8. The postfix form of the expression (A+ B)*(C*D− E)*F / G is


(A) AB+ CD*E − FG /** (B) AB + CD* E − F **G /
(C) AB + CD* E − *F *G / (D) AB + CDE * − * F *G /

9. Representation of data structure in memory is known as:


(A) recursive (B) abstract data type
(C) storage structure (D) file structure

10. An ADT is defined to be a mathematical model of a user-defined type along with the
collection
of all ____________ operations on that model.
(A) Cardinality (B) Assignment
(C) Primitive (D) Structured

11. In C, parameters are always

(A) Passed by value (B) Passed by reference


(C) Non-pointer variables are passed by value and pointers are passed by reference (D) Passed
by value result

12. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is


(A) 600. (B) 350.
(C) 650. (D) 588.

13. What is the postfix form of the following prefix *+ab–cd


(A) ab+cd–* (B) abc+*–
(C) ab+*cd– (D) ab+*cd–

14. Which of the following is not a storage class specifier in C?

(A) auto (B) register


(C) volatile (D) typedef

15. Which data structure is needed to convert infix notation to postfix notation?

(A) Branch (B) Queue


(C) Tree (D) Stack

16. A characteristic of the data that binary search uses but the linear search ignores is

the___________.
(A) Order of the elements of the list.
(B) Length of the list.
(C) Maximum value in list.
(D) Type of elements of the list.
17. The largest element of an array index is called its
(A) lower bound. (B) range.
(C) upper bound. (D) All of these.

18. Which data structure is used for implementing recursion?


(A) Queue. (B) Stack.
(C) Arrays. (D) List.

19. What is the result of the following operation?


Top (Push (S, X))
(A) X (B) null
(C) S (D) None of these.

20. A program P reads in 500 integers in the range [0...100] exe presenting the scores of 500
students. It then prints the frequency of each score above 50. What would be the best way for
P to store the frequencies?

(A) An array of 50 numbers (B) An array of 100 numbers

(C) An array of 500 numbers (D) A dynamically allocated array of 550 numbers

21. The OS of a computer may periodically collect all the free memory space to form contiguous
block of free space. This is called
(A) Concatenation (B) Garbage collection
(C) Collision (D) Dynamic Memory Allocation

22. What is the following code segment doing?


void fn( ){
char c;
cin.get(c);
if (c != ‘\n’) {
fn( );
cout.put(c);
}
}
(A) The string entered is printed as it is.
(B) The string entered is printed in reverse order.
(C) It will go in an infinite loop.
(D) It will print an empty line.

23. A mathematical-model with a collection of operations defined on that model is called


(A) Data Structure (B) Abstract Data Type
(C) Primitive Data Type (D) Algorithm

24. The smallest element of an array’s index is called its


(A) lower bound. (B) upper bound.
(C) range. (D) extraction.

25. The data structure required to evaluate a postfix expression is


(A) queue (B) stack
(C) array (D) linked-list

26. The data structure required to check whether an expression contains balanced parenthesis
is
(A) Stack (B) Queue
(C) Tree (D) Array

27. What is the postfix form of the following prefix expression -A/B*C$DE
(A) ABCDE$*/- (B) A-BCDE$*/-
(C) ABC$ED*/- (D) A-BCDE$*/

28. The postfix form of the expression (A+ B)*(C*D− E)*F / G is


(A) AB+ CD*E − FG /** (B) AB + CD* E − F **G /
(C) AB + CD* E − *F *G / (D) AB + CDE * − * F *G /

29. Output of following program?

#include <stdio.h>
int main()
{
    int i = 5;
    printf("%d %d %d", i++, i++, i++);
    return 0;
}
(A) 765 (B) 567
(C) 777 (D) Compiler dependent

30. In C, parameters are always

(A) Passed by value (B) Passed by reference


(C) Non-pointer variables are passed by value and pointers are passed by reference (D) Passed
by value result
31. Consider the following C function

void swap (int a, int b)


{
   int temp;
   temp = a;
   a = b;
   b = temp;
}

In order to exchange the values of two variables x and y.

(A) Call swap (x, y) (B) Call swap (&x, &y)


(C) swap(x,y) cannot be used as it does not return any value (D) swap(x,y) cannot be used as the
parameters are passed by value

32. Which of the following is not a storage class specifier in C?

(A) auto (B) register


(C) volatile (D) typedef

33. #include <stdio.h>

int main()
{
    static int i=5;
    if(--i){
        main();
        printf("%d ",i);
    }
}

(A) 4321 (B) 1234


(C) 0000 (D) compiler error

34. #include <stdio.h>

int main()
{
    static int i=5;
    if (--i){
        printf("%d ",i);
        main();
    }
}
(A) 4321 (B) 1234
(C) 4444 (D) 0000

35. #include <stdio.h>

int main()
{
    int x = 5;
    int * const ptr = &x;
    ++(*ptr);
    printf("%d", x);
   
    return 0;
}

(A) 6 (B) 5
(C) run time error (D) compiler error

36. #include <stdio.h>

int main()
{
    int x = 5;
    int const * ptr = &x;
    ++(*ptr);
    printf("%d", x);
   
    return 0;
}
(A) 6 (B) 5
(C) run time error (D) compiler error

37. #include<stdio.h>

int main()
{
   typedef int i;
   i a = 0;
   printf("%d", a);
   return 0;
}
(A) 1 (B) 0
(C) run time error (D) compiler error
38. #include<stdio.h>

int main()
{
  typedef int *i;
  int j = 10;
  i *a = &j;
  printf("%d", **a);
  return 0;
}
(A) 10 (B) 0
(C) Garbage value (D) compiler error

39. #include <stdio.h>

int fun()
{
  static int num = 16;
  return num--;
}
 
int main()
{
  for(fun(); fun(); fun())
    printf("%d ", fun());
  return 0;
}
(A) Infinite loop (B) 13 10 7 4 1
(C) 14 11 8 5 2 (D) 15 12 8 5 2

You might also like