Quiz: Problem Solving and Algorithm Analysis — 23 questions

Detailed questions and answers

1. Why can a computer not produce useful results without software?

It creates operating rules from the hardware configuration
It interprets human intentions and selects suitable tasks
It improves its reasoning by observing previous outputs
It follows instructions supplied by software to perform tasks

It follows instructions supplied by software to perform tasks

Explanation

A computer is a machine that executes instructions, and software provides those instructions. The idea that it can independently interpret intentions confuses programmed operation with human-like decision-making.

2. Which sequence best represents the program-development process?

Implementation, documentation, requirements specification, testing, analysis, and design
Problem analysis, implementation, documentation, requirements specification, and testing
Algorithm design, testing, implementation, requirements specification, and documentation
Requirements specification, analysis, design, implementation, testing, and documentation

Requirements specification, analysis, design, implementation, testing, and documentation

Explanation

Program development begins by specifying requirements and analyzing the problem, then proceeds through algorithm design, implementation, testing and verification, and documentation. Treating coding as the starting or complete activity omits essential planning and checking stages.

3. What does a requirements specification primarily describe?

The test results obtained after the completed program is executed
The programming language, data structures, and code used for implementation
The detailed sequence of computational steps for processing each input
The needed inputs, outputs, resources, constraints, and expected solution

The needed inputs, outputs, resources, constraints, and expected solution

Explanation

Requirements specification defines what the solution must receive, produce, use, and satisfy. A detailed sequence of computational steps belongs to problem analysis or algorithm design rather than requirements specification.

4. In a program that calculates the cost of apples, which item is an output rather than an input?

The cost per kilogram expressed in rupees
The total cost expressed in rupees
The quantity of apples measured in kilograms
The weighing information supplied for the purchase

The total cost expressed in rupees

Explanation

The apple quantity and price per kilogram are supplied values, while their product gives the total cost in rupees. Calling the quantity an output reverses the roles of supplied data and calculated results.

5. Which description best defines an algorithm?

A collection of programming statements written in a selected language
A hardware procedure that executes instructions without software support
A finite, unambiguous sequence of logical steps for a specific problem
A general explanation of a problem that omits operational details

A finite, unambiguous sequence of logical steps for a specific problem

Explanation

An algorithm gives complete, clear, finite steps for solving a particular problem and does not depend on a programming language. Programming statements are an implementation of an algorithm, not the language-independent algorithm itself.

6. Which statement correctly describes the input and output requirements of an algorithm?

It may omit inputs and outputs when its instructions are unambiguous
It must accept exactly one input and produce exactly one output
It may accept zero or more inputs and must produce at least one output
It must accept at least one input and may produce zero or more outputs

It may accept zero or more inputs and must produce at least one output

Explanation

An algorithm can operate without input, but it must provide at least one defined output as part of its required properties. Requiring an input would incorrectly exclude valid algorithms that use fixed or internally available data.

7. Which property of an algorithm concerns whether it solves the intended problem rather than how many resources it uses?

Efficiency concerns solving the intended problem
Finiteness concerns minimizing resource use
Correctness concerns solving the intended problem
Correctness concerns minimizing resource use

Correctness concerns solving the intended problem

Explanation

Correctness evaluates whether the algorithm produces a solution to the intended problem. Efficiency instead concerns the resources the algorithm uses, such as time or memory.

8. What happens after the factorial algorithm finishes multiplying by the current value of ii?

It prints the factorial before changing the value of ii
It resets the factorial value and reads a new nn
It increments ii and checks whether ini \leq n
It stops whenever ii is equal to or less than nn

It increments $$i$$ and checks whether $$i \leq n$$

Explanation

The algorithm increments ii after each multiplication and continues while ini \leq n. Termination occurs when the increment makes ii greater than nn, not while the condition remains true.

9. What is the primary purpose of program testing?

Checking whether a program meets user requirements
Writing comments that explain the program's structure
Planning the algorithm before any code is written
Executing a program to demonstrate its correctness

Executing a program to demonstrate its correctness

Explanation

Program testing involves executing the program to provide evidence that it behaves correctly. Checking compliance with user requirements is the role of verification rather than testing.

10. A developer compares a completed program with the features and constraints requested by users without focusing on running test inputs. What activity is being performed?

Algorithm design through computational decomposition
Program documentation through explanatory comments
Program verification against user requirements
Program testing through executed input cases

Program verification against user requirements

Explanation

Verification determines whether the program meets user requirements. Testing differs because it executes the program with inputs to demonstrate correctness.

11. Which description best characterizes a flowchart?

A programming-language representation containing executable syntax
A graphical representation of an algorithm's logic and operation sequence
An informal description written with English-like algorithm statements
A collection of comments explaining how program code can be modified

A graphical representation of an algorithm's logic and operation sequence

Explanation

A flowchart uses graphical elements to represent logic paths and the sequence of operations in an algorithm. Pseudocode conveys the same kind of planning information through informal English-like statements rather than pictures.

12. In a flowchart, which symbol represents a decision that can create different branches of execution?

The rectangular process symbol
The parallelogram input-output symbol
The oval start-and-end symbol
The diamond-like decision symbol

The diamond-like decision symbol

Explanation

The diamond-like symbol represents a decision and therefore supports branching in the flow of control. The oval identifies the start or end, while the parallelogram represents input or output.

13. Which statement correctly describes pseudocode?

It tests whether a program satisfies user requirements during execution
It describes algorithm operations in execution order using informal English-like language
It assigns values and compares conditions using programming syntax
It depicts algorithm paths with standardized graphical symbols and arrows

It describes algorithm operations in execution order using informal English-like language

Explanation

Pseudocode is an informal, abstract description of an algorithm that lists operations in execution order without actual programming syntax. Graphical symbols and arrows characterize flowcharts, not pseudocode.

14. Which statement correctly distinguishes low-level languages from high-level languages?

Low-level languages require interpretation, while high-level languages execute directly on hardware.
Low-level languages are hardware-dependent, while high-level languages are easier to read and more portable.
Low-level languages are written in portable syntax, while high-level languages use binary instructions.fi
Low-level languages are easier to read, while high-level languages depend closely on specific hardware.

Low-level languages are hardware-dependent, while high-level languages are easier to read and more portable.

Explanation

Low-level languages are closely tied to hardware, whereas high-level languages are designed for readability and portability across platforms. The distractor claiming that high-level languages depend closely on hardware reverses the central distinction.

15. Which sequence correctly describes the main stages that transform C source code into an executing program?

Loader, compiler, assembler, preprocessor, linker, and execution
Preprocessor, compiler, assembler, linker, loader, and execution
Compiler, linker, preprocessor, loader, assembler, and execution
Assembler, preprocessor, compiler, execution, linker, and loader

Preprocessor, compiler, assembler, linker, loader, and execution

Explanation

C processing proceeds through preprocessing, compilation, assembly, linking, loading, and execution. The other sequences place these translation and program-loading stages in an incorrect order.

16. How does a compiler differ from an interpreter when translating a program?

A compiler loads programs into memory, while an interpreter connects separately compiled object files.
A compiler translates the whole program before execution, while an interpreter handles instructions line by line.
A compiler executes each instruction as it is read, while an interpreter translates the whole program first.
A compiler converts machine code into source code, while an interpreter converts binary into assembly.

A compiler translates the whole program before execution, while an interpreter handles instructions line by line.

Explanation

A compiler translates the entire source program before it runs, whereas an interpreter translates and executes instructions incrementally. The claim that a compiler processes each instruction during execution describes interpreter behavior instead.

17. What does time complexity measure for an algorithm with input size nn?

The amount of memory reserved for storing input and intermediate results
The physical time needed by a processor regardless of the input size
The number of constant-time execution steps as a function of input size
The number of programming languages required to implement the algorithm

The number of constant-time execution steps as a function of input size

Explanation

Time complexity describes execution time through the number of constant-time steps as input size changes. Memory requirements belong to space complexity, so the memory-focused distractor confuses the two measures.

18. Which expression represents the space complexity when fixed and instance-dependent storage are both considered?

S(p)=ASp(I)S(p) = \frac{A}{S_p(I)}
S(p)=A+Sp(I)S(p) = A + S_p(I)
S(p)=ASp(I)S(p) = A - S_p(I)
S(p)=ASp(I)S(p) = A \cdot S_p(I)

$$S(p) = A + S_p(I)$$

Explanation

Total space consists of fixed space AA plus variable space Sp(I)S_p(I) determined by the problem instance. Multiplication, subtraction, and division do not represent this additive decomposition.

19. Which analysis evaluates the maximum number of operations an algorithm may perform over its possible inputs?

Best-case analysis
Worst-case analysis
Average-case analysis
Amortized storage analysis

Worst-case analysis

Explanation

Worst-case analysis measures the maximum operations required among possible inputs. Best-case analysis measures the minimum, while average-case analysis estimates expected behavior across inputs.

20. A linear search checks an array and finds the target in its first position. What is the search time complexity in this situation?

Θ(n2)\Theta(n^2)
Θ(n)\Theta(n)
Θ(1)\Theta(1)
Θ(logn)\Theta(\log n)

$$\Theta(1)$$

Explanation

When the target is first, linear search performs a constant number of comparisons, giving Θ(1)\Theta(1) best-case complexity. The bound Θ(n)\Theta(n) applies when the target is absent or appears at the final position.

21. What are the exact time cost and asymptotic time bound of a single-loop summation with cost modeled by T(n)=2n+3T(n) = 2n + 3?

Exact cost 2n2+2n+22n^2 + 2n + 2 and asymptotic bound O(n2)O(n^2)
Exact cost n+3n + 3 and asymptotic bound O(1)O(1)
Exact cost 2n3+3n2+2n+22n^3 + 3n^2 + 2n + 2 and asymptotic bound O(n3)O(n^3)
Exact cost 2n+32n + 3 and asymptotic bound O(n)O(n)

Exact cost $$2n + 3$$ and asymptotic bound $$O(n)$$

Explanation

The single-loop summation has the stated exact cost 2n+32n + 3, whose dominant growth is linear, so its asymptotic time is O(n)O(n). The quadratic and cubic expressions belong to matrix addition and matrix multiplication examples, respectively.

22. If matrix addition is performed on two n×nn \times n matrices, which time and space bounds apply?

Time O(n3)O(n^3) and space O(n2)O(n^2)
Time O(n)O(n) and space O(n)O(n)
Time O(n2)O(n^2) and space O(n3)O(n^3)
Time O(n2)O(n^2) and space O(n2)O(n^2)

Time $$O(n^2)$$ and space $$O(n^2)$$

Explanation

Matrix addition processes the entries of an n×nn \times n matrix, producing both time and space bounds of O(n2)O(n^2). Cubic time is associated with the matrix multiplication example, not matrix addition.

23. For matrix multiplication with exact cost T(n)=2n3+3n2+2n+2T(n) = 2n^3 + 3n^2 + 2n + 2, what are its asymptotic time and space bounds?

Time O(n3)O(n^3) and space O(n2)O(n^2)
Time O(n)O(n) and space O(n2)O(n^2)
Time O(n2)O(n^2) and space O(n2)O(n^2)
Time O(n3)O(n^3) and space O(n3)O(n^3)

Time $$O(n^3)$$ and space $$O(n^2)$$

Explanation

The cubic term dominates the exact time expression, giving time complexity O(n3)O(n^3), while the stored matrices require space O(n2)O(n^2). A cubic space bound incorrectly treats the multiplication time growth as memory growth.

Review with flashcards

Memorize the answers with 54 flashcards on Problem Solving and Algorithm Analysis.

Why is a computer called a dumb machine?

It operates strictly according to instructions and cannot perform tasks without software.

What is the first step in the program-development process?

Requirements specification.

Which step follows problem analysis in program development?

Algorithm design.

See flashcards →

Read the study sheet

Read the complete study sheet on Problem Solving and Algorithm Analysis.

See study sheet →

Similar courses

Create your own quizzes

Import your course and AI generates quizzes with corrections in 30 seconds.

Quiz generator