Sorting, Searching and Optimization

38 MCQs Covers Bubble and Selection Sort, Linear and Binary Search, and BFS versus DFS. Also covers optimization problems, with the exercise MCQs on sorting and DFS.

MCQs

38 questions · 35 min · 38 marks

Want to try first? Take the free Computer Science test: SDLC and Waterfall Model

Sample questions

The first 5 of 38. Try each one, then tap to see the answer.

  1. Question 1

    Which of the following sorting algorithms is the most efficient for large datasets?

    • ABubble Sort
    • BMerge Sort
    • CSelection Sort
    • DInsertion Sort
    Show answer

    Answer: B

    Merge Sort is O(n log n); the others are O(n²). (Textbook exercise MCQ 5; the printed question mixed up search and sort, so I reworded it.)

  2. Question 2

    An algorithm that sorts data by stepping through the list and swapping adjacent elements if needed is:

    • ASelection Sort
    • BQuick Sort
    • CMerge Sort
    • DBubble Sort
    Show answer

    Answer: D

    Bubble Sort compares adjacent elements. (Textbook exercise MCQ 7.)

  3. Question 3

    The time complexity of Depth-First Search (DFS) in a graph is:

    • AO(V + E)
    • BO(n log n)
    • CO(V²)
    • DO(n)
    Show answer

    Answer: A

    Every vertex and edge is visited once. (Textbook exercise MCQ 8.)

  4. Question 4

    Bubble Sort works by:

    • ADividing the list into halves
    • BPicking the largest coin
    • CComparing adjacent elements and swapping them if they are in the wrong order
    • DStoring results of subproblems
    Show answer

    Answer: C

    The passes repeat until no swaps are needed.

  5. Question 5

    The worst-case time complexity of Bubble Sort is:

    • AO(n)
    • BO(n²)
    • CO(log n)
    • DO(n log n)
    Show answer

    Answer: B

    Each element may be compared with every other element.

More tests in Algorithms and Problem Solving

Practise with a free account

Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.

Create free account