CDCDAC Prep
PGCP-ACCMCE (CCE Modules Exam)•20 Questions

Data Structures and Algorithms Practice MCQs

Topic Covered in this Question Set

Problem Solving, Abstraction and Algorithm Correctness

Click on an option to check your answer immediately. Full solution & explanation provided for every question.

Interactive Practice Mode

Data Structures and Algorithms Free MCQs

Select an option to test your knowledge with real exam questions and instant explanations.

Total20
Correct0
Wrong0
Progress: 0 of 20 answered0% Accuracy
Q1 of 20

What should be established first when solving a programming problem?

Open topic in App →
Q2 of 20

Which statement best defines an algorithm?

Open topic in App →
Q3 of 20

What does an abstract data type (ADT) specify?

Open topic in App →
Q4 of 20

Which of the following is part of a stack ADT's behavioural contract rather than an implementation detail?

Open topic in App →
Q5 of 20

Binary search requires its input array to be sorted. In contract terms, "the array is sorted" is the operation's:

Open topic in App →
Q6 of 20

After push(x) completes, size() has grown by one and peek() returns x. In contract terms, these statements are push's:

Open topic in App →
Q7 of 20

What is a loop invariant?

Open topic in App →
Q8 of 20

Which three steps make up a loop-invariant proof of correctness?

Open topic in App →
Q9 of 20

To prove that a loop always terminates, what is typically shown?

Open topic in App →
Q10 of 20

A student's maximum method starts with best = 0 and replaces best whenever a[i] > best. For which input does it return a wrong answer?

Open topic in App →
Q11 of 20

For a nonempty int array a, which initialization of best makes the maximum algorithm correct for every input?

Open topic in App →
Q12 of 20

What happens when this Java method is called with an empty array? ``` static int max(int[] a) { int best = a[0]; for (int i = 1; i < a.length; i++) if (a[i] > best) best = a[i]; return best; } ```

Open topic in App →
Q13 of 20

A text-analysis program is split into separate tokenizing, word-counting and report-formatting components, each with its own inputs and outputs. Which technique is this?

Open topic in App →
Q14 of 20

Which group contains only nonlinear data structures?

Open topic in App →
Q15 of 20

Why should an array-based stack class keep its items array and top field private?

Open topic in App →
Q16 of 20

A stack ADT is implemented once with an array and once with linked nodes. Which statement is true?

Open topic in App →
Q17 of 20

A sorting method passes 50 hand-picked test cases. What can be concluded?

Open topic in App →
Q18 of 20

A linear search is written with the loop for (int i = 0; i < a.length - 1; i++). Which test case exposes the bug?

Open topic in App →
Q19 of 20

The maximum algorithm starts with best = a[0] and loops for i = 1 to n - 1. For a = [4, 9, 2, 11, 5], what is best just before the iteration with i = 3?

Open topic in App →
Q20 of 20

Which three basic control constructs are sufficient to express any algorithm?

Open topic in App →
Need to review the concepts?

Read Data Structures and Algorithms Study Notes

Review complete topic notes, syntax guides, code examples, and summary tables.

Read Free Study Notes →