wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DATA STRUCTUIR Quiz1 (AIML)

Total questions: 20

Worksheet time: 15mins

Name
Class
Date
1.

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

a)

1

b)

14

c)

74

d)

-18

2.

If the insertion and deletion happens from both the ends then the queue is called a______Queue

a)

a) Deque

b)

b) Header

c)

c) Queue

d)

d) Circular Queue

3.

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

4.

If for an algorithm time complexity is given by O(n) then complexityof it is:

a)

A. constant

b)

B. linear

c)

C. exponential

d)

D. none of the mentioned

5.

The number of elements in the adjacency matrix of a graph having 7 vertices is

a)

7

b)

14

c)

49

d)

34

6.

What is the number of moves required to solve Tower of Hanoi problem for k disks?

a)

a) 2k – 1

b)

b) 2k + 1

c)

c) 2k + 1

d)

d) 2k – 1

7.

In linked list implementation of a queue, where does a new element be inserted?

a)

a) At the head of link list

b)

b) At the tail of the link list

c)

c) At the centre position in the link list

d)

d) None

8.

Consider the following definition in c programming language.

struct node { int data; struct node next; }

typedef struct node NODE;

NODE *ptr;

Which of the following c code is used to create new node?

a)

ptr = (NODE*)malloc(sizeof(NODE));

b)

ptr = (NODE*)malloc(NODE);

c)

ptr = (NODE*)malloc(sizeof(NODE*));

d)

ptr = (NODE)malloc(sizeof(NODE));

9.

What is the way to increment the rear end of a circular queue?

a)

(Rear+1) mod MAX

b)

Rear mod MAX

c)

(Front+1) mod MAX

d)

(Rear-1) mod MAX

10.

The algorithm scans the list by swapping the entries whenever pair of adjacent keys are out of desired order

a)

A. Insertion sort

b)

B. Quick sort

c)

C. Selection sort

d)

D. Bubble sort

11.

Recognize the algorithm that does not divide the list.

a)

Merge sort

b)

Binary Search

c)

Linear Search

d)

Quick sort

12.

In the ....... traversal we process all of a vertex’s descendants before we move to an adjacent vertex.

a)

A. Depth Limited

b)

B. Breadth First

c)

C. Width First

d)

D. Depth First

13.

Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardinality will be the slowest?

a)

union

b)

membership

c)

cardinality

d)

union, intersection

14.

Which of the following algorithms is not feasible to implement in a linked list?

a)

Insertion Sort

b)

Quick Sort

c)

Heap Sort

d)

Binary Search

15.

Which of the following operations is performed more efficiently by doubly linked list than by linear linked list?

a)

Deleting a node whose location is given

b)

Searching an unsorted list for a given item

c)

Inserting a node after the node with a given location

d)

Traversing the list to process each node

16.

Consider a singly linked list of the form where F is a pointer to the first element in the linked list and L is the pointer to the last element in the list. The time of which of the following operations depends on the length of the list?

a)

Delete the last element of the list

b)

Delete the first element of the list

c)

Add an element after the last element of the list

d)

Interchange the first two elements of the list

17.

Assume that the operators +,-, X are left associative and ^ is right associative.

The order of precedence (from highest to lowest) is ^, X, +, -.

The postfix expression for the infix expression

a + b X c – d ^ e ^ f is?

a)

abc X+ def ^^ –

b)

abc X+ def ^^ –

c)

ab+c Xd – e ^f^

d)

-+aXbc^ ^def

18.

Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node x from the list?

a)

O(n)

b)

O(log2 n)

c)

O(logn)

d)

O(1)

19.

Consider the following operation performed on a stack of size 5.


Push(1);

Pop();

Push(2);

Push(3);

Pop();

Push(4);

Pop();

Pop();

Push(5);


After the completion of all operation, the no of element present on stack are

a)

1

b)

3

c)

2

d)

4

20.

When a collision occurs with a hashing function, what is one method for dealing with the collisions?

a)

creating a new linked list at that index

b)

creating a new array

c)

creating a new hash table

d)

creating a new binary tree