Chapter 01 - Computing and Computers
Chapter 01 - Computing and Computers
Disclaimer: The contents of these slides are taken from various publicly available resources such as books, talks
and lectures. They are being used for the purpose of classroom teaching and academic dissemination only. The
sources are acknowledged wherever possible.
9854
7
XXXXX
• Multiply 5 by 7, obtain 35, add the carry 2, obtain 37, write down 7, carry 3
• Multiply 8 by 7, obtain 56, add the carry 3, obtain 59, write down 9, carry 5
• Multiply 9 by 7, obtain 63, add the carry 5, obtain 68, write down 8, carry 6
• Problem specification
• Input
• 4-digit number
• 1-digit number
• Output
• Product of the given 4-digit number and the 1-digit number
• Solution methodology
• Ordered set of steps to solve the problem using the primitive operations
9854
67
0XXXXX
XXXXX0
XXXXXX
COL100: Introduction to Computer Science (Semester II, 2024-2025) 7
Multiplication Method
• Multiply 9854 by 7, write down the result
• Multiply 9854 by 6, shift the result by one decimal place, and write down the result
• Sum the result obtained in Step 1 and the shifted result obtained in Step 2
• The original problem can be divided into sub-problems which must be solved first.
• The solution to the sub-problems can be obtained using primitive operations and
packaged as a “compound” operation.
• The solution to the original problem can be obtained by combining the compound
operations.
• Combination methods
• specify how the primitive operations can be combined with one another to obtain a
compound operation
• Abstraction methods
• specify how compound operations can be utilized as individual units
• It must utilize the primitive operations of the computing tool and provide a solution in a
finite number of operations.
• It must be unambiguous.
• Soundness: Given any input, does the algorithm output the “correct” solution?
• Efficiency
• Is the algorithm fast/slow (time) or does it take more/less memory (space) in relation
to other possibilities?
• Example
• (5 * 4) * (2 + 3 + 5) = 20 * 10 = 200
• (5 * 4) * (2 + 3 + 5) = (5 * 4 * 2) + (5 * 4 * 3) + (5 * 4 * 5) = 40 + 60 + 100 = 200
• We need to express the algorithm into a form that may be understood by a computer.
• Like English, every programming language has its well-defined vocabulary (primitives)
and its well-defined grammar (syntax).
• Unlike English, a program written in a programming language has only one meaning.
• Example: “Flying planes can be dangerous”
• What would happen if the program’s meaning is not what the programmer intended?
• Programming languages differ in terms of the convenience and facilities they offer even
though they are all equally “powerful” in terms of what they can actually compute.
• Algorithms depend on the computation model, but not on the programming language and
many programming languages have same / similar computational models.
Memory
Arithmetic
Control Unit Logic Unit Input
Accumulator
Output
Processor
Execute Decode
Halt instruction instruction
Arithmetic
Control Unit Logic Unit Input
Accumulator
Output
Processor
COL100: Introduction to Computer Science (Semester II, 2024-2025) 24
Input/Output (I/O) Units
• They handle communication with the outside world.
• linguistic realizations
• hardware realizations
• applications