Algorithmic Problem-Solving Guides: Efficiency Awareness Without Big-O Notation (Copy)
Efficiency Awareness Without Big-O Notation
What “Efficiency Awareness” Means At AS Level
- You are NOT expected to use:
- Big-O notation
- Formal time complexity symbols
- You ARE expected to:
- Recognise slow vs fast algorithms
- Reduce unnecessary operations
- Choose sensible loops and logic
- Examiners test efficiency by:
- Asking you to improve algorithms
- Comparing two approaches
- Penalising wasteful logic
Core Examiner Rule (Very Important)
- Efficiency is judged by:
- Number of operations
- Number of repetitions
- Unnecessary processing
- Not by mathematical notation
How Examiners Informally Judge Efficiency
Examiners look for answers like:
- “This algorithm repeats unnecessary comparisons”
- “This loop runs more times than required”
- “The algorithm could stop earlier”
- “The same calculation is done repeatedly”
The Three Efficiency Dimensions You Must Understand
| Dimension | Meaning |
|---|---|
| Time efficiency | How many steps are executed |
| Loop efficiency | How many times loops repeat |
| Logical efficiency | Whether work is repeated unnecessarily |
Efficiency Principle 1: Avoid Unnecessary Repetition
Inefficient Logic
FOR i ← 1 TO 100
OUTPUT "Hello"
NEXT i
- Always runs 100 times
- Even if only one output needed
Efficient Logic
OUTPUT "Hello"
- Same result
- Far fewer steps
Efficiency Principle 2: Stop As Soon As The Goal Is Achieved
Inefficient Search
found ← FALSE
FOR i ← 1 TO 20
INPUT num
IF num = 7 THEN
found ← TRUE
ENDIF
NEXT i
- Continues even after value found
Efficient Search (Early Termination)
found ← FALSE
i ← 1
WHILE i <= 20 AND found = FALSE DO
INPUT num
IF num = 7 THEN
found ← TRUE
ELSE
i ← i + 1
ENDIF
ENDWHILE
- Stops immediately when found
- Fewer comparisons
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Efficiency Principle 3: Use The Correct Loop Type
Inefficient Loop Choice
FOR i ← 1 TO 100
INPUT num
IF num = -1 THEN
EXIT LOOP
ENDIF
NEXT i
- FOR loop assumes fixed repetitions
- Exit used awkwardly
Efficient Loop Choice
REPEAT
INPUT num
UNTIL num = -1
- Loop matches the problem logic
- Cleaner and more efficient
Efficiency Principle 4: Avoid Recalculating The Same Value
Inefficient Code
FOR i ← 1 TO 10
average ← total / 10
NEXT i
- Same calculation repeated 10 times
Efficient Code
average ← total / 10
- Calculation done once
Efficiency Principle 5: Combine Conditions Where Possible
Inefficient Conditional Logic
IF mark >= 50 THEN
passCount ← passCount + 1
ENDIF
IF mark >= 80 THEN
distinctionCount ← distinctionCount + 1
ENDIF
- Two checks every time
More Efficient Logic
IF mark >= 80 THEN
distinctionCount ← distinctionCount + 1
passCount ← passCount + 1
ELSEIF mark >= 50 THEN
passCount ← passCount + 1
ENDIF
- Fewer comparisons
- Clear priority logic
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Efficiency Principle 6: Do Not Use Arrays Unless Needed
Inefficient Use Of Array
DECLARE nums : ARRAY[1..10] OF INTEGER
FOR i ← 1 TO 10
INPUT nums[i]
NEXT i
FOR i ← 1 TO 10
sum ← sum + nums[i]
NEXT i
- Two loops
- Extra storage
Efficient One-Pass Solution
sum ← 0
FOR i ← 1 TO 10
INPUT num
sum ← sum + num
NEXT i
- One loop
- No array needed
Efficiency Principle 7: Reduce Nested Loops Where Possible
Inefficient Nested Loop
FOR i ← 1 TO 10
FOR j ← 1 TO 10
OUTPUT i, j
NEXT j
NEXT i
- 100 iterations
- Acceptable only if truly required
Examiner Expectation
- Nested loops are not wrong
- They are inefficient unless necessary
Efficiency Principle 8: Validate Input Efficiently
Inefficient Validation
WHILE num < 1 DO
INPUT num
ENDWHILE
WHILE num > 100 DO
INPUT num
ENDWHILE
- Two loops
- Confusing logic
Efficient Validation
REPEAT
INPUT num
UNTIL num >= 1 AND num <= 100
- One loop
- One condition
- Clear intent
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
How Efficiency Is Tested In Exams
Common Question Styles
- “Explain why this algorithm is inefficient”
- “Suggest one improvement”
- “Rewrite the algorithm to be more efficient”
- “Compare the two algorithms”
Examiner-Friendly Efficiency Language (Use These Phrases)
- “The algorithm performs unnecessary repetitions”
- “The loop continues even after the result is known”
- “The same calculation is repeated multiple times”
- “The algorithm could terminate earlier”
- “This reduces the number of comparisons”
Common Efficiency Mistakes By Students
- Using arrays unnecessarily
- Not stopping loops early
- Repeating calculations
- Using nested loops without reason
- Writing code that works but wastes steps
Efficiency Comparison Example
Version A
FOR i ← 1 TO 20
IF nums[i] = target THEN
found ← TRUE
ENDIF
NEXT i
Version B
found ← FALSE
i ← 1
WHILE i <= 20 AND found = FALSE DO
IF nums[i] = target THEN
found ← TRUE
ELSE
i ← i + 1
ENDIF
ENDWHILE
Examiner View
- Version B is more efficient
- Stops early
- Performs fewer checks
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Efficiency Checklist (Memorise This)
- Can the loop stop earlier?
- Is any calculation repeated?
- Is an array really required?
- Are conditions combined logically?
- Is the simplest loop used?
Exam-Ready Efficiency Template
When asked to improve efficiency:
- Identify waste
- Explain why it is wasteful
- Show a simpler alternative
One-Line Rules To Memorise
- Working code can still be inefficient
- Fewer steps = better efficiency
- Stop when the goal is reached
- Don’t store what you don’t need
- Simplicity wins marks
