wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

data structures lab model exam

Total questions: 60

Worksheet time: 3600secs

Name
Class
Date
1.

What is an AVL tree?

a)

a tree which is balanced and is a height balanced tree

b)

a tree which is unbalanced and is a height balanced tree

c)

a tree with three children

d)

a tree with atmost 3 children

2.

Why we need to a binary tree which is height balanced?

a)

to avoid formation of skew trees

b)

to save memory

c)

to attain faster memory access

d)

to simplify storing

3.

What is the maximum height of an AVL tree with p nodes?

a)

p

b)

log(p)

c)

log(p)/2

d)

p/2

4.

Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given without performing any rotations?

a)

just build the tree with the given input

b)

find the median of the set of elements given, make it as root and construct the tree

c)

use trial and error

d)

use dynamic programming to build the tree

5.

Why to prefer red-black trees over AVL trees?

a)

Because red-black is more rigidly balanced

b)

AVL tree store balance factor in every node which costs space

c)

AVL tree fails at scale

d)

Red black is more efficient

6.

When performing trinode restructuring in an AVL tree, which node should be labeled "Z"?

a)

the first node at which the height-balance property is violated

b)

the first node that would be visited in an inorder traversal

c)

the child of the node where the height-balance property is violated

d)

the traller grandchild of the node at which the height-balance property is violated

7.

The goal of trinode restructuring is to ___.

a)

balance the subtree

b)

move "a" to be the root

c)

move "c" to be the root

d)

move "y" to be the root

8.

What is the worst-case height of an AVL tree?

a)

O(log n)

b)

O(n)

c)

O(n logn)

d)

O(1)

9.

A height balanced binary search tree is called__________

a)

height tree

b)

AVL tree

c)

binary tree

d)

binary search tree

10.

The balancing factor for AVL tree =

a)

hL-hR

b)

hR-hL

c)

hL-hL

d)

hR-hR

11.

The allowed values for height of an avl tree

a)

0,1

b)

2,0,-2

c)

0,1,2

d)

-1,0,1

12.

For RL imbalance which rotation is need to balance the tree

a)

Single LL rotation

b)

Single RR rotation

c)

LL and RR rotation

d)

None

13.

Possible Operations on AVL tree

a)

insertion

b)

deletion

c)

traversal

d)

all the above

14.

Which of the following is a double rotation

a)

LL rotation

b)

RR rotation

c)

RL rotation

d)

None

15.

What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree with a single node is 0.

a)

2

b)

3

c)

4

d)

5

16.

In an AVL tree the difference between heights of left and right sub trees cannot be more than

a)

1

b)

2

c)

3

d)

0

17.

AVL tree got its name after its

a)

Adelson-Velsky and Landis

b)

Adam Velsky Lenin

c)

Adelson Vel Landis

d)

None

18.

The sequence of insertion 10,12,14 will lead to imbalance by using which rotation can be used to balance the tree

a)

RR rotation

b)

LL rotation

c)

LR rotation

d)

RL rotation

19.

The sequence of insertion 25,12,9 will lead to imbalance by using which rotation can be used to balance the tree

a)

RR rotation

b)

LL rotation

c)

RL rotation

d)

LR rotation

20.

After an insertion or deletion operation in an AVL tree the first node with an invalid balancing factor is called............

a)

nodes

b)

invalid node

c)

node

d)

critical node

21.

What does a searching algorithm do?

a)

Search through a set of data

b)

Save a set of data

c)

Help to organise data

22.

What would be needed if searching algorithms didn't exist?

a)

The data would need to be saved

b)

Each item of data would need to be looked at one by one, until the searched for data was found

c)

A new set of data to look at would be needed

23.

Which of these is a type of searching algorithm?

a)

Linear search

b)

Word search

c)

Search engine

24.

What does a linear search do?

a)

Looks at the first item of data, then each one in turn, until it finds the data item requested

b)

Organises the data into alphabetical order

c)

Splits the data until the requested data is found

25.

What is an advantage of a linear search?

a)

It is very quick

b)

It only works with ordered lists

c)

It is a simple algorithm

26.

Which of the following is NOT an advantage of a serial search?

a)

It can be used on any set of data regardless of type

b)

It is the quickest search to use

c)

It is a simple algorithm, so it is easy to write a computer program to carry it out

27.

What does a binary search do?

a)

a)Looks at the first item of data, then each one in turn, until it finds the data item requested

b)

b)Converts all the data into binary

c)

c)Takes the data and splits it in half repeatedly until it finds the data item requested

28.

Which search algorithm would be best to use with ordered data?

a)

A binary search

b)

Either binary search or a linear search

c)

A linear search

29.

What is an advantage of a binary search

a)

It's very quick

b)

It only works with ordered lists

c)

It is a simple algorithm

30.

What is the biggest disadvantage of a binary search?

a)

It is slow

b)

It can only be used if the data is sorted into an order

c)

It takes the data and keeps dividing it in half until it finds the item it is looking for

31.

What does a sorting algorithm do?

a)

Finds an item of data in a set of data

b)

Saves a set of data

c)

Puts a list of items into order

32.

Which of the following is not a sorting algorithm?

a)

Bubble Sort

b)

Long Sort

c)

Insertion Sort

33.

What does a bubble sort do?

a)

Sorts a list by comparing two items that are side by side, to see which is out of order

b)

Separates a list of data into different collections of data, before sorting and gathering back into a list

c)

Finds an item of data in a list

34.

How many passes will a bubble sort go through?

a)

Only one pass

b)

Two passes

c)

Several passe - until the data is fully ordered

35.

Why does a bubble sort do a final pass even when the data is in the correct order?

a)

To save the data

b)

It does not recognise that the data is in order until the final pass requires no changes

c)

It needs to do this to put the data back in to a list

36.

Which of the following is an advantage of a bubble sort?

a)

It is a very small and simple computer program

b)

It takes a very long time to run

c)

It is very quick

37.

Which of the following is NOT an advantage of a bubble sort?

a)

It is a very small and simple computer program

b)

There is only one task to perform

c)

It is very quick

38.

What does an insertion sort do?

a)

Separates a list of data into different collections of data which are sorted and gathered back into a list

b)

Goes through a list of data a number of times and compares two items that are side by side to each other to see which is out of order

c)

Goes through a list, comparing two items that are side by side, and continues to move one value until it is in the correct place.

39.

Which of the following is an advantage of a insertion sort when compared with a bubble sort?

a)

It is quicker than a bubble sort algorithm

b)

It is simpler than a bubble sort algorithm

c)

There is no advantage.

40.

How many passes will an insertion sort go through?

a)

Only one pass

b)

Two passes

c)

Several passes - until the data is fully ordered

41.

Breadth First Search is equivalent to which of the traversal in the Binary Trees?

a)

Pre-order Traversal

b)

Post-order Traversal

c)

Level-order Traversal

d)

In-order Traversal

42.

Time Complexity of Breadth First Search is? (V – number of vertices, E – number of edges)

a)

O(V + E)

b)

O(V)

c)

O(E)

d)

O(V*E)

43.

The Data structure used in standard implementation of Breadth First Search is?

a)

Stack

b)

b) Queue

c)

c) Linked List

d)

d) Tree

44.

The Breadth First Search traversal of a graph will result into?

a)

Linked List

b)

Tree

c)

Graph with back edges

d)

Arrays

45.

A person wants to visit some places. He starts from a vertex and then wants to visit every place connected to this vertex and so on. What algorithm he should use?

a)

Depth First Search

b)

Breadth First Search

c)

Trim’s algorithm

d)

Kruskal’s algorithm

46.

Which of the following is not an application of Breadth First Search?

a)

Finding shortest path between two nodes

b)

Finding bipartiteness of a graph

c)

GPS navigation system

d)

Path Finding

47.

When the Breadth First Search of a graph is unique?

a)

When the graph is a Binary Tree

b)

When the graph is a Linked List

c)

When the graph is a n-ary Tree

d)

When the graph is a Ternary Tree

48.

Regarding implementation of Breadth First Search using queues, what is the maximum distance between two nodes present in the queue? (considering each edge length 1)

a)

Can be anything

b)

0

c)

At most 1

d)

Insufficient Information

49.

In BFS, how many times a node is visited?

a)

Once

b)

Twice

c)

Equivalent to number of indegree of the node

d)

Thrice

50.

Depth First Search is equivalent to which of the traversal in the Binary Trees?

a)

Pre-order Traversal

b)

Post-order Traversal

c)

Level-order Traversal

d)

In-order Traversal

51.

Time Complexity of DFS is? (V – number of vertices, E – number of edges)

a)

O(V + E)

b)

O(V)

c)

O(E)

d)

O(V*E)

52.

The Data structure used in standard implementation of Breadth First Search is?

a)

Stack

b)

Queue

c)

Linked List

d)

Tree

53.

The Depth First Search traversal of a graph will result into?

a)

Linked List

b)

Tree

c)

Graph with back edges

d)

Array

54.

A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use?

a)

Depth First Search

b)

Breadth First Search

c)

Trim’s algorithm

d)

Kruskal’s Algorithm

55.

Which of the following is not an application of Depth First Search?

a)

For generating topological sort of a graph

b)

For generating Strongly Connected Components of a directed graph

c)

Detecting cycles in the graph

d)

Peer to Peer Networks

56.

When the Depth First Search of a graph is unique?

a)

When the graph is a Binary Tree

b)

When the graph is a Linked List

c)

When the graph is a n-ary Tree

d)

When the graph is a n-ary Tree

57.

Regarding implementation of Depth First Search using stacks, what is the maximum distance between two nodes present in the stack? (considering each edge length 1)

a)

Can be anything

b)

0

c)

At most 1

d)

Insufficient Information

58.

In Depth First Search, how many times a node is visited?

a)

Once

b)

Twice

c)

Equivalent to number of indegree of the node

d)

Thrice

59.

Traversal of a graph is different from tree because

a)

There can be a loop in graph so we must maintain a visited flag for every vertex

b)

DFS of a graph uses stack, but inorrder traversal of a tree is recursive

c)

BFS of a graph uses queue, but a time efficient BFS of a tree is recursive.

d)

All of the above

60.

Which of the following algorithms can be used to most efficiently determine the presence of a cycle in a given graph ?

a)

Depth First Search

b)

Breadth First Search

c)

Prim’s Minimum Spanning Tree Algorithm

d)

Kruskal’ Minimum Spanning Tree Algorithm