0% found this document useful (0 votes)
2 views

algorithm

The document contains a series of multiple-choice questions and answers related to algorithms, data structures, and complexity theory. It covers topics such as algorithm properties, search algorithms, sorting algorithms, time complexity, and graph theory. Each question is followed by the correct answer indicated in parentheses.

Uploaded by

zmd141479
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

algorithm

The document contains a series of multiple-choice questions and answers related to algorithms, data structures, and complexity theory. It covers topics such as algorithm properties, search algorithms, sorting algorithms, time complexity, and graph theory. Each question is followed by the correct answer indicated in parentheses.

Uploaded by

zmd141479
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

1

1. An algorithm is a _________ set of precise instructions for performing


computation.(b)
a) Infinite
b) Finite
c) Constant
d) None of the mentioned

2. Out of the following which property algorithms does not share?(d)


a) Input
b) Finiteness
c) Generality
d) Constancy

3. In ________ search each element is compared with x till not found.(b)


a) Binary
b) Sequential
c) Merge
d) None of the mentioned

4. If the entire list is searched sequentially without locating x in linear search, the
solution is __________(a)
a) 0
b) -1
c) 1
d) 2

5. To sort a list with n elements, the insertion sort begins with the __________
element.(b)
a) First
b) Second
c) Third
d) Fourth

6. __________ comparisons required to sort the list 1, 2, 3…….n using insertion sort.
(c)
a) (n2 + n + 2) / 2
b) (n3 + n – 2) / 2
c) (n2 + n – 2) / 2
2

d) (n2 – n – 2) / 2

7. The Worst case occurs in linear search algorithm when ____________(d)


a) Item is somewhere in the middle of the array
b) Item is not in the array at all
c) Item is the last element in the array
d) Item is the last element in the array or is not there at all

8. List obtained in third pass of selection sort for list 3, 5, 4, 1, 2 is ___________(b)


a) 1, 2, 4, 3, 5
b) 1, 2, 3, 4, 5
c) 1, 5, 4, 3, 2
d) 3, 5, 4, 1, 2

9. The operation of processing each element in the list is known as _________(d)


a) Sorting
b) Merging
c) Inserting
d) Traversal

10. The complexity of Bubble sort algorithm is _________(c)


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)

1. An Algorithm is ___________(a)
a) A procedure for solving a problem
b) A problem
c) A real life mathematical problem
d) None of the mentioned

2. An algorithm in which we divide the problem into subproblem and then we


combine the subsolutions to form solution to the original problem is known as
_________(b)
a) Brute Force
b) Divide and Conquer
c) GreedyAlgorithm
3

d) None of the mentioned

3. An algorithm which uses the past results and uses them to find the new results is
_________(c)
a) Brute Force
b) Divide and Conquer
c) Dynamic programming algorithms
d) None of the mentioned

4. A Complexity of algorithm depends upon _________(c)


a) Time only
b) Space only
c) Both Time and Space
d) None of the mentioned

5. An algorithm which tries all the possibilities unless results are satisfactory is and
generally is time-consuming is _________(a)
a) Brute Force
b) Divide and Conquer
c) Dynamic programming algorithms
d) None of the mentioned

6. For a recursive algorithm _________(b)


a) a base case is necessary and is solved without recursion.
b) a base case is not necessary
c) doesnot solve a base case directly
d) none of the mentioned

7. Optimization of algorithm means _________(a)


a) making that algorithm fast by time and compact by space
b) making that algorithm slow by time and large by space
c) making that algorithm fast by time and large by space
d) making that algorithm slow by time and compact by space

8. For an algorithm which is the most important characteristic that makes it


acceptable _________(c)
a) Fast
b) Compact
c) Correctness and Precision
4

d) None of the mentioned

9. An algorithm: can be represented through _________(d)


a) flow charts
b) pseudo codes
c) instructions in common language
d) all of the mentioned

10. There are two algorithms suppose A takes 1.41 milli seconds while B takes 0.9
milliseconds, which one of them is better considering all other things the same?(b)
a) A is better than B
b) B is better than A
c) Both are equally good
d) None of the mentioned

1. Which of the following case does not exist in complexity theory?(d)


a) Best case
b) Worst case
c) Average case
d) Null case

2. The complexity of linear search algorithm is _________(a)


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)

3. The complexity of Binary search algorithm is _________(b)


a) O(n)
b) O(log)
c) O(n2)
d) O(n log n)

4. The complexity of merge sort algorithm is _________(d)


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)
5

5. The complexity of Bubble sort algorithm is _________(c)


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)

6. The Worst case occur in linear search algorithm when _________(d)


a) Item is somewhere in the middle of the array
b) Item is not in the array at all
c) Item is the last element in the array
d) Item is the last element in the array or is not there at all

7. The worst case complexity for insertion sort is _________(c)


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)

8. The complexity of Fibonacci series is _________(a)


a) O(2n)
b) O(log n)
c) O(n2)
d) O(n log n)

9. The worst case occurs in quick sort when _________(b)


a) Pivot is the median of the array
b) Pivot is the smallest element
c) Pivot is the middle element
d) None of the mentioned

10. The worst case complexity of quick sort is _________(c)


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)

1. Which is used to measure the Time complexity of an algorithm Big O notation?(d)


a) describes limiting behaviour of the function
b) characterises a function based on growth of function
6

c) upper bound on growth rate of the function


d) all of the mentioned

2. If for an algorithm time complexity is given by O(1) then the complexity of it is


____________(a)
a) constant
b) polynomial
c) exponential
d) none of the mentioned

3. If for an algorithm time complexity is given by O(log2n) then complexity will be


___________(d)
a) constant
b) polynomial
c) exponential
d) none of the mentioned

Explanation: The growth rate of that function will be logarithmic therefore complexity will be
logarithmic.

4. If for an algorithm time complexity is given by O(n) then the complexity of it is


___________(b)
a) constant
b) linear
c) exponential
d) none of the mentioned

5. If for an algorithm time complexity is given by O(n2) then complexity will ____(b)
a) constant
b) quadratic
c) exponential
d) none of the mentioned

6. If for an algorithm time complexity is given by O((3⁄2)n) then complexity will be


___________(c)
a) constant
b) quardratic
c) exponential
7

d) none of the mentioned

7. The time complexity of binary search is given by ___________(d)


a) constant
b) quardratic
c) exponential
d) none of the mentioned

8. The time complexity of the linear search is given by ___________(d)


a) O(log2n)
b) O(1)
c) exponential
d) none of the mentioned

9. Which algorithm is better for sorting between bubble sort and quicksort?(b)
a) bubble sort
b) quick sort
c) both are equally good
d) none of the mentioned

10. Time complexity of the binary search algorithm is constant.(b)


a) True
b) False

1. The binary notation of 231 is ___________(d)


a) (11010111)2
b) (10111011)2
c) (11100011)2
d) (11100111)2

Explanation: By binary Expansion of 11100111 is 1*20 + 1*21 + 1*22 + 1*25 + 1*26 + 1*27 is
equal to 231.

2. The decimal notation of 101010101 is ___________(b)


a) 34010
b) 34110
c) 34210
d) 31510
8

Explanation: (101010101)2 = 1*20 + 1*22 + 1*24 + 1*26 + 1*28 = 341.

3. The binary notation of ABBA is ___________(a)


a) 1010 1011 1011 1010
b) 1010 1001 1011 1011
c) 1011 1000 1010 1001
d) 1001 1000 1000 1111

4. The hexadecimal notation of (1011 0111 1011)2 is ___________(c)


a) (B2B)16
b) (B5B)16
c) (B7B)16
d) (A7B)16

Explanation: (1011)2 = 11 and (0111)2 = 7, 11 in hexadecimal notation represents B. So it is


(B7B)16.

5. The octal expansion of (10 1011 1011)2 is ___________(d)


a) (1245)8
b) (1276)8
c) (1275)8
d) (1273)8

6. The hexadecimal expansion of (177130)10 is ___________(b)


a) (2B3EB)16
b) (2B3EA)16
c) (2C3AA)16
d) (2B2AA)16

Explanation: Successively divide 177130 by 16 to obtain remainder they are (2B3EA)16.

7. The greatest common divisor of 414 and 662 is?(c)


a) 4
b) 5
c) 2
d) 6

8. The greatest common divisor of 12 and 18 is?(d)


a) 2
b) 3
9

c) 4
d) 6

9. The decimal expansion of (2AE0B)16 is?(a)


a) (175627)10
b) (175624)10
c) (178566)10
d) (175622)10

10. The greatest common divisor of 7 and 5 is?(a)


a) 1
b) 2
c) 5
d) 7

1. The quotient when 19 is divided by 6 is?(c)


a) 1
b) 2
c) 3
d) 0

Explanation: According to the Division Algorithm 19 = 6(3) + 1. Hence, quotient when 19


divided by 6 is 3 = 19 div 6.

2. The remainder when 111 is divided by 12 is?(d)


a) 0
b) 1
c) 2
d) 3

Explanation: According to the Division Algorithm 111 = 12(9) + 3. Hence, remainder when
111 divided by 12 is 3 = 111 mod 12.

3. The quotient and remainder when -1 is divided by 3 is?(b)


a) -1 and -1
b) -1 and 2
c) 1 and 2
d) -1 and -2
10

Explanation: According to the Division Algorithm -1 = 3(-1) + 2. Hence, quotient when -1


divided by 3 is -1 = -1 div 3 and remainder when -1 divided by 3 is 2 = -1 mod 3.

4. The value of 12 mod 3 is?(a)


a) 0
b) 1
c) 2
d) 3

Explanation: By the Division algorithm 12 = 3(4) + 0. Where remainder is 12 mod 3.

5. The value of 155 mod 9 is?(c)


a) 0
b) 1
c) 2
d) 3

Explanation: By the Division algorithm 155 = 9(17) + 2. Where remainder is 155 mod 9.

6. Is 17 congruent to 4 modulo 6.(b)


a) True
b) False

Explanation: 6 does not divide 17 – 4 = 13.

7. If a|b and a|c, then?(c)


a) a|bc
b) c|a
c) a|(b+c)
d) b|a

8. Is 102 congruent to 6 modulo 16.(a)


a) True
b) False

Explanation: 16 divide 102 – 6 = 96.

9. The quotient and remainder when 18 is divided by 5 is?(d)


a) 2 and 3
b) 1 and 2
11

c) 3 and 2
d) 3 and 3

Explanation: According to the Division Algorithm 18 = 5(3) + 3. Hence, quotient when 18


divided by 5 is 3 = 18 div 5 and remainder when 18 divided by 5 is 3 = 18 mod 5.

10. The value of 15 mod 11 is?(d)


a) 1
b) 2
c) 3
d) 4

1. An undirected graph G which is connected and acyclic is called _________(c)


a) bipartite graph
b) cyclic graph
c) tree
d) forest

2. An n-vertex graph has ______ edges.(b)


a) n2
b) n-1
c) n*n
d) n*(n+1)/2

3. What is a star tree?(a)


a) A tree having a single internal vertex and n-1 leaves
b) A tree having n vertices arranged in a line
c) A tree which has 0 or more connected subtrees
d) A tree which contains n vertices and n-1 cycles

4. A polytree is called _______________(a)


a) directed acyclic graph
b) directed cyclic graph
c) bipartite graph
d) connected graph

5. The tree elements are called __________(b)


a) vertices
b) nodes
12

c) points
d) edges

6. In an n-ary tree, each vertex has at most ______ children.(a)


a) n
b) n4
c) n*n
d) n-1

7. A linear graph consists of vertices arranged in a line.(b)


a) false
b) true
c) either true or false
d) cannot determined

8. Two labeled trees are isomorphic if ____________(c)


a) graphs of the two trees are isomorphic
b) the two trees have same label
c) graphs of the two trees are isomorphic and the two trees have the same label
d) graphs of the two trees are cyclic

9. A graph which consists of disjoint union of trees is called ______(b)


a) bipartite graph
b) forest
c) caterpillar tree
d) labeled tree

10. What is a bipartite graph?(d)


a) a graph which contains only one cycle
b) a graph which consists of more than 3 number of vertices
c) a graph which has odd number of vertices and even number of edges
d) a graph which contains no cycles of odd length

1. In preorder traversal of a binary tree the second step is ____________(b)


a) traverse the right subtree
b) traverse the left subtree
c) traverse right subtree and visit the root
d) visit the root
13

2. An important application of binary tree is ______(a)


a) Huffman coding
b) stack implementation
c) queue implementation
d) traverse a cyclic graph

3. From the following code identify the which traversal of a binary tree is this
_______(c)

//if node has left child


order(node.left)
//if node has right child
order(node.right)
visit(node)

a) Inorder traversal
b) preorder traversal
c) postorder traversal
d) Euler tour traversal

4. What is the minimum height for a binary search tree with 60 nodes?(d)
a) 1
b) 3
c) 4
d) 2

5. From the following code identify the which traversal of a binary tree is this __________

function traversal(node)
{
//Input:root node of the tree
//Output:None
visitLeft(node)
//if node has left child
traversal(node.left)
visit_Below(node)
//if node has right child
traversal(node.right)
visitRight(node)
14

a) Inorder traversal
b) Euler Tour traversal
c) Post-order traversal
d) Pre-order Traversal

Answer: b

6. For the expression (7-(4*5))+(9/3) which of the following is the post order tree
traversal?(c)
a) *745-93/+
b) 93/+745*-
c) 745*-93/+
d) 74*+593/-

7. The time complexity of calculating the sum of all leaf nodes in an n-order binary
tree is __________(d)
a) O(n2)
b) O(n+1)
c) O(1)
d) O(n)

8. An immediate application of a Depth First Search traversal is __________(a)


a) count the number of leaf nodes
b) perform Inorder traversal in easy way
c) count number of nodes
d) implement preorder traversal

9. Breadth First Search traversal of a binary tree finds its application in


__________(b)
a) Cloud computing
b) Peer to peer networks
c) Weighted graph
d) Euler path

10. Worst case complexity of Breadth First Search traversal __________(b)


a) O(n*n)
b) O(nlogn)
15

c) O(n2 logn)
d) O(n3)

1. If a matrix A = [A11 A12 ⋯ A1n A21 A2n ⋮ ⋮ An1 An2 ⋯ Ann], order(nxn) Aii = 1, Aij = 0 for i ≠ j.
Then that matrix is known as ________(a)
a) Identity matrix
b) Null matrix
c) Singular matrix
d) None of the mentioned

2. A symmetric matrix is a one in which?(c)


a) All diagonal elements are zero
b) All diagonal elements are 1
c) A = AT
d) A = -AT

3. An anti-symmetric matrix is a one in which?(d)


a) All diagonal elements are zero
b) All diagonal elements are 1
c) A = AT
d) A = -AT

4. A matrix having one row and many columns is known as?(a)


a) Row matrix
b) Column matrix
c) Diagonal matrix
d) None of the mentioned

5. A matrix having many rows and one column is known as?(b)


a) Row matrix
b) Column matrix
c) Diagonal matrix
d) None of the mentioned

6. The trace of the matrix is defined as _______(b)


a) Sum of all the elements of the matrix
b) Sum of all the elements of leading diagonal of matrix
c) Sum of all non-zero elements of matrix
16

d) None of the mentioned

7. A square matrix A = [aij ]nxn, if aij = 0 for i > j then that matrix is known as _______(a)
a) Upper triangular matrix
b) Lower triangular matrix
c) Unit matrix
d) Null matrix

8. A square matrix A = [aij ]nxn, if aij = 0 for i < j then that matrix is known as _______(b)
a) Upper triangular matrix
b) Lower triangular matrix
c) Unit matrix
d) Null matrix

9. Two matrix can be added if _______(c)


a) rows of both the matrices are same
b) columns of both the matrices are same
c) both rows and columns of both the matrices are same
d) number of rows of first matrix should be equal to number of column of second

10. For matrix A if AAT = I, I is identity matrix then A is?(a)


a) Orthagonal matrix
b) Nilpotent matrix
c) Idempotent matrix
d) None of the mentioned

1. The determinant of identity matrix is?(a)


a) 1
b) 0
c) Depends on the matrix
d) None of the mentioned

2. If determinant of a matrix A is Zero than __________(a)


a) A is a Singular matrix
b) A is a non-Singular matrix
c) Can’t say
d) None of the mentioned
17

3. For a skew symmetric even ordered matrix A of integers, which of the following
will not hold true?(c)
a) det(A) = 9
b) det(A) = 81
c) det(A) = 7
d) det(A) = 4

4. For a skew symmetric odd ordered matrix A of integers, which of the following will
hold true?(c)
a) det(A) = 9
b) det(A) = 81
c) det(A) = 0
d) det(A) = 4

5. Let A = [kaij]nxn, B = [aij]nxn, be an nxn matrices and k be a scalar then det(A) is equal
to _________(b)
a) Kdet(B)
b) Kndet(B)
c) K3det(b)
d) None of the mentioned

6. The Inverse exist only for non-singular matrices.(a)


a) True
b) False

10. Which of the following property of matrix multiplication is correct?(d)


a) Multiplication is not commutative in general
b) Multiplication is associative
c) Multiplication is distributive over addition
d) All of the mentioned

You might also like