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
Q4 of 20
Which of the following is part of a stack ADT's behavioural contract rather than an implementation detail?
Q5 of 20
Binary search requires its input array to be sorted. In contract terms, "the array is sorted" is the operation's:
Q6 of 20
After push(x) completes, size() has grown by one and peek() returns x. In contract terms, these statements are push's:
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?
Q11 of 20
For a nonempty int array a, which initialization of best makes the maximum algorithm correct for every input?
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; } ```
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?
Q15 of 20
Why should an array-based stack class keep its items array and top field private?
Q16 of 20
A stack ADT is implemented once with an array and once with linked nodes. Which statement is true?
Q17 of 20
A sorting method passes 50 hand-picked test cases. What can be concluded?
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?
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?
Q20 of 20
Which three basic control constructs are sufficient to express any algorithm?
Need to review the concepts?
Read Free Study Notes →Read Data Structures and Algorithms Study Notes
Review complete topic notes, syntax guides, code examples, and summary tables.