A computer is a dumb machine that operates strictly according to instructions and cannot perform useful tasks without software.
The program-development process consists of:
Requirements ā analysis ā design ā implementation ā testing ā documentation
I-O-C-F: Inputs, Outputs, Constraints, Formulas
ā Must-know
Further detail
Algorithm = language-independent logic; program = coded implementation
A top-down algorithm design breaks a process into major steps: get the data, perform computations, and display the result, while requiring correctness, finiteness, and efficiency.
š The factorial algorithm:
Get data ā perform computations ā display result
Translate logic ā map flowchart ā write source code ā test ā release
ā Must-know
Further detail
š A = 10 assigns the value 10 to A, whereas A == 10 tests whether A equals 10.
Flowcharts show logic pictorially; pseudocode describes it in readable text
ā Must-know
š Low-level languages are close to hardware and machine-dependent, whereas high-level languages are easier to read and more portable across platforms.
š A compiler translates the entire source program before execution, whereas an interpreter translates and executes instructions line by line.
Further detail
Machine-level language consists entirely of binary instructions made of 1s and 0s and executes directly on computer hardware without a compiler or interpreter.
Assembly language uses mnemonics such as ADD, SUB, INR, DCR, and CMP and must be translated into machine code by an assembler.
Compiler translates the whole program; interpreter translates line by line
ā Must-know
š Formula ā Space complexity is expressed as , where A is fixed space and is variable space dependent on the problem instance.
Complexity cases measure: minimum operations in the best case, expected behavior across possible inputs in the average case, maximum operations in the worst case
For linear search, the best case has complexity Ī(1) when the item is first, while the worst case has complexity Ī(n) when the item is absent and every element is compared.
Further detail
š Formula ā For adding two n-bit integers, the time requirement is , so computational time grows linearly with input size.
Time and space ā best, average, worst ā asymptotic analysis
š Formula ā For single-loop summation, the exact time cost is and its asymptotic time bound is ; its space bound is also because of the array.
š Formula ā For matrix addition, the exact time cost is and its time and space bounds are both .
š Formula ā For matrix multiplication, the exact time cost is , its time bound is , and its space bound is .
Summation O(n) ā matrix addition O(n²) ā matrix multiplication O(n³)
Compiler and Interpreter
| Dimension | Compiler | Interpreter |
|---|---|---|
| Translation | Translates the entire program before execution | Translates and executes line by line |
| Error detection | After compiling the entire program | Immediately after translating each line |
| Execution speed | Slower analysis but faster execution | Faster analysis but slower execution |
| Intermediate code | Generates object code and needs more memory | Generates no intermediate object code |
Test your knowledge on Problem Solving and Algorithm Analysis with 23 multiple-choice questions with detailed corrections.
1. Why can a computer not produce useful results without software?
2. Which sequence best represents the program-development process?
Memorize the key concepts of Problem Solving and Algorithm Analysis with 54 interactive flashcards.
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.
Import your course and AI generates sheets, quizzes and flashcards in 30 seconds.
Sheet generator