DS........

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

1. Which of the following is a sparse matrix?

Please choose a correct answer.

a. 1 1 1 0

0010

1100

b. 1 1 1 0

0011

1100

c. 4 5 3 0

0060

7600

d. 4 0 3 0

0060

7600

Ans:- d. 4 0 3 0

0060

7600

------------------------------------------------------------------------------------------------------------------------------------

2. A self-adjusting tree in which the element on which operation is performed becomes the root of
the tree

Please choose a correct answer

2-3 Tree

Red-Black Tree

Splay Tree

AVL Tree

Ans:- Splay Tree


------------------------------------------------------------------------------------------------------------------------------------
3. A B tree that stores data on leaf nodes and keys in internal nodes is known

Please choose a correct answer.

B-Tree

B+ Tree

AB+ Tree

A- Tree

Ans:- B+ Tree

------------------------------------------------------------------------------------------------------------------------------------

4. When two keys result in having the same hash value, the condition is called

Please choose a correct answer.

Collapsing

Collision

Chaining

Matching

Ans:- Collision

------------------------------------------------------------------------------------------------------------------------------------

5. Consider the following sorting algorithm.

procedure xSort(var a as array)

if (n == 1) return a

var l1 as array = a[0] ... a[n/2]

var l2 as array = a[n/2+1] ... a[n]

l1 =xSort( l1 )

l2= xSort( l2 )

return mergeArrays( l1, l2)

end procedure

Predict the name of the sorting algorithm from the following option….Please choose a correct
answer.

Quick sort

Merge sort
Selection sort

Radix sort Ans:- Merge Sort


------------------------------------------------------------------------------------------------------------------------------------

6. Which of the following is not a self-balancing tree?

Please choose a correct answer.

Red-black trees

AVL Trees

2-3 Trees

None of the above

Ans:- None of the above

------------------------------------------------------------------------------------------------------------------------------------

7. The least Time Complexity of removing the duplicates from the unsorted linked list is

Please choose a correct answer

O(n^3)

O(n^2)

O(n)

None

Ans:- O(n)

------------------------------------------------------------------------------------------------------------------------------------

8. There are two data structures, one an array and another a singly linked list. Both stores same set
of elements. Let A indicate time taken to search in an array and B indicate to search in a Inked list

Which of the following is true on a typical modern computer

Please choose a correct answer.

A>B

A<B

A=B

Can't Predict

Ans:- A<B

------------------------------------------------------------------------------------------------------------------------------------

9. Fill in the blank with the most appropriate option:

Jack was given two non-negative functions f1 and f2. The function f1 (n) =O(f2(n)) if and only
if there exist a positive constant K and no such that? Please choose a correct answer.

a) f1(n) ≤ K*f2 (n)


b) f1(n) = K*f2(n)

c) f1(n) ≥ K*f2(n)

d) f1(n) 1 = K*f2(n)

Ans:- a) f1(n) ≤ K*f2 (n)

------------------------------------------------------------------------------------------------------------------------------------

10. Fill in the blank with the most appropriate option:

Jack was given two non-negative functions f1 and f2. The function f1 (n) =O(f2(n)) if and only

if there exist a positive constant K and no such that?

Please choose a correct answer.

a) f1(n) ≤ K*f2 (n)

b) f1(n) = K*f2(n)

c) f1(n) ≥ K*f2(n)

d) f1(n) 1 = K*f2(n)

Answer : a) f1(n) ≤ K*f2 (n)

------------------------------------------------------------------------------------------------------------------------------------

11. Sam has a problem K. The problem K is NP-complete if K is NP-hard. Which of the

following conditions satisfy this?

Please choose a correct answer.

a) K:NP

b) K directly proportional to NP

c) KENP

d) K=NP

Answer : d) K=NP

------------------------------------------------------------------------------------------------------------------------------------

12. A hash table has 12 buckets and uses linear probing to insert values. The hash function is

K mod 8 and the key values are combined. The elements 11, 17, 14, 21, 31, 28, 51, 18 were

inserted into the hash table in that order, which location holds the 18.

a) 1

b) 4

c) 7

d) 2 Answer : 2
------------------------------------------------------------------------------------------------------------------------------------

13. Consider the following sorting algorithm.

procedure ( Sort var a as array )

if (n = - 1) return a

Var 11

as

array - a[0] ... a[n/2]

var 12

as array = a[n/241] ... a[n]

Sort( 11 )

Sort( 12 )

return mergeArrays ( 11, 12 )

end procedure

Predict the name of the sorting algorithm from the following options.

Answer : Merge Sort Algorithm

------------------------------------------------------------------------------------------------------------------------------------

14. Thomas has written an algorithm to sort an array. The algorithm is given below. Help

Thomas to get the running time required for this algorithm.

Choose from the following options:

list: array of items

n: size of list

for i = 1 to n - 1

min = 1 for j = 1+1 to n if list[j] ‹ list[min] then min - 33

end if end for

if indexMin 1 = i then swap list[min] and 1ist[1] end if end for

end procedure

a) O( log2 n) (logbase2)

b) O( n 10g2 n) (logbase2)

c) O(n)

d) O(n^2)

Answer : d) O(n^2)
------------------------------------------------------------------------------------------------------------------------------------

15. what will be the outcome of the below algorithm:

1. Begin from the first element, then perform a comparison with the following

element in the array.

2. If the present element is larger than the following element of the array, then

swap their positions.

3. If the present element is lesser than the following element of the array, shift

to the next element, and again repeat step 1.

Searching a particular

a) Reversing the given list

b) Sorting the list of given numbers

c) Addition of first N Numbers

d) searching a particular

Answer: b) Sorting the list of given numbers

------------------------------------------------------------------------------------------------------------------------------------

16. What is the complexity of a binary search algorithm?

a) O(log n).

b) O(n log n)

c) O(n)

d) O(n^2)

Answer: a) O(log n)

------------------------------------------------------------------------------------------------------------------------------------

17. In linear search algorithm, the worst case manifests in which of the following

situations?

a) When item is the last element in the array

b) When item is the last element in the array or When item is not in the array

at all

c) None of the given options

Answer: b) When item is the last element in the array or When item is not in

the array at all

------------------------------------------------------------------------------------------------------------------------------------
18. Which of the following solutions would you get when you apply Prim's

algorithm on a graph?

a) Traveling salesman problem

b) Graph coloring problem

c) Transitive closure of a graph

d) Minimum cost spanning tree

Answer: d) Minimum cost spanning tree

------------------------------------------------------------------------------------------------------------------------------------

19. As a schedular, Operating System has to schedule different jobs that are

coming for processing. OS has to refine the precedence of each job for

scheduling. Which queue is used for storing and scheduling these jobs?

a) Linear Queue

b) Circular Queue

c) Dequeue

d) Priority Queue

Answer: d) Priority Queue

------------------------------------------------------------------------------------------------------------------------------------

20. you want to store the following data of N students and porform the

operations like searching and sorting Which of the following you will use for

the same?

Answer: Array of Structures.

------------------------------------------------------------------------------------------------------------------------------------

21. Which of the following solutions would you get when you apply Prim's

algorithm on a graph?

Answer: Minimum Spanning Tree (MST)

------------------------------------------------------------------------------------------------------------------------------------

22. 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 Answer: d) All of the above


------------------------------------------------------------------------------------------------------------------------------------

23. 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

Answer: d) All of the above

------------------------------------------------------------------------------------------------------------------------------------

24. Which of the following sorting algorithms can be used to sort a random

linked list with minimum time complexity?

a) Insertion Sort

b) Quick Sort

c) Heap Sort

d) Merge Sort

Answer: d) Merge Sort

------------------------------------------------------------------------------------------------------------------------------------

25. Which of the following is true about linked list implementation of stack?

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

Answer: d) None of the above

------------------------------------------------------------------------------------------------------------------------------------

26. Which of the following is an advantage of adjacency list representation

over adjacency matrix representation of a graph?

a) In adjacency list representation, space is saved for sparse graphs.

b) DFS and BSF can be done in O(V+ E) time for adjacency list representation.

These operations take O(V^2) time in adjacency matrix representation. Here is


V and E are number of vertices and edges respectively.

c) Adding a vertex in adjacency list representation is easier than adjacency

matrix representation.

d) All of the above

Answer: d) All of the above

------------------------------------------------------------------------------------------------------------------------------------

27. Which of the following sorting algorithms follows the divide-and-conquer

approach?

a) Insertion sort

b) Bubble sort

c) Quick sort

d) None of the above

Answer: c) Quick sort

------------------------------------------------------------------------------------------------------------------------------------

28. A binary tree can be traversed in

a) Inorder

b) Preorder

c) Postorder

d) All of the above

Answer: d) All of the above

------------------------------------------------------------------------------------------------------------------------------------

29. Stack works on the principle of

a) Last In First Out

b) Last In First Out

c) First In Middle Out

d) None of the Above

Answer: a) Last in First Out

------------------------------------------------------------------------------------------------------------------------------------

30. When determining the efficiency of an algorithm, how would you measure

the space factor?

a) By counting the maximum memory needed by the algorithm


b) By counting the minimum memory owned by algorithm

c) By counting the average memory needed by the algorithm

d) By counting the maximum disk space made by the the algorithm

Answer: a) By counting the maximum memory needed by the algorithm

------------------------------------------------------------------------------------------------------------------------------------

31. What is the complexity of a bubble sort algorithm?

a) O(log n)

b) O(n log n)

c) O(n^2)

d) O(n)

Answer: c) O(n^2)

------------------------------------------------------------------------------------------------------------------------------------

32. You want to store n integer numbers inputed by the user and perform the

actions like searching and sorting on those numbers. Which of the following

you will use to store the data?

a) Structure

b) Union

c) Variable

d) Arrays

Answer: d) Arrays

------------------------------------------------------------------------------------------------------------------------------------

33. The common term used to adding data item to a stack.

a) Insert

b) Commit

c) Push

d) None of the above

Answer: c) push

------------------------------------------------------------------------------------------------------------------------------------

34. what an extra key inserted at the end of the array is called?

a) Transposition

b) Stop key
c) Sentinel

d) Not sure

Answer: c) Sentinel

------------------------------------------------------------------------------------------------------------------------------------

35. An intelligent thief thieving in a new place, where the houses were arranged like a binary tree.
The thief can only enter through the root. Apart from the root ,each house has only one parent
house.
The thief had to be careful about the burglar system installed there. It would automatically contact
the police if two directly linked houses were robbed on the same night. You are given the binary
tree. Find the maximum amount of money the thief can rob without altering the police.

a) 310

b)305

c)330

d)345

Ans:

You might also like