0% found this document useful (0 votes)
24 views6 pages

IGCSE Computer Science Revision Notes

Uploaded by

Zephy Tron
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

IGCSE Computer Science Revision Notes

Uploaded by

Zephy Tron
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

IGCSE Computer Science Detailed Revision Notes

(Chapters 7 & 8)

Chapter 7 – Algorithm Design & Problem Solving


Program Development Life Cycle (PDLC):
1. Analysis – Define the problem, inputs, outputs, processing requirements.
2. Design – Plan algorithms with pseudocode, flowcharts, structure diagrams.
3. Coding – Translate design into a programming language.
4. Testing – Ensure program works with different test data.
5. Maintenance – Correct errors, update to meet new requirements.
Decomposition:
• Large problems are divided into smaller, manageable sub-problems.
• Each sub-problem can be solved separately and combined later.
Algorithms:
• Written in pseudocode or shown using flowcharts.
• Must be unambiguous, clear, and step-by-step.
• Standard methods of solution include:
– Totalling values in a list.
– Counting items that match a condition.
– Finding maximum, minimum, average.
– Searching (linear search).
– Sorting (bubble sort).
Validation vs Verification:
• Validation – ensures data entered is reasonable:
– Range check, Type check, Length check, Format check, Presence check.
• Verification – ensures data entered correctly:
– Double entry, Visual check.
Test Data Types:
• Normal data – typical input expected in normal use.
• Boundary data – values at the extreme ends of allowed range.
• Abnormal data – invalid data used to test rejection of inputs.
Trace Tables & Dry Runs:
• Trace tables track values of variables step-by-step in algorithms.
• Dry runs are manual simulations of code execution to detect logic errors.
Types of Errors:
• Syntax errors – violate rules of programming language.
• Logic errors – program runs but gives incorrect output.
• Runtime errors – occur while program is running (e.g., divide by zero).
Good Algorithm Design:
• Use meaningful variable names.
• Break problem into smaller steps (modular design).
• Always test with normal, boundary, and abnormal data.
• Correct and refine algorithms after testing.
Chapter 8 – Programming
Basic Concepts:
• Variables – storage locations that can change value.
• Constants – fixed values that cannot change.
• Input and Output – INPUT (user data), OUTPUT/PRINT (display results).
Control Structures:
• Sequence – instructions executed one after the other.
• Selection – decisions using IF…THEN…ELSE, nested IFs, CASE statements.
• Iteration – repetition of instructions:
– FOR loops: fixed number of repetitions.
– WHILE loops: repeat while condition true.
– REPEAT UNTIL loops: run until condition true.
Operators:
• Arithmetic: +, -, *, /, MOD (remainder), DIV (integer division).
• Relational: >, <, >=, <=, =, ≠ .
• Logical: AND, OR, NOT (used in conditions).
String Handling:
• Concatenation – join strings together.
• Length – number of characters in a string.
• Substring – extract part of a string.
• Useful for processing usernames, passwords, text data.
Procedures and Functions:
• Procedure – performs a task, no return value.
• Function – performs a task and returns a value.
• Parameters – values passed into subroutines.
• Local variables – exist only inside subroutine.
• Global variables – can be accessed throughout program.
Arrays:
• 1D Array – list of elements (e.g., numbers[10]).
• 2D Array – table or matrix (e.g., marks[5][5]).
• Use indexes to access elements.
• Often used with loops to process multiple values.
File Handling:
• OPEN file (READ or WRITE).
• READ data line by line.
• WRITE data into file.
• CLOSE file after use.
• Essential for storing permanent data.
Good Programming Practice:
• Indent code for readability.
• Add comments to explain logic.
• Use meaningful variable and function names.
• Break code into subroutines to reduce complexity.
Pseudocode Examples
Totalling
total ← 0
FOR counter ← 1 TO 5
INPUT number
total ← total + number
NEXT counter
OUTPUT total

Counting
count ← 0
FOR counter ← 1 TO 10
INPUT mark
IF mark >= 50 THEN
count ← count + 1
ENDIF
NEXT counter
OUTPUT count

Find Max/Min
INPUT firstNumber
max ← firstNumber
min ← firstNumber
FOR counter ← 2 TO 10
INPUT number
IF number > max THEN
max ← number
ENDIF
IF number < min THEN
min ← number
ENDIF
NEXT counter
OUTPUT "Max = ", max
OUTPUT "Min = ", min

Linear Search
found ← FALSE
index ← 0
INPUT searchItem
WHILE index < arrayLength AND found = FALSE
IF array[index] = searchItem THEN
found ← TRUE
ELSE
index ← index + 1
ENDIF
ENDWHILE
IF found = TRUE THEN
OUTPUT "Item found at position ", index
ELSE
OUTPUT "Item not found"
ENDIF

Bubble Sort
FOR pass ← 1 TO arrayLength - 1
FOR index ← 0 TO arrayLength - 2
IF array[index] > array[index+1] THEN
temp ← array[index]
array[index] ← array[index+1]
array[index+1] ← temp
ENDIF
NEXT index
NEXT pass

IF / ELSE
INPUT age
IF age >= 18 THEN
OUTPUT "Adult"
ELSE
OUTPUT "Not Adult"
ENDIF

WHILE Loop
count ← 0
WHILE count < 5
OUTPUT "Hello"
count ← count + 1
ENDWHILE

REPEAT…UNTIL
REPEAT
INPUT number
UNTIL number >= 0

FOR Loop
FOR counter ← 1 TO 10
OUTPUT counter
NEXT counter

Procedure
PROCEDURE greet(name)
OUTPUT "Hello ", name
ENDPROCEDURE
CALL greet("Ali")

Function
FUNCTION square(number)
RETURN number * number
ENDFUNCTION
result ← square(5)
OUTPUT result

1D Array
FOR index ← 0 TO 4
INPUT names[index]
NEXT index
FOR index ← 0 TO 4
OUTPUT names[index]
NEXT index
2D Array
FOR row ← 0 TO 2
FOR col ← 0 TO 2
INPUT marks[row][col]
NEXT col
NEXT row

File Write
OPENFILE "[Link]" FOR WRITE
FOR i ← 1 TO 5
INPUT item
WRITEFILE "[Link]", item
NEXT i
CLOSEFILE "[Link]

File Read
OPENFILE "[Link]" FOR READ
WHILE NOT EOF("[Link]")
READFILE "[Link]", item
OUTPUT item
ENDWHILE
CLOSEFILE "[Link]
Trace Table Example
Algorithm (Average of 3 numbers):
count ← 0
total ← 0
FOR i ← 1 TO 3
INPUT number
total ← total + number
count ← count + 1
NEXT i
average ← total / count
OUTPUT average

Trace Table (inputs: 4, 6, 8)


i number total count
1 4 4 1
2 6 10 2
3 8 18 3

average = 18 / 3 = 6
OUTPUT = 6

You might also like