Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DSA Quiz

Total questions: 40

Worksheet time: 27mins

Name
Class
Date
1.

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

2.

Which of the following applications may use a stack?

a)

a) A parentheses balancing program

b)

b) Tracking of local variables at run time

c)

c) Compiler Syntax Analyzer

d)

d) Data Transfer between two asynchronous process

3.

The data structure required to check whether an expression contains balanced parenthesis is?

a)

a) Stack

b)

b) Queue

c)

c) Array

d)

d) Tree

4.

Circular Queue is also known as ________

a)

a) Ring Buffer

b)

b) Square Buffer

c)

c) Rectangle Buffer

d)

d) Curve Buffer

5.

What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)

{

if(head == NULL)

return;

fun1(head->next);

printf("%d ", head->data);

}

a)

a) Prints all nodes of linked lists

b)

b) Prints all nodes of linked list in reverse order

c)

c) Prints alternate nodes of Linked List

d)

d) Prints alternate nodes in reverse order

6.

Linked list data structure offers considerable saving in _____________

a)

a) Computational Time

b)

b) Space Utilization

c)

c) Space Utilization and Computational Time

d)

d) Speed Utilization

7.

___________ is neither an algorithm nor a program.

a)

a.Computing

b)

b.Pseudo code

c)

c.Computer science

d)

d.None of the above

8.

Efficiency of an algorithm is measured by

a)

Time and Capacity complexity

b)

Time and Space complexity

c)

Speed and Space complexity

d)

Speed and Capacity complexity

9.

Data in the data structures are processed by operations like insertion, deletion, sorting, merging and

a)

Traversing

b)

Searching

c)

Retrieval

d)

Both A and B

10.

What will be the postfix form of the above expression -

(A+B)∗(C∗D-E)∗F/G

a)

None of these

b)

A B + C D ∗ E − F G ∗ / ∗

c)

A B + C D E ∗ − F G / ∗ ∗

d)

A B + C D ∗ E − F G / ∗ ∗

11.

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

a)

Managing function calls

b)

The stock span problem

c)

Arithmetic expression evaluation

d)

All of the above

12.

List of data in which element can be inserted and removed at the same end is called as __________.

a)

array

b)

stack

c)

linked list

d)

queue

13.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced.

Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).

The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?

a)

1

b)

2

c)

3

d)

4 or more

14.

User perform following operations on stack of size 5 then -

push(1);

pop();

push(2);

push(3);

pop();

push(2);

pop();

pop();

push(4);

pop();

pop();

push(5);

a)

Overflow Occurs

b)

Stack Operations will be performed Smoothly

c)

Underflow Occurs

d)

None of these

15.

To evaluate an expression without any embedded function calls:

a)

One stack is enough

b)

Two stacks are needed

c)

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

d)

A Turing machine is needed in the general case

16.

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

a)

Managing function calls

b)

The stock span problem

c)

Arithmetic expression evaluation

d)

All of the above

17.

List of data in which element can be inserted and removed at the same end is called as __________.

a)

array

b)

stack

c)

linked list

d)

queue

18.

In a Queue Data Structure...

a)

New elements may only be added to the end of the queue

b)

Elements may only be retrieved from the front of the queue.

c)

Elements may only be retrieved from the end of the queue.

d)

New elements may only be added to the front of the queue

19.

Select ALL the situations that a Queue data structure would be used?

a)

Printer in a room full of computers

b)

Characters typed on a keyboard

c)

Back Button

d)

Undo Button

20.

Which is the correct operation for:

"Add a item to the rear of the queue."

a)

enQueue(item)

b)

Append.Queue(item)

c)

enQueue()

d)

AddItem(EnQueue())

21.

A function calls itself is called ___________.

a)

queue

b)

recursion

c)

function

d)

none of above

22.

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

a)

1

b)

2

c)

3

d)

4

23.

Which of the following is true about linked list implementation of queue?

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

24.

Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are

a)

Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT

b)

Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR

c)

Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT

d)

Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

25.

Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter.

What is the worst case time complexity of a sequence of n MultiDequeue() operations on an initially empty queue?

a)

O(n)

b)

O(n+k)

c)

O(nk)

d)

O(n^2)

26.

Suppose implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?

a)

A queue cannot be implemented using this stack.

b)

A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes a sequence of two instructions.

c)

A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction.

d)

A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction each.

27.

If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values

a)

2,2,1,1,2

b)

2,2,1,2,2

c)

2,1,2,2,1

d)

2,1,2,2,2

28.

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is

a)

A

b)

B

c)

C

d)

D

e)

E

29.

Consider the following operations performed on a stack of size 5 : Push (a); Pop() ; Push(b); Push(c); Pop(); Push(d); Pop();Pop(); Push (e) Which of the following statements is correct?

a)

Underflow occurs

b)

Stack operations are performed smoothly

c)

Overflow occurs

d)

None of the above

30.

Which of the following is not an inherent application of stack?

a)

Implementation of recursion

b)

Evaluation of a postfix expression

c)

Job scheduling

d)

Reverse a string

31.

If there's no base criteria in a recursive program, the program will

a)

not be executed

b)

executed until all condition matches

c)

executes infinitely

d)

obtain progressive approach

32.

Which of the following is not an inherent application of stack?

a)

a) Reversing a string

b)

b) Evaluation of postfix expression

c)

c) Implementation of recursion

d)

d) Job scheduling

33.

In the linked list implementation of the queue , where does the insert method place the new entry on the linked list?

a)

At the front

b)

At the rear

c)

After all other entries that are greater than the new entry.

d)

After all other entries that are smaller than the new entry.

34.

Suppose we have a circular array implementation of the queue, with ten items in the queue stored at data[2] through data[11]. The current capacity is 42. Where does the insert method place the new entry in the array?

a)

data[1]

b)

data[2]

c)

data[11]

d)

data[12]

35.

One difference between a queue and a stack is:

a)

Queues require linked lists, but stacks do not.

b)

Stacks require linked lists, but queues do not.

c)

Queues use two ends of the structure; stacks use only one.

d)

Stacks use two ends of the structure, queues use only one.

36.

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

a)

ABCD

b)

ABDC

c)

DCAB

d)

DCBA

37.

Suppose you have the following series of queue operations.

q = Queue();

q.enqueue(1);

q.enqueue(10);

q.enqueue(100);

q.dequeue();

q.dequeue();

What items are the output?

a)

10010

b)

101

c)

110

d)

10010

38.

Suppose you have the following series of queue operations.

q = Queue();

q.enqueue('hello');

q.enqueue('dog');

q.dequeue();

q.enqueue('3');

q.dequeue();

What items are the output?

a)

hellodog

b)

hello

c)

doghello

d)

hellodog3

e)

3

39.

Suppose you have the following series of queue operations.

q = Queue();

q.enqueue('hello');

q.enqueue('dog');

q.enqueue(3);

q.dequeue();

What items are left on the queue?

a)

'hello', 'dog'

b)

'dog', 3

c)

'hello', 3

d)

'hello', 'dog', 3

40.

Which the following is not true about queue?

a)

An ordered collection of items where the addition of new items happens at one end

b)

The simplest example of a queue is the typical line that we all participate in from time to time.

c)

As an element enters the queue it starts at the rear and makes its way toward the front, waiting until that time when it is the next element to be removed.

d)

An ordered collection of items where the addition of new items and the removal of existing items always takes place at the same end