wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DAA IA2 Test 50 1 marks , 25 2 marks total 100

Total questions: 75

Worksheet time: 2hrs 38mins

Name
Class
Date
1.

You are running a library catalog. You know that the books in your collection are almost in sorted ascending order by title, with the exception of one book which is in the wrong place. You want the catalog to be completely sorted in ascending order.

a)

Insertion Sort

b)

Merge Sort

c)

Radix Sort

d)

Heap Sort

e)

Counting Sort

2.

Which of the following sorting methods would be most suitable for sorting a list which is almost sorted?

a)

Bubble Sort

b)

Insertion Sort

c)

Binary Sort

d)

Quick Sort

3.

What is the time complexity of the above recursive implementation used to reverse a string?

a)

O(1)

b)

O(n)

c)

O(n2)

d)

O(n3)

4.

How many recursive calls are there in Recursive matrix multiplication by Strassen’s Method?

a)

5

b)

7

c)

8

d)

4

5.

Which of the following statement is true about stack?

a)

Pop operation removes the top most

element

b)

Pop operation removes the bottom most

element

c)

Push operation adds new element at the

bottom

d)

Push operation removes the top most

element

6.

Which of the following is considered as the top of the stack in the linked list implementation of the stack?

a)

Last node

b)

First node

c)

Random node

d)

Middle node

7.

Which of the following is the biggest advantage of selection sort?

a)

It has low time complexity

b)

it has low space complexity

c)

it is easy to implement

d)

it requires only n swaps under any condition

8.

Recursive selection sort is a comparison based sort.

a)

True

b)

False

9.

Which of the following sorting algorithm is NOT stable?

a)

Selection Sort

b)

Bubble Sort

c)

Brick Sort

d)

Merge Sort

10.

What is the number of swaps required to sort the array arr={5,3,2,4,1} using recursive selection sort?

a)

0

b)

1

c)

2

d)

3

11.

Which of the following lines should be inserted to complete the above code?

a)

arr[i] > max_element

b)

arr[i] < max_element

c)

arr[i] == max_element

d)

arr[i] != max_element

12.

Which of the following techniques can be used to search an element in an unsorted array?

a)

Iterative linear search

b)

Recursive binary search

c)

Iterative binary search

d)

Normal Binary Search

13.

Which of the following lines should be inserted to complete the above code?

a)

temp = next

b)

temp->next = temp

c)

temp = temp->next

d)

return 0

14.

Which of the following lines should be inserted to complete the above code?

a)

1

b)

0

c)

linear_search(temp, value)

d)

linear_search (temp-> next,value)

15.

Recursive solution of tower of Hanoi problem is an example of which of the following algorithm?

a)

Dynamic Programming

b)

Backtracking

c)

Greedy algorithm

d)

Divide and Conquer

16.

Minimum time required to solve tower of Hanoi puzzle with 4 disks assuming one move takes 2 seconds, will be

a)

15 Seconds

b)

30 Seconds

c)

16 Seconds

d)

32 Seconds

17.

Which of the following is a sub string of “SANFOUNDRY”?

a)

SANO

b)

FOUND

c)

SAND

d)

FOND

18.

Which is the worst method of choosing a pivot element?

a)

First element as pivot

b)

Last element as pivot

c)

Median - of - Three - Partioning

d)

Random element as Pivot

19.

Which among the following is the best cut-off range to perform insertion sort within a quick sort?

a)

N = 0 - 5

b)

N = 5 - 20

c)

N = 20 - 30

d)

N > 30

20.

Quick sort uses join operation rather than merge operation.

a)

TRUE

b)

FALSE

21.

Which of the following areas do closest pair problem arise?

a)

Computational geometry

b)

Graph coloring problems

c)

Numerical problems

d)

String matching

22.

Which approach is based on computing the distance between each pair of distinct points and finding a pair with the smallest distance?

a)

Brute force

b)

Exhaustive Search

c)

Divide and Conquer

d)

Branch and bound

23.

Manhattan distance is an alternative way to define a distance between two points.

a)

True

b)

False

24.

The optimal time obtained through divide and conquer approach using merge sort is the best case efficiency.

a)

True

b)

False

25.

Which of the points are closer to each other?

a)

P11 and P11

b)

P3 and P8

c)

P2 and P3

d)

P9 and P10

26.

Cross product is also known as?

a)

Scalar Product

b)

Vector Product

c)

Dot Product

d)

Multiplication

27.

What is the other name for quick hull problem?

a)

Convex hull

b)

Concave hull

c)

Closest pair

d)

Path Conversation

28.

What does the following diagram depict?

a)

Closest pair

b)

Convex hull

c)

Concave Hull

d)

Path Compression

29.

What is the average case complexity of a quick hull algorithm?

a)

O(N)

b)

O(N LOG N)

c)

O(N2)

d)

O(Log N)

30.

The quick hull runs faster if the input uses non extremes points

a)

True

b)

False

31.

Dijkstra’s Algorithm is used to solve _____________ problems

a)

All pair shortest path

b)

Single source shortest path

c)

Network flow

d)

Sorting

32.

What is the basic principle behind Bellman Ford Algorithm?

a)

Interpolation

b)

Extrapolation

c)

Regression

d)

Relaxation

33.

When dynamic programming is applied to a problem, it takes far less time as compared to other methods that don’t take advantage of overlapping subproblems.

a)

True

b)

False

34.

When a top-down approach of dynamic programming is applied to a problem, it usually _____________

a)

Decreases both, the time complexity and the space complexity

b)

Decreases the time complexity and increases the space complexity

c)

Increases the time complexity and decreases the space complexity

d)

Increases both, the time complexity and the space complexity

35.

Which of the following problems is NOT solved using dynamic programming?

a)

0/1 knapsack problem

b)

Matrix chain multiplication problem

c)

Edit distance problem

d)

Fractional knapsack problem

36.

Which of the following problems should be solved using dynamic programming?

a)

Merge Sort

b)

Binary Search

c)

Longest Common subsequence

d)

Quick Sort

37.

To calculate c(i, j )’s , w( i, j)’s and r(i, j)’s; the OBST algorithm in worst case takes the following time.

a)

O(log n)

b)

O (n4)

c)

O (n3)

d)

O (n log n)

38.

What is the type of the algorithm used in solving the 4 Queens problem?

a)

Greedy

b)

Dynamic

c)

Branch and Bound

d)

Backtracking

39.

In Knapsack problem, the best strategy to get the optimal solution, where Pi, Wi is the Profit, Weight associated with each of the Xi h object respectively is to

a)

Arrange the values Pi/Wi in ascending order

b)

Arrange the values Pi/Xi in ascending order

c)

Arrange the values Pi/Wi in descending order

d)

Arrange the values Pi/Xi in descending order

40.

Greedy job scheduling with deadlines algorithms’ complexity is defined as

a)

O(N)

b)

Ω( n log n)

c)

O (n2 log n)

d)

O ( n log n)

41.

From the following choose the one which belongs to the algorithm paradigm other than to which others from the following belongs to

a)

Minimum & Maximum problem

b)

Knapsack problem

c)

Selection problem

d)

Merge sort

42.

Identify the name of the sorting in which time is not proportional to n2

a)

Selection sort

b)

Bubble sort

c)

Quick sort

d)

Insertion sort.

43.

The optimal solution to a problem is a combination of optimal solutions to its subproblems. This is known as

a)

Principle of Duality

b)

Principle of Feasibility

c)

Principle of Optimality

d)

Principle of Dynamicity

44.

Which of the following versions of merge sort algorithm does uses space efficiently?

a)

Contiguous version

b)

Array version

c)

Linked version

d)

Structure version

e)

Heap version.

45.

Identify the correct problem for multistage graph from the list given below

a)

Resource allocation problem

b)

Traveling salesperson problem

c)

Producer consumer problem

d)

Barber’s problem

46.

From the following pick the one which does not belongs to the same paradigm to which others belongs to.

a)

Minimum & Maximum problem

b)

Knapsack problem

c)

Selection problem

d)

Merge sort

47.

The amount of time needs to run to completion is known as____________

a)

Space complexity

b)

Time complexity

c)

Worst case

d)

Best case

48.

__________ is the minimum number of steps that can executed for the given parameters

a)

Average Case

b)

Time Complexity

c)

worst case

d)

Best case

49.

Graphical representation of algorithm is _____________________

a)

Pseudo-code

b)

Flow chart

c)

Graph coloring

d)

Dynamic programing

50.

In pseudo-code conventions input express as __________

a)

Input

b)

Read

c)

Write

d)

Return

51.

Time complexity of given algorithm Algorithm Display(A)

{

S:=0.0; For i:=0 to n-1

{

S:=S+A[i];

Return S;

}

}

a)

4n+4

b)

4n2+4

c)

2n2+2n+2

d)

4n+4

52.

Time complexity of given algorithm Algorithm Sum(A,S)

{

for i:=1 to n-1

{

for j:=2 to n-1

{

S:=S+i+j;

return S;

}

}

}

a)

6n2-14n+4

b)

6n2+14n+10

c)

4n2+6n+12

d)

6n2-14n+10

53.

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

a)

Insertion sort.

b)

Bubble sort.

c)

Shell sort

d)

Quick sort.

54.

In analysis of algorithm, approximate relationship between the size of the job and the amount of work required to do is expressed by using _________

a)

Central tendency

b)

Differential equation

c)

Order of execution

d)

Order of magnitude

e)

Order of Storage

55.

How many recursive calls are there in

Recursive matrix multiplication through

Simple Divide and Conquer Method

a)

4

b)

7

c)

5

d)

9

56.

If Matrix X is of order A*B and Matrix Y

is of order C*D, and B=C then the order of

the Matrix X*Y is A*D?

a)

True

b)

False

57.

Which of the following is considered as the

top of the stack in the linked list

implementation of the stack

a)

Last node

b)

First node

c)

Middle node

d)

Random mode

58.

Which of the following methods can be

used to find the largest and smallest element

in an array

a)

Recursion

b)

Iteration

c)

Both recursion and Iteration

d)

No method is suitable

59.

Recursive solution of tower of hanoi

problem is an example of which of the

following algorithm

a)

Dynamic Programming

b)

Back Tracking

c)

Greedy algorithm

d)

Divide and Conquer

60.

Quick sort follows Divide-and-Conquer

strategy

a)

True

b)

False

61.

Name the node which has been generated but none of its children nodes have been generated in state space tree of backtracking method.

a)

Dead Node

b)

Live Node

c)

E Node

d)

State Node

62.

Testing of a program consists of 2 phases which are ______________________and ____________

a)

Average case & Worst case

b)

Time complexity & Space complexity

c)

Validation and checking errors

d)

Debugging and profiling

63.

The amount of time needs to run to completion is known as____________

a)

Space Complexity

b)

Time Complexity

c)

Best complexity

d)

Worst Complexity

64.

Prims algorithm is based on _____________ method

a)

Divide and conquer method

b)

Greedy method

c)

Branch and bound

d)

Dynamic programming

65.

The general criteria of algorithm; algorithm must terminates after a finite number of steps ______

a)

Output

b)

Finiteness

c)

Effectiveness

d)

Input

66.

O-notation provides an asymptotic

a)

upper bound

b)

lower bound

c)

light bound

d)

none of these

67.

The minimum number of colors needed to color a graph having n>3 vertices and 2 edges is

a)

2

b)

3

c)

4

d)

1

68.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))

a)

1

b)

2

c)

3

d)

4

69.

The upper bound on the time complexity of the nondeterministic sorting algorithm is

a)

O(n)

b)

O(n log n)

c)

O(1)

d)

O( log n)

e)

O(n2).

70.

How do you determine the cost of a spanning tree?

a)

By the sum of the costs of the edges of the tree

b)

By the sum of the costs of the edges and vertices of the tree

c)

By the sum of the costs of the vertices of the tree

d)

By the sum of the costs of the edges of the graph

e)

By the sum of the costs of the edges and vertices of the graph

71.

Sorting is not possible by using which of the following methods?

a)

Insertion

b)

Selection

c)

Deletion

d)

Exchange

72.

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

a)

Insertion sort.

b)

Bubble sort

c)

Shell sort.

d)

Quick sort.

73.

fractional knapsack is based on ____________method

a)

greedy method

b)

dynamic programming

c)

branch and bound

d)

divide and conquer

74.

In Algorithm Specification the blocks are indicated with matching _______

a)

Braces

b)

Parenthesis

c)

Square Brackets

d)

Slashes

75.

____________ is an algorithm design method that can be used when the solution to a problem can be viewed as the result of a sequence of decisions

a)

Dynamic programming

b)

Backtracking

c)

Branch and bound

d)

Greedy method