Any2Quiz
CBSE / 12 / Computer Science / Programming

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.

Play all 10 questions free

Sample questions

  1. What is the time complexity of linear search?

    1. O(1)
    2. O(log n)
    3. O(n)
    4. O(n^2)
    Show answer

    Answer: C. O(n)

    Linear search checks each element one by one, resulting in a time complexity of O(n).

  2. Which sorting algorithm has a worst-case time complexity of O(n^2)?

    1. Merge Sort
    2. Quick Sort
    3. Heap Sort
    4. Bubble Sort
    Show answer

    Answer: D. Bubble Sort

    Bubble Sort has a worst-case time complexity of O(n^2) when the input is reverse sorted.

  3. Explain the difference between recursive and iterative algorithms.

    1. Recursive algorithms use loops, while iterative algorithms use function calls.
    2. Recursive algorithms use function calls, while iterative algorithms use loops.
    3. Both are the same.
    4. None of the above.
    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.

  4. Describe Dijkstra's algorithm and its application.

    1. Finds the shortest path in an unweighted graph
    2. Finds the shortest path in a weighted graph with negative edges
    3. Finds the shortest path in a weighted graph with non-negative edges
    4. Finds the minimum spanning tree in a graph
    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.

  5. Explain Amortized Analysis and give an example.

    1. Analyzing the average case complexity
    2. Analyzing the worst-case complexity
    3. Analyzing the average time complexity over a sequence of operations
    4. Analyzing the best-case complexity
    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.

Take the full quiz

More quizzes

Browse all Programming quizzes