0% found this document useful (0 votes)
5 views25 pages

MCQ Algorithm

The document is a comprehensive multiple-choice question bank covering various topics in algorithms, including fundamentals, complexity theory, and specific algorithms like linear search, binary search, bubble sort, selection sort, and insertion sort. Each section contains questions with correct answers provided, focusing on key concepts such as algorithm properties, time and space complexity, and efficiency. Additionally, it includes true/false questions to test understanding of algorithm characteristics.

Uploaded by

ammargamal57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views25 pages

MCQ Algorithm

The document is a comprehensive multiple-choice question bank covering various topics in algorithms, including fundamentals, complexity theory, and specific algorithms like linear search, binary search, bubble sort, selection sort, and insertion sort. Each section contains questions with correct answers provided, focusing on key concepts such as algorithm properties, time and space complexity, and efficiency. Additionally, it includes true/false questions to test understanding of algorithm characteristics.

Uploaded by

ammargamal57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Algorithms - MCQ Question Bank

Section 1: Algorithm Fundamentals (10 MCQs)

Q1
Which of the following best defines an algorithm?
a) A programming language
b) A step-by-step procedure to solve a problem
c) A computer hardware unit
d) A compiler

Answer: b

Q2
Which property ensures that an algorithm terminates?
a) Definiteness
b) Finiteness
c) Correctness
d) Efficiency

Answer: b

Q3
Definiteness means:
a) Steps are ambiguous
b) Steps are clearly defined
c) Output is random
d) Input is mandatory

Answer: b

Q4
Correctness means:
a) Fast execution
b) Minimal memory usage
c) Produces correct output
d) Uses recursion

Answer: c

Q5
Which is NOT a property of an algorithm?
a) Input
b) Output
c) Ambiguity
d) Finiteness

Answer: c

Q6
An algorithm may have:
a) No input
b) Infinite steps
c) No output
d) Random steps

Answer: a

Q7
Efficiency refers to:
a) CPU speed only
b) Time and space usage
c) Memory only
d) Output correctness

Answer: b

Q8
Which is mandatory for every algorithm?
a) Recursion
b) Input and output
c) Sorting
d) Looping

Answer: b

Q9
Which statement is true?
a) All algorithms must use loops
b) Algorithms must terminate
c) Algorithms must be recursive
d) Algorithms must be written in code

Answer: b

Q10
Which is NOT required for an algorithm?
a) Definiteness
b) Finiteness
c) Ambiguity
d) Correctness

Answer: c

Section 2: Complexity Theory (10 MCQs)

Q11
Time complexity measures:
a) Memory usage
b) Execution time growth
c) CPU type
d) Output size

Answer: b
Q12
Space complexity measures:
a) Execution time
b) Memory usage
c) CPU speed
d) Disk size

Answer: b

Q13
O(1) means:
a) Linear time
b) Constant time
c) Logarithmic time
d) Quadratic time

Answer: b

Q14
O(log n) typically occurs in:
a) Linear search
b) Binary search
c) Bubble sort
d) Selection sort

Answer: b

Q15
Which grows fastest?
a) O(n)
b) O(n log n)
c) O(n²)
d) O(2ⁿ)

Answer: d
Q16
Simplify: O(n² + n)
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Q17
Simplify: O(5n + 100)
a) O(1)
b) O(n)
c) O(n²)
d) O(log n)

Answer: b

Q18
O(n) + O(n) equals:
a) O(2n)
b) O(n²)
c) O(n)
d) O(log n)

Answer: c

Q19
O(n) × O(n) equals:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b
Q20
Which is correct ordering?
a) O(2ⁿ) < O(n²) < O(n)
b) O(n) < O(n²) < O(2ⁿ)
c) O(n²) < O(n) < O(2ⁿ)
d) O(log n) > O(n)

Answer: b

Section 3: Linear Search (8 MCQs)

Q21
Linear search works on:
a) Sorted data only
b) Unsorted data
c) Trees only
d) Graphs only

Answer: b

Q22
Worst-case time complexity of Linear search:
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)

Answer: b

Q23
Best-case of Linear search occurs when:
a) Element is last
b) Element is first
c) Element not found
d) Array is large
Answer: b

Q24
Average-case complexity of Linear search:
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)

Answer: b

Q25
Space complexity of Linear search:
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)

Answer: b

Q26
Linear search is efficient when:
a) Data is large sorted
b) Data is small or unsorted
c) Data is binary
d) Data is recursive

Answer: b

Q27
Worst case of Linear search occurs when the required element is:
a) First element
b) Last or not found
c) Middle
d) Sorted array
Answer: b

Q28
Linear search requires:
a) Sorted data
b) Does NOT require sorted data
c) Balanced tree
d) Hashing

Answer: b

Section 4: Binary Search (8 MCQs)

Q29
Binary search requires:
a) Unsorted array
b) Sorted array
c) Graph
d) Tree

Answer: b

Q30
Worst-case complexity of Binary search:
a) O(n)
b) O(log n)
c) O(1)
d) O(n²)

Answer: b

Q31
Best-case of Binary search occurs when:
a) First element
b) Middle element
c) Last element
d) Not found

Answer: b

Q32
Average-case of Binary search:
a) O(n)
b) O(log n)
c) O(1)
d) O(n²)

Answer: b

Q33
Space complexity of Binary search:
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)

Answer: b

Q34
Binary search works by:
a) Increasing array
b) Dividing search space
c) Sorting array
d) Random selection

Answer: b

Q35
Binary search is efficient for:
a) Small unsorted data
b) Large sorted data
c) Graphs
d) Trees

Answer: b

Q36
Worst case of Binary search occurs when:
a) First step match
b) Repeated halving until the end
c) Empty array
d) Sorted array

Answer: b

Section 5: Bubble Sort (10 MCQs)

Q37
Bubble sort compares:
a) Random elements
b) Adjacent elements
c) First only
d) Last only

Answer: b

Q38
Worst-case complexity of Bubble sort:
a) O(n)
b) O(n log n)
c) O(n²)
d) O(1)

Answer: c
Q39
Best-case of Bubble sort occurs when:
a) Reverse sorted
b) Already sorted
c) Random
d) Empty

Answer: b

Q40
Best-case complexity of Bubble sort:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: a

Q41
Space complexity of Bubble sort:
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)

Answer: b

Q42
Bubble sort is:
a) Stable
b) Not stable
c) Recursive
d) Binary

Answer: a
Q43
Worst-case of Bubble sort occurs when:
a) Sorted
b) Reverse sorted
c) Small data
d) Random

Answer: b

Q44
In Bubble sort, maximum number of passes in worst case:
a) 1
b) n
c) n-1
d) n²

Answer: c

Q45
Bubble sort is efficient for:
a) Large datasets
b) Small datasets
c) Graphs
d) Trees

Answer: b

Q46
In Bubble sort, each pass moves:
a) Smallest to end
b) Largest to end
c) Random element
d) Middle element

Answer: b
Section 6: Selection Sort (8 MCQs)

Q47
Selection sort works by:
a) Swapping adjacent elements repeatedly
b) Selecting the minimum element each pass
c) Dividing array recursively
d) Using hashing

Answer: b

Q48
Worst-case time complexity of Selection Sort:
a) O(n)
b) O(n log n)
c) O(n²)
d) O(1)

Answer: c

Q49
Best-case time complexity of Selection Sort:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b
Explanation:

Selection Sort always has O(N2) complexity because it performs comparisons independently of
the input order

Q50
Average-case time complexity of Selection Sort:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Q51
Space complexity of Selection Sort:
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)

Answer: b

Q52
Selection Sort is:
a) Stable
b) Not stable
c) Always stable
d) Depends on input

Answer: b

Q53
In Selection Sort, when the array is already sorted:
a) No comparisons are performed
b) No swaps are performed
c) Both comparisons and swaps are reduced
d) Time complexity becomes O(n)

Answer: b

Q54
The main operation in Selection Sort is:
a) Swapping adjacent elements
b) Finding the minimum element
c) Splitting array
d) Searching recursively

Answer: b

Section 7: Insertion Sort (10 MCQs)

Q55
Insertion sort builds:
a) Tree structure
b) Sorted portion gradually
c) Graph
d) Hash table

Answer: b

Q56
Worst-case time complexity of Insertion sort:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Q57
Best-case of Insertion sort occurs when:
a) Reverse sorted
b) Already sorted
c) Random
d) Empty

Answer: b
Q58
Best-case complexity of Insertion sort:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: a

Q59
Average-case complexity of Insertion sort:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Q60
Space complexity of Insertion sort:
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)

Answer: b

Q61
Insertion sort is efficient for:
a) Large random data
b) Nearly sorted data
c) Graph data
d) Binary trees

Answer: b
Q62
Insertion sort is:
a) Stable
b) Not stable
c) Unstable
d) Recursive

Answer: a

Q63
Worst-case of Insertion sort occurs when:
a) Sorted
b) Reverse sorted
c) Middle sorted
d) Small data

Answer: b

Q64
In insertion sort, each step inserts element into:
a) Random position
b) Sorted subarray
c) Tree
d) Graph

Answer: b

Section 8: Code Complexity (10 MCQs)

Q65

for(i=0;i<n;i++)

for(j=0;j<n;j++)

print(j)
Time complexity is:
a) O(n)
b) O(n²)
c) O(n³)
d) O(log n)

Answer: b

Q66

for(i=1;i<n;i=i*2)

print(i)

Time complexity:
a) O(n)
b) O(log n)
c) O(n²)
d) O(1)

Answer: b

Q67

for(i=0;i<n;i++)

for(j=n;j>1;j=j/2)

print(j)

Time complexity:
a) O(n)
b) O(n log n)
c) O(n²)
d) O(log n)

Answer: b
Q68

for(i=0;i<n;i++)

for(j=0;j<i;j++)

print(j)

Time complexity:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Q69
Triple nested loop complexity:
a) O(n²)
b) O(n³)
c) O(n log n)
d) O(n)

Answer: b

Q70
A loop that halves/divides the input each step is:
a) O(n)
b) O(log n)
c) O(n²)
d) O(1)

Answer: b

Q71
Adding two loops O(n) + O(n) equals:
a) O(n²)
b) O(2n)
c) O(n)
d) O(log n)

Answer: c

Q72
A nested loop typically results in:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Q73
In two-nested loops, if the outer loop runs n and the inner runs constant k:
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: a

Q74
Best description of two nested loops, each one has O (n):
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)

Answer: b

Section 9: Mixed & Trick Questions (10 MCQs)


Q75
Which algorithm performs best on nearly sorted data?
a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) Binary Search

Answer: c

Q76
Which algorithm always performs same comparisons regardless of input?
a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) Linear Search

Answer: b

Q77
Worst-case Linear Search occurs when:
a) First element
b) Last or absent element
c) Middle element
d) Sorted array

Answer: b

Q78
Binary search is not applicable for:
a) Sorted array
b) Unsorted array
c) Large dataset
d) Balanced data

Answer: b
Q79
Which is most efficient for large sorted datasets?
a) Linear Search
b) Binary Search
c) Bubble Sort
d) Selection Sort

Answer: b

Q80
Which of the following is a comparison-based sorting algorithm?
a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) All of the above

Answer: d

Q81
Best case for Linear Search is:
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)

Answer: b

Q82
Worst-case growth rate is most important in:
a) Real systems
b) Best-case analysis
c) Random cases only
d) Input preprocessing

Answer: a
Q83
Which of these is more efficient?
a) O(n²)
b) O(n log n)
c) O(2ⁿ)
d) O(n³)

Answer: b

Q84
Algorithm efficiency depends on:
a) Only hardware
b) Time and space complexity
c) Only programming language
d) Only input size

Answer: b

Section 10: True/False (MCQ Format) (10 MCQs)

Q85
Binary search works on unsorted arrays
a) True
b) False

Answer: b

Q86
Insertion sort is stable
a) True
b) False

Answer: a
Q87
Selection sort is stable
a) True
b) False

Answer: b

Q88
Time complexity measures memory usage
a) True
b) False

Answer: b

Q89
O(n²) is slower than O(n log n) for large inputs
a) True
b) False

Answer: a

Q90
Binary search has O(log n) complexity
a) True
b) False

Answer: a

Q91
Best case of Bubble Sort is O(n)
a) True
b) False

Answer: a
Q92
Worst-case of Selection Sort depends on the input order
a) True
b) False

Answer: b

Q93
Bubble sort is better than selection sort
a) True
b) False

Answer: b

Q94
Bubble Sort is generally more efficient than Selection Sort for large datasets
a) True
b) False

Answer: b

You might also like