wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Data Structures and Algorithms Quiz

Total questions: 137

Worksheet time: 1hrs 9mins

Name
Class
Date
1.

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

a)

Either binary search or a linear search

b)

A binary search

c)

A linear search

d)

Neither binary search nor a linear search

2.

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

a)

14

b)

36

c)

49

d)

7

3.

Given the sequential representation of the binary tree T (a one-dimensional array is used to store the elements of the tree T) and the root node of the tree T is the node 35): Show the sequence of nodes in the tree T that will be visited using post-order traversal algorithm:

a)

22, 45, 25, 47, 32, 40, 42, 56, 23, 30, 35

b)

22, 32, 45, 25, 47, 40, 42, 56, 23, 30, 35

c)

22, 23, 45, 25, 47, 32, 40, 42, 56, 30, 35

d)

22, 25, 45, 47, 32, 40, 42, 56, 23, 30, 35

4.

What is the output of the following list operation? aList = [10, 20, 30. 40, 50, 60, 70, 80] print(aList[2:5])

a)

[30, 40, 50]

b)

[20, 30, 40, 50]

c)

[30, 40, 50, 60]

d)

[20, 30, 40]

5.

Which of the following is the longest proper prefix which is also the suffix of 'ABCA'?

a)

"AB"

b)

"ABC"

c)

“ABCA”

d)

"A"

6.

What will be the output of the following code? def f(n): if (n<10): return n- 5 return f(n+1); print(f(4))

a)

1

b)

-1

c)

0

d)

5

7.

The total number of edges that connect to node u is called

a)

Degree

b)

Out-degree

c)

In-degree

d)

Order

8.

What does the following code do?
def Operation(self, newdata):

NewNode = Node(newdata)

if self.head is None:

self.head NewNode

return

laste = self.head

while(laste.next):

laste laste.next

laste.next=NewNode

a)

Insert a new node at the beginning of the list

b)

Remove the last node

c)

Traverse the list

d)

Insert a new node at the tail of the list

9.

According to Stack data structure, what is output for input "finaltest"?

a)

tsetlanif

b)

final

c)

test

d)

final test

10.

Given a string S = "ABCDEFABCD" and a pattern P = "BC" What is the return value when applying the KMP algorithm? (the string is indexed from 0)

a)

2, 8

b)

1

c)

0

d)

1, 7

11.

Given data compression rate is 0.25 and length of input data is 8. What is the length of output data?

a)

6

b)

0

c)

8

d)

4

12.

Which is the most appropriate definition for recursion?

a)

An in-built method that is automatically called.

b)

A class method that calls another class method.

c)

A function that calls another execution instance of the same function

d)

A function that calls another function

13.

Given an empty queue Q, what does it look like after the following operations?

Q.enqueue(1)

Q.enqueue(2)

Q.dequeue()

Q.enqueue(3)

Q.dequeue()

a)

1 2 3

b)

empty

c)

3

d)

2 3

14.

What is the hash function used in the division method?

a)

h(k) = m mod k

b)

h(k) = k/m

c)

h(k) = m/k

d)

h(k) = k mod m

15.

For the given hash table with size 100 and folding method is used, in what location will the key 2844267 be hashed using probing?

a)

5

b)

67

c)

105

d)

7

16.

The complexity of the binary search algorithm is

a)

O(n*n)

b)

O(log n).

c)

O(n* log n).

d)

O(n)

17.

A graph in which exists a path between any two nodes is called

a)

Digraph

b)

Complete graph

c)

In-directed graph

d)

Connected graph

18.

Suppose a singly linked list of integers is given below:

head ->1-2-3->4->5->None

What will be the output of the following code?

def listprint(self):

printval = self.head

while printval.next is not None:

print (printval.data) printval = printval.next

a)

5 4 3 2 1

b)

1 2 3 4

c)

2 3 4 5

d)

1 2 3 4 5

19.

Following function is used to calculate the factorial number of n. What is the missing line?

def fact(num):

if num == 0:

return 1

else:

return____

a)

num* fact(num - 1)

b)

fact(num)* fact(num - 1}

c)

num*fact(num + 1)

d)

num (num - 1)

20.

What is the result of Post-order traversal of the binary search tree below

a)

7 2 12 10 20 35 50 25 15

b)

15 10 2 7 12 25 50 20 35

c)

7 2 12 20 10 35 50 25 15

d)

15 10 2 7 12 25 20 50 35

21.

Given the sequential representation of the binary tree T (a one-dimensional array is used to store the elements of the tree T) and the root node of the tree T is the node 15): The ancestors of the node 30 are:

a)

15, 20, 12

b)

15, 20, 10

c)

15, 10, 12

d)

15, 20, 25

22.

Which sorting algorithm is the best if the list is already in order?

a)

Quick Sort

b)

Merge Sort

c)

Selection Sort

d)

Insertion Sort

23.

Given a binary search tree as follows What would be the value of root after deleting key 50?

a)

100 or 5

b)

35 or 65

c)

75 or 25

d)

30 or 72

24.

Give a binary tree as belows: The leaves of tree are:

a)

E F G H

b)

G H

c)

G H F

d)

B G H

25.

What does the following function do def Func(self, root): if root: self.Func (root.left) print(root.data) self.Func (root.right)

a)

Traverse the tree in BFT

b)

Traverse the tree in Pre-order

c)

Traverse the tree in In-order

d)

Traverse the tree in DFT

26.

Given a graph in the figure. the breadth-first traversal from node A is:

a)

ABCGEFD

b)

ABFCEDG

c)

ACEBDFG

d)

ABCEDFG

27.

A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a?

a)

Tree

b)

Linked list

c)

Stack

d)

Queue

28.

What will be the output of the following code? a=[1, 2, 3, 4, 5] b=a[2:4] print(b)

a)

[3, 4, 5]

b)

[2, 3, 4]

c)

[2,4]

d)

[3, 4]

29.

In a hash table, an element with key k is stored at index

a)

H(k)

b)

k

c)

Log k

d)

k*k

30.

Given an empty Stack S and a sequence of the following operations: Push(F); Push(P); Pop(S); Push(T); Pop(S); Push(U); What does the stack S look like?

a)

TU

b)

FPTU

c)

FP

d)

FU

31.

Recursion calls are stored on the memory in which data structure?

a)

Queue

b)

Stack

c)

Heap

d)

Tree

32.

A sorting algorithm that uses the divide and conquer technique is?

a)

Bubble sort

b)

Selection sort

c)

Insertion sort

d)

Quick sort

33.

In a stack we can add and remove an element?

a)

at/from any position

b)

at/from middle position

c)

at/from many positions

d)

only at/from one position

34.

Which of the following algorithms does not divide the list?

a)

Merge Sort

b)

Binary search

c)

Linear search

d)

Quick Sort

35.

What is the result of Pre-order traversal of the binary search tree below

a)

15 10 2 12 7 25 20 50 35

b)

72 12 20 10 35 50 25 15

c)

15 10 2 12 25 7 20 50 35

d)

15 10 2 7 12 25 20 50 35

36.

Given a hash table T with 20 slots that stores 1000 elements, the load factor a for T is

a)

20

b)

1000

c)

50

d)

0.02

37.

Linear search is highly inefficient compared to binary search when dealing with:

a)

large and sorted arrays

b)

large and unsorted arrays

c)

small and unsorted arrays

d)

unsorted arrays

38.

What will be the output of the following code? b=[1] *5 print(b)

a)

0

b)

[1, 1, 1, 1, 1]

c)

Error

d)

5

39.

What is the output of the following program? a=[1,2,3,4,5] a[0]=6; print(len(a))

a)

5

b)

1

c)

6

d)

0

40.

Given a graph in the figure, the adjacency matrix of the graph is (visit nodes in ABCD order):

a)

[[0, 2, 0, 0], [0, 0, 7, 0], [0, 0, 0, 0], [0, 4, 8, 0]]

b)

[[0,1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0], [0, 1, 1, 0]]

c)

[[0, 2, 0, 9], [0, 0, 7, 4], [0, 7, 0, 8], [9, 4, 8, 0]]

d)

[[0, 1, 0, 1], [1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]]

41.

What is the output of the following code? my_list = ["Hello", "Python"] print("-".join(my_list))

a)

HelloPython-

b)

Hello-Python

c)

-HelloPython

d)

HelloPython

42.

What is a hash table?

a)

A structure used for storage

b)

A structure that maps values to keys

c)

A structure that maps keys to values

d)

A structure used to implement stack and queue

43.

Using Huffman coding to fill missed data into the following table:

a)

A: 01411, B: 000, C: 0110, D: 0011, E: 0010, F: 010, G: 01110, H: 1

b)

A: 1, B: 01110, C 0110, D: 0011, E: 0010, F: 010, G: 000, H 1

c)

A: 1, B: 01110, C: 0110, D: 0011, E: 0010, F 010, G: 000, H: 01111

d)

A:01111, B: 01110, C: 0110, D: 0011, E: 0010, F: 010. G: 000. H: 1

44.

What is the MAXIMUM number of nodes in a binary search tree with height =3?

a)

7

b)

15

c)

8

d)

16

45.

What will be the output of the following code? def fun(i, j): if (i == 0): retum j else: return fun(i-1,j+1) print(fun(4,8))

a)

16

b)

8

c)

12

d)

4

46.

Given an array A = {6, 7, 4, 1, 2, 9} and Quick Sort is used to sort the array A in increasing order. What is the sequence after pass 2?

a)

467129

b)

146729

c)

674129

d)

124769

47.

What method is used to remove an element from a Queue?

a)

dequeue()

b)

enqueue()

c)

push()

d)

pop()

48.

A sorted array contains 16 items. Using binary search, the maximum number of comparisons to search for an item in this array is

a)

5

b)

4

c)

3

d)

None of above

49.

Which graph in discrete mathematics has a path of edges between every pair of vertices in the graph?

a)

A bipartite graph

b)

A connected graph

c)

A disconnected graph

d)

A directed graph

50.

What is the output of post-order traversal?

a)

abc+*+defg*+*

b)

a+b*c+de+f*g

c)

abc*+de*f+g*+

d)

++a*b*+*defg

51.

In which of the following hash functions, do consecutive keys map to consecutive hash values?

a)

Folding method

b)

Multiplication method

c)

Mid-square method

d)

Division method

52.

The following sorting algorithms maintain two sub-lists. one sorted and one to be sorted?

a)

Quick Sort

b)

Selection Sort

c)

None of these

d)

Merge Sort

53.

Given the sequential representation of the binary tree T (a one-dimensional array is used to store the elements of the tree T) and the root node of the tree T is the node 15 (picture below).

Show all the leaf nodes of the tree T:

a)

5, 12, 7, 19, 2, 4

b)

12, 19, 4

c)

7, 19, 2, 4

d)

12, 7, 19, 2, 4

54.

Given a graph in the figure, the depth first traversal from node B is (visit nodes in ABCDE order):

a)

BAEDC

b)

BCDEA

c)

BACDE

d)

BADCE

55.

Which of the following statement is false?

a)

Infinite recursion can occur if the base case is not properly defined

b)

Every recursive function must have a return value.

c)

A recursive function makes the code easier to understand.

d)

Every recursive function must have a base case

56.

Given 4 graph in the figure, the adjacency matrix of the graph to:

a)

[[0, 2, 0, 9, 4], [1, 0, 1, 0,0], [0, 1, 0, 1, 0], [9, 0, 8, 0, 5], [4, 0, 0, 5, 0]]

b)

[[0, 2, 0, 1, 4], [1, 0, 1, 0,0], [0, 7, 0, 8, 5], [9, 0, 8, 0, 5], [4, 0, 0, 5, 0]]

c)

[[0, 1, 0, 1, 1], [1, 0, 1, 0,0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [1, 0, 0, 1, 0]]

d)

[[1, 0, 1, 0, 0], [0, 1, 0, 1,1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 1, 1, 0, 1]]

57.

What is the shortest path from node A to node G?

a)

A-B-E-G

b)

A-B-C-E-G

c)

A-C-E-G

d)

A-G

58.

Which is the correct code to access data of the second node in a linked list?

a)

head.next.data

b)

head.next.next.data

c)

head.head.data

d)

head.data

59.

What is the best-case time complexity of the Linear search?

a)

O(1)

b)

O(n*n)

c)

O(nlogn)

d)

O(n)

60.

Given a list of 64 elements, how many elements will be checked to look for a value that is larger than the largest value in the list using binary search?

a)

8

b)

6

c)

7

d)

9

61.

What will be the output of the following code? def rec(n): if n > 5 return n else return n + rec(n+2) print(rec(1))

a)

5

b)

16

c)

1

d)

15

62.

List A is defined as follows: A= [1, 2,3, 4, 5] select all of the following statements that remove the middle element 3 from A so that it equals [1, 2, 4, 5]:

a)

A[2:2] = []

b)

A[2].remove()

c)

del A[2]

d)

A[2]=0

63.

The following circular queue can accommodate a maximum six elements with the following data front = 2, rear = 4 queue = ;L; M;N;__; What are the values of front and rear after the add O operation takes place? queue; L; M;N; 0;

a)

front 3, rear=5

b)

front 1, rear= 4

c)

front = 2, rear=5

d)

front = 3, rear =4

64.

Which of the following cases occurs when searching an array using linear search: the value to be searched is equal to the first element of the array?

a)

The best case

b)

The amortized case

c)

The average case

d)

The worst case

65.

The data structure required for Breadth First Traversal on a graph is?

a)

Stack

b)

Linked list

c)

Array

d)

Queue

66.

In Linked List implementation, a node carries information regarding

a)

Data and Link

b)

Node

c)

Link

d)

Data

67.

Given a graph in the figure. the breadth first traversal from node 1 in order of precedence ascending

a)

1432

b)

1423

c)

1342

d)

1324

68.

The following sorting algorithms maintain two sub-lists. one sorted and one to be sorted?

a)

Quick Sort

b)

Insertion Sort

c)

None of these

d)

Merge Sort

69.

Which of the following algorithms has a logarithmic runtime complexity?

a)

Binary search

b)

Linear search

c)

Merge Sort

d)

Selection Sort

70.

Given an undirected graph G with V vertices and E edges. the sum of the degrees of all vertices is

a)

V

b)

2V

c)

E

d)

2E

71.

A chained hash table has an array size of 255. What is the maximum number of elements the table?

a)

There is no limit

b)

2

c)

255

d)

256

72.

What is the best definition of a collision situation in a hash table?

a)

Two entries are identical except for their keys

b)

Two entries with different data have the exact same key.

c)

Two entries with different keys have the same exact hash value.

d)

Two entries with the exact same key have different hash values

73.

List is defined as follows

A= [a', 'b','c']

Which of the following statements adds 'd' and 'e' to the end of A, so that it then equ["a','b', 'c', 'd', 'e']

a)

A.extend(['d', 'e'])

b)

A.append(['d', 'e'])

c)

A[-1] = [d', 'e]

d)

A.append('d', 'e')

74.

Two algorithms, used for finding a Minimum spanning tree, are Kruskal and Dijkstra. Which algorithm uses the Cycle detection method?

a)

The Kruskal algorithm

b)

Bellman Ford algorithm

c)

Huffman algorithm

d)

Conquer algorithm

e)

The Dijkstra algorithm.

75.

What is the output of the following program? a= [5, 4, 7, 2, 9] print(a.index(4))

a)

0

b)

1

c)

2

d)

9

76.

A sequence of the following operations.

Enqueue(15)

ENQUeUe(25)

Enqueue(25)

Dequeue():

Dequeue()

The value of the front element

a)

0

b)

5

c)

15

d)

25

77.

Suppose the frequencies of characters is given by: A[10%], B[20%], C[70%] We want to improve the average length of the codeword by applying the Huffman algorithm to pairs of letters instead of single letters. What is the Huffman code of AB?

a)

0010

b)

001

c)

0110

d)

01

78.

A hash function h defined h (key) = key mod 5, with Quadratic probing , is used to insert the keys 1, 10, 11, 12 into a table index from 0 to 4. What will be the location of key 12?

a)

4

b)

3

c)

0

d)

1

79.

What is direct addressing?

a)

Distinct array position for every possible key

b)

Fewer array positions than keys

c)

Fewer keys than array positions

d)

Same array position for all keys

80.

What is the output of the following list assignment? aList[4, 8, 12, 16] aList[1: 4] = [20, 24, 28] print(aList)

a)

[4, 20. 24, 28. 8. 12. 16]

b)

[4. 20. 24, 28]

c)

[4, 8, 12, 16]

d)

[20, 24, 28]

81.

What will be the output of the following code?

def fact(n):

if n == 0:

return "good"

return fact(n-4)

else:

print(fact((16))

a)

good good good good

b)

good

c)

16

d)

4

82.

What is the value of the shift Folding Hash Function if K = 723-203-541-213-24 and table size = 1000?

a)

704

b)

24

c)

723

d)

1704

83.

Which of these is false about recursion?

a)

Clean code

b)

Takes less memory

c)

Takes more memory

d)

A Complex task is broke

84.

What is the number of swappings needed to sort the numbers 8, 22, 7, 9, 31 in ascending order using bubble sort?

a)

2

b)

3

c)

4

d)

5

85.

Given an array A = {6, 7, 4, 1, 2, 9} and Quick sort is used to sort the array A in increasing order. What is the sequence after the first phase, the pivot is 4?

a)

674129

b)

214769

c)

124769

d)

124679

86.

What is tail recursion?

a)

A recursive function that has two base cases

b)

A function where the recursive functions leads to an infinite loop

c)

A recursive function where the function doesn't return anything and just prints the values

d)

A function where the recursive call is the last thing executed by the function

87.

Which of these is not true about recursion?

a)

Making the code look clean

b)

A complex task can be broken into sub-problems

c)

Recursive calls take up less memory

d)

Sequence generation is easier than a nested iteration

88.

What will be the output of the following code?

S.append(1)

S.append(2)

S.append(3)

print(S.peak())

a)

[1,2,3]

b)

1

c)

3

d)

Error

89.

The complexity of Linear search algorithm is

a)

O(n)

b)

O(log n)

c)

O(n^2)

d)

O(n log n)

90.

Suppose a singly linked list of integers is given below:

head ->1->2->3->4->5->None

What will be the output of the following code?

def listprint(self):

printval = self.head

print (printval.data)

printval = printval.next

a)

12345

b)

2345

c)

1234

d)

54321

91.

What would be the contents of an empty stack S1 after the following operations are executed (visit from bottom to top)?

S1.push(3);

S1.push(5);

S1.push(9);

S1.pop();

S1.push(11);

a)

3 5 9 11

b)

5 9 11

c)

369

d)

3 5 11

92.

An advantage of chained hash table (external hashing) over the open addressing scheme is

a)

Worst case complexity of search operations is less

b)

Space used is less

c)

Deletion is easier

d)

None of these

93.

Given a binary search tree as follows: What is the output of In-order traversal?

a)

10 20 30 40 50

b)

50 40 20 30 10

c)

40 20 50 10 30

d)

40 20 50 30 10

94.

Assume that Binary Trees T is represented as Array-Based Representation (root is stored at index 1) and a node X is stored at index 3. What is position of the left child of X?

a)

3

b)

5

c)

6

d)

7

95.

The concept of prefix and suffix is used in which of the following algorithms?

a)

KMP

b)

Boyer-Moore

c)

Brute Force

d)

Advanced Brute Force

96.

What will be the output of the following code?

def rec(n):

if (n <= 2):

return n

else:

return rec(n-2) + rec(n-1)

print(rec(4))

a)

5

b)

4

c)

0

d)

Error

97.

What is degree of vertex V?

a)

0

b)

5

c)

4

d)

3

98.

What will be the output of the following code?

from collections import deque

S = deque()

S.append(1)

S.append(2)

S.pop()

S.append(3)

S.pop()

print(S)

a)

deque([1])

b)

deque([1, 2, 3])

c)

3

d)

1

99.

What is disadvantage of Recursion?

a)

Recursive calls are expensive (inefficient) as they take up a lot of memory and time

b)

Sequence generation is more difficult with recursion than using some nested iteration

c)

A complex task can not be broken down into simpler sub-problems using recursion

d)

None of these

100.

Given an array A = {6, 7, 3, 4, 1, 2, 9} and Quick Sort is used to sort the array A in increasing order with pivot value 4. What is the array like after the first round?

a)

6, 7, 3, 4, 1, 2, 9

b)

2, 1, 3, 4, 7, 6, 9

c)

1, 2, 3, 4, 7, 6, 9

d)

1, 2, 3, 4, 6, 7, 9

101.

Given a graph in the figure. the depth first traversal from node D is (visit nodes in ABC order):

a)

D, C, B, A, E

b)

D, C, E, A, B

c)

D, A, B, C, E

d)

D, E, A, B, C

102.

Which sorting technique will be most appropriate to sort 1 GB of data with only 100 MB of available main memory?

a)

Insertion sort

b)

Heap sort

c)

Merge sort

d)

Quick sort

103.

Which of the following algorithms use recursion for sorting an array of integers?

a)

Bubble sort and Insertion sort

b)

Bubble sort and Quicksort

c)

Bubble sort and merge sort

d)

Quicksort and merge sort

104.

Which of these is false about recursion?

a)

Recursive function can be replaced by a non-recursive function

b)

Recursive functions usually take more memory space than non-recursive function

c)

Recursive functions run faster than non-recursive function

d)

Recursion makes programs easier to understand

105.

In a hash table, what is called if two different keys are hashed to the same location?

a)

Collision

b)

Addressing

c)

Hashing

d)

Probing

106.

What is the output of the following program? A=[1, 2, 3, 4, 5] A.pop(1) print (A)

a)

1

b)

[1, 3, 4, 5]

c)

[2, 3, 4, 5]

d)

[1, 2, 3, 4, 5]

107.

Given a definition as follows: "a recursive function in which the first statement is a recursive call and then the other operations are performed" What is this?

a)

Tail-Recursion

b)

Non Tail-Recursion

c)

Recursion

d)

None of these

108.

Given a graph in the figure. the weighted matrix of the graph is (visit nodes in ABC order)

a)

[[0, 5, 0, 40], [0, 0, 10, 0], [0, 10, 0, 10], [0, 0, 0, 0]]

b)

[[0, 1, 0, 0], [0, 0, 10, 9], [0, 1, 1, 0], [0, 0, 0, 0]]

c)

[[0, 1, 0, 1], [1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]]

d)

[[0, 1, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0]]

109.

Given a string S = "1234512345" and a pattern P = "123". What is brute-force algorithm returns? (the string is indexed from 0)

a)

0

b)

1

c)

5

d)

0, 5

110.

A hash function h defined h(key)= key mod 5, linear probing is used to insert sequentially the keys 24,16, 36 into a hash table indexed from 0 to 4. What will the location of the key 36 be?

a)

0

b)

1

c)

2

d)

3

111.

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

a)

n/2

b)

n*n

c)

n

d)

log(n)

112.

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: (REAR+1) mod n == FRONT, empty: REAR == FRONT

113.

Given a graph in the figure. the weighted matrix of the graph is (visit nodes in ABC order)

a)

[[0, 2, 0, 9], [0, 0, 7, 0], [0, 0 0, 0], [0, 0, 8, 0]]

b)

[[0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0], [0, 0, 1, 0]]

c)

[[0, 1, 0, 1], [1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]]

d)

[[0, 2, 0, 0], [0, 0, 7, 0], [0, 0, 0, 0], [0, 4, 8, 0]]

114.

The number of elements in the weighted matrix of a graph having 5 vertices is?

a)

5

b)

16

c)

25

d)

36

115.

Given a binary search tree as follows: What are the Internal nodes?

a)

40

b)

25, 35, 45, 60

c)

30, 50

d)

30, 40, 50

116.

Which of these is not true about recursion?

a)

It's easier to code some real-world problems using recursion than non-recursive equivalent

b)

Recursive functions are easy to debug

c)

Recursive calls take up a lot of memory

d)

Programs using recursion take longer time than their non-recursive equivalent

117.

You are given pointers to the first node of a singly linked list, which of the following operations are dependent on the length of the linked list?

a)

Delete the first element

b)

Insert a new element as a first element

c)

Add a new element at the end of the list

d)

None of these

e)

Deleting the last element

118.

Given an array as follows: [4, 1, 2, 9, 8]. How is the array like after the first round of Bubble sort?

a)

4, 1, 2, 9, 8

b)

1, 2, 4, 8, 9

c)

1, 4, 2, 8, 9

d)

1, 4, 2, 9, 8

119.

Given an array as follows: [4, 1, 2, 9, 8]. How is the array like after the first round of Bubble sort?

a)

4, 1,2, 9, 8

b)

1, 2, 4, 8, 9

c)

1, 4, 2, 8, 9

d)

1, 4, 2, 9, 8

120.

Given a binary search tree as follows: What would be the output of Pre-order traversal?

a)

25, 30, 35, 40, 45, 50, 60

b)

40, 30, 25, 35, 50, 45, 60

c)

40, 30, 50, 25, 35, 45, 60

d)

25, 35, 30, 45, 60, 50, 40

121.

What is the search complexity in direct addressing?

a)

O(n)

b)

O(logn)

c)

O(nlogn)

d)

O(1)

122.

A map/dictionary is created and the following key-value pairs are added in the following order: {"a": 2}, {"b": 3}, {"a", 4}, {"c", 5}. What is the value associated with the key "a"?

a)

2

b)

3

c)

4

d)

There's an error

123.

What will be the output of the following code?

S=[]

for i in range(1,5):

if (i%2!= 1):

S.append(i)

while (len(S) > 0):

print(S.pop(0))

a)

1 3

b)

2 4

c)

3 1

d)

4 2

124.

Given an array A = {3, 7, 6. 9, 1} how to A like after the first phase of selection sort in ascending order?

a)

3, 7, 6, 9, 1

b)

1, 3, 7, 6, 9

c)

1, 7, 6, 9, 3

d)

9, 3, 7, 6, 9

125.

What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?

a)

O(n/2)

b)

O(log(n))

c)

O(n*n)

d)

O(n)

126.

Which is the correct code to access data of node p in a linked list?

a)

p.data

b)

p.next

c)

p.next.data

d)

head.p.data

127.

What will be the output of the following code?

S=[]

S.append(1)

S.append(2)

S.append(3)

S.pop()

print(S)

a)

[1, 2, 3]

b)

[1, 2]

c)

1

d)

3

128.

Given an array as follows: [4, 2, 5, 8, 6] and a search key x using linear search? The Best case of searching occurs when value of x is

a)

2

b)

4

c)

6

d)

None of these

129.

The data structure required for Depth First Traversal on a graph is?

a)

Stack

b)

Linked list

c)

Array

d)

Queue

130.

How many passes are required for sorting 8 elements list using bubble sort?

a)

8

b)

7

c)

9

d)

6

131.

What is a hash function?

a)

A function has allocated memory to keys

b)

A function that computes the location of the key in the array

c)

A function that creates an array

d)

A function that computes the location of the values in the array

132.

The order of an internal node in a B+ tree index is the maximum number of children it can have. Suppose that a child pointer takes 6 bytes, the search field value takes 14 bytes, and the block size is 512 bytes. What is the order of the internal node?

a)

24

b)

25

c)

26

d)

27

133.

Given a hash table T with 25 slots that stores 2000 elements, the load factor a for T is

a)

80

b)

0.0125

c)

8000

d)

1.25

134.

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 Q from the list?

a)

O(n)

b)

O(logn)

c)

O(1)

d)

O(n*n)

135.

B+ Trees are considered BALANCED because

a)

the lengths of the paths from the root to all leaf nodes are all equal.

b)

the lengths of the paths from the root to all leaf nodes differ from each other by at most 1.

c)

the number of children of any two non-leaf sibling nodes differ by at most 1.

d)

the number of records in any two leaf nodes differ by at most 1.

136.

The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?

a)

2

b)

3

c)

4

d)

6

137.

The postorder traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The inorder traversal of the same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is was Numerical Type question. Note -This

a)

2

b)

3

c)

4

d)

5