wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Data Structures Training Quiz2

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

In a stack, if a user tries to remove an element from an empty stack it is called _________

a)

Underflow

b)

Empty Collection

c)

Overflow

d)

Garbage Collecction

2.

What is the value of the postfix expression 6 3 2 4 + – *?

a)

1

b)

40

c)

74

d)

-18

3.

Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?

a)

1

b)

2

c)

3

d)

4

4.

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

              8 2 3 ^ / 2 3 + 5 1 -

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

a)

3,2

b)

1,5

c)

6,1

d)

5,7

5.

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

a)

abc × + def ^ ^ -

b)

abc × + de ^ f ^ -

c)

ab + c × d - e ^ f ^

d)

+ a × bc ^ ^ def

6.

To evaluate an expression without any embedded function calls :

a)

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

b)

One stack is enough

c)

Two Stacks are needed

d)

A Turing machine is needed in general case

7.

The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is

a)

284

b)

213

c)

142

d)

71

8.

A function f defined on stacks of integers satisfies the following properties. f(∅) = 0 and f (push (S, i)) = max (f(S), 0) + i for all stacks S and integers i.If a stack S contains the integers 2, -3, 2, -1, 2 in order from bottom to top, what is f(S)?

a)

6

b)

4

c)

3

d)

2

9.

Suppose a stack is to be implemented with a linked list instead of an array. What would be the effect on the time complexity of the push and pop operations of the stack implemented using linked list (Assuming stack is implemented efficiently)?

a)

O(1) for insertion and O(n) for deletion

b)

O(1) for insertion and O(1) for deletion

c)

O(n) for insertion and O(1) for deletion

d)

O(n) for insertion and O(n) for deletion

10.

Consider n elements that are equally distributed in k stacks. In each stack, elements of it are arranged in ascending order (min is at the top in each of the stack and then increasing downwards). Given a queue of size n in which we have to put all n elements in increasing order. What will be the time complexity of the best known algorithm?

a)

O(n log k)

b)

O(nk)

c)

O(n2)

d)

O(k2)

11.

If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?

a)

ABCD

b)

DCBA

c)

DCAB

d)

ABDC

12.

A normal queue, if implemented using an array of size MAX_SIZE, gets full when?

a)

Rear = MAX_SIZE – 1        

b)

Front = (rear + 1)mod MAX_SIZE

c)

Front = rear + 1

d)

Rear = front

13.

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

a)

When a resource is shared among multiple consumers.

b)

When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes

c)

Load Balancing

d)

All of the above

14.

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you

a)

1

b)

2

c)

3

d)

4

15.

Which of the following is NOT a common operation in a queue data structure?

a)

Enqueue

b)

Dequeue

c)

Peek

d)

Shuffle