MCQs / Computer Science / Unit 2: Computational Thinking and Algorithms

Unit 2: Computational Thinking and Algorithms MCQs — Computer Science (page 2)

43 multiple-choice questions on Unit 2: Computational Thinking and Algorithms from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

26. Which approach to summing 1 to n is most efficient?

  1. The formula n(n + 1)/2
  2. Recursion adding one at a time
  3. Two nested loops
  4. A loop adding each number

Answer: A) The formula n(n + 1)/2

Explanation: The formula needs a single calculation whatever the size of n. SLO CS-11-B-01

Discuss this question

27. What is printed? (sum of even numbers algorithm with N = 9) python N = 9 s, i = 0, 2 while i <= N: s += i i += 2 print(s)

  1. 18
  2. 30
  3. 25
  4. 20

Answer: D) 20

Explanation: 2 + 4 + 6 + 8 = 20; the loop stops when i = 10. SLO CS-11-B-01

Discuss this question

28. Which sort works like arranging playing cards in your hand?

  1. Linear sort
  2. Binary sort
  3. Insertion sort
  4. Bubble sort

Answer: C) Insertion sort

Explanation: Insertion sort inserts each new item into its correct place in the sorted part. SLO CS-11-B-02

Discuss this question

29. Worst-case number of comparisons for bubble sort on 8 items is:

  1. 16
  2. 28
  3. 8
  4. 64

Answer: B) 28

Explanation: (n − 1) + … + 1 = n(n − 1)/2 = 28. SLO CS-11-B-02

Discuss this question

30. Which search is better for a small, unsorted list?

  1. K-map search
  2. Linear search
  3. Binary search
  4. Bubble search

Answer: B) Linear search

Explanation: Linear search works on unsorted data and is simple for small lists. SLO CS-11-B-02

Discuss this question

31. Insertion sort is especially efficient when the list is:

  1. nearly sorted
  2. stored on paper
  3. in reverse order
  4. very large and random

Answer: A) nearly sorted

Explanation: Few items need to be shifted when the list is almost sorted. SLO CS-11-B-02

Discuss this question

32. In pseudocode, the symbol ← usually means:

  1. assignment
  2. less than
  3. comparison
  4. output

Answer: A) assignment

Explanation: count ← count + 1 assigns a new value to count. SLO CS-11-B-01

Discuss this question

33. After the first pass of bubble sort (ascending) on [5, 1, 4, 2, 8], the list is:

  1. [1, 4, 2, 5, 8]
  2. [1, 5, 4, 2, 8]
  3. [5, 1, 4, 2, 8]
  4. [1, 2, 4, 5, 8]

Answer: A) [1, 4, 2, 5, 8]

Explanation: Swaps: (5,1), (5,4), (5,2); (5,8) stays – the largest value reaches the end. SLO CS-11-B-02

Discuss this question

34. The rounded rectangle (oval) in a flowchart shows:

  1. a decision
  2. start or stop
  3. a process
  4. a connector only

Answer: B) start or stop

Explanation: Terminal symbols mark the start and end. SLO CS-11-B-01

Discuss this question

35. In binary search, if the middle item is smaller than the target, the search continues in the:

  1. left half
  2. whole list again
  3. middle only
  4. right half

Answer: D) right half

Explanation: The target must be among the larger values to the right. SLO CS-11-B-02

Discuss this question

36. Searching for a word in a printed dictionary by opening near the middle is similar to:

  1. insertion sort
  2. linear search
  3. bubble sort
  4. binary search

Answer: D) binary search

Explanation: The dictionary is sorted, and you repeatedly halve the range. SLO CS-11-B-02

Discuss this question

37. For a program accepting marks 0–100, the value 100 is:

  1. normal data
  2. erroneous data
  3. boundary data
  4. invalid data

Answer: C) boundary data

Explanation: Values at the limits of the valid range are boundary (extreme) data. SLO CS-11-B-01

Discuss this question

38. What does this program print? python data = [3, 8, 12, 17, 23] print(data.index(17))

  1. 3
  2. -1
  3. 4
  4. 2

Answer: A) 3

Explanation: Indexes start at 0: 3→0, 8→1, 12→2, 17→3. SLO CS-11-B-02

Discuss this question

39. Noticing that every class needs the same permission letter, so one template can be reused, is:

  1. encryption
  2. pattern recognition
  3. decomposition
  4. abstraction

Answer: B) pattern recognition

Explanation: Pattern recognition finds similarities to reuse solutions. SLO CS-11-B-02

Discuss this question

40. The property of an algorithm that it must stop after a finite number of steps is:

  1. effectiveness
  2. definiteness
  3. clarity
  4. finiteness

Answer: D) finiteness

Explanation: An algorithm must terminate. SLO CS-11-B-01

Discuss this question

41. To sort in descending order with bubble sort, the comparison a[j] a[j+1] changes to:

  1. a[j] == a[j+1]
  2. a[j] = a[j+1]
  3. a[j] < a[j+1]
  4. it does not change

Answer: C) a[j] < a[j+1]

Explanation: Swap when the left item is smaller, so larger values move to the front. SLO CS-11-B-02

Discuss this question

42. Which flowchart symbol is used for a decision?

  1. Diamond
  2. Oval
  3. Rectangle
  4. Parallelogram

Answer: A) Diamond

Explanation: A diamond holds a condition with Yes/No exits. SLO CS-11-B-01

Discuss this question

43. Binary search requires the list to be:

  1. short
  2. sorted
  3. made of strings only
  4. unsorted

Answer: B) sorted

Explanation: Binary search halves a sorted range; on unsorted data it gives wrong answers. SLO CS-11-B-02

Discuss this question

Previous Page 2 of 2

Practise Unit 2: Computational Thinking and Algorithms MCQs

More Computer Science chapters