DataStructures Quiz-1

DataStructures Quiz-1

Professional Development

12 Qs

quiz-placeholder

Similar activities

MR8

MR8

Professional Development

13 Qs

ready player one

ready player one

KG - Professional Development

15 Qs

minecraft

minecraft

Professional Development

15 Qs

Sanitation Systems phase 1 1.2

Sanitation Systems phase 1 1.2

Professional Development

15 Qs

Drainage level 3

Drainage level 3

Professional Development

15 Qs

Crane Hand Signals

Crane Hand Signals

Professional Development

10 Qs

309 Sanitation - PP 2

309 Sanitation - PP 2

Professional Development

10 Qs

Boss Baby

Boss Baby

KG - Professional Development

12 Qs

DataStructures Quiz-1

DataStructures Quiz-1

Assessment

Quiz

Other

Professional Development

Hard

Created by

Pallavi Girish

Used 2+ times

FREE Resource

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Following is C like pseudo code of a function that takes a number as an argument, and uses a stack S to do processing.

void fun(int n)

{

    Stack S;  // Say it creates an empty stack S

    while (n > 0)

    {

      // This line pushes the value of n%2 to stack S

      push(&S, n%2);

 

      n = n/2;

    }

 

    // Run while Stack S is not empty

    while (!isEmpty(&S))

      printf("%d ", pop(&S)); // pop an element from S and print it

}

Prints binary representation of n in reverse order

Prints binary representation of n

Prints the value of Logn

Prints the value of Logn in reverse order

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which one of the following is an application of Stack Data Structure?

Managing function calls

The stock span problem

Arithmetic expression evaluation

All of the above

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following pseudocode that uses a stack 

  • C

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"?

geeksquizgeeksquiz

ziuqskeeg

geeksquiz

ziuqskeegziuqskeeg

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The following postfix expression with single digit operands is evaluated using a stack:

8 2 3 ^ / 2 3 + 5 1 -

Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:

6, 1

5, 7

3, 2

1, 5

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full” is (GATE CS 2004)

(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)

top1 + top2 = MAXSIZE

(top1= MAXSIZE/2) or (top2 = MAXSIZE)

top1= top2 -1

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is

abc × + def ^ ^ -

abc × + de ^ f ^ -

ab + c × d - e ^ f ^

- + a × bc ^ ^ def

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

To evaluate an expression without any embedded function calls :
 

As many stacks as the height of the expression tree are needed

One stack is enough

Two stacks are needed

A Turing machine is needed in the general case

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?