Algorithms Quiz - CBSE Class 12 Computer Science
Free practice quiz: Algorithms (CBSE Class 12 Computer Science). 10 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
This CBSE Class 12 Computer Science practice quiz has 10 multiple-choice questions on Algorithms, and 10 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.
Start quiz: 10 questions, freeSample questions
What is the time complexity of linear search?
Show answer
Answer: C. O(n)
Linear search checks each element one by one, resulting in a time complexity of O(n).
Which sorting algorithm has a worst-case time complexity of O(n^2)?
Show answer
Answer: D. Bubble Sort
Bubble Sort has a worst-case time complexity of O(n^2) when the input is reverse sorted.
Explain the difference between recursive and iterative algorithms.
Show answer
Answer: B. Recursive algorithms use function calls, while iterative algorithms use loops.
Recursive algorithms solve a problem by breaking it down into smaller subproblems of the same type, while iterative algorithms use loops to repeat a block of code.
Describe Dijkstra's algorithm and its application.
Show answer
Answer: C. Finds the shortest path in a weighted graph with non-negative edges
Dijkstra's algorithm is used to find the shortest paths from a single source node to all other nodes in a graph with non-negative edge weights.
Explain Amortized Analysis and give an example.
Show answer
Answer: C. Analyzing the average time complexity over a sequence of operations
Amortized analysis considers the average time complexity of a sequence of operations, even if some individual operations are expensive.
More questions in this quiz
Answers and explanations are in the full quiz.
- What is the best-case time complexity of binary search?
- What is the space complexity of Merge Sort?
- What is the time complexity of finding the kth smallest element using QuickSelect?
- What is the time complexity of a naive string matching algorithm?
- Design an algorithm to find the longest palindromic substring within a given string and analyze its time complexity. Justify your choice of algorithm.
More quizzes
Browse all Programming quizzes