Algorithm flowchart and pseudocode
The logic of one algorithm, as a flowchart and as pseudocode.
What it explains and when it is useful
A flowchart shows the steps of one algorithm, its decisions and loops, using standard symbols. Pseudocode describes the same logic in structured text that is independent of any programming language.
When to use it: For every significant algorithm in your product. Flowcharts suit branching logic; pseudocode suits longer procedures and loops. Many students give both for the most important algorithm.
Worked example
Illustrative: PracticePal is a fictional project used throughout this guide.
Scroll sideways to see the whole diagram.
Pseudocode
FUNCTION make_booking(student, room, start, loud)
// SC4–SC6: every check must pass before anything is saved
end ← start + 30 minutes
IF NOT valid_slot(start) THEN RETURN "Invalid time"
IF room_blocked(room, start, end) THEN RETURN "Room is blocked"
IF overlapping_bookings(room, start, end) > 0 THEN
RETURN "Slot taken" // the page then offers the waiting list (SC7)
END IF
IF bookings_in_week(student, week_of(start)) ≥ 3 THEN RETURN "Weekly limit reached"
IF loud THEN
FOR EACH n IN neighbours[room] // dictionary: room → set of rooms
IF loud_bookings(n, start, end) > 0 THEN RETURN "Noise clash with " + n
END FOR
END IF
BEGIN IMMEDIATE TRANSACTION // lock first, so two requests cannot both pass
repeat the overlap check
INSERT booking(student, room, start, end, loud, "confirmed")
COMMIT, or ROLLBACK and RETURN "Slot just taken" if the insert fails
RETURN booking
END FUNCTION
overlap rule: booking A overlaps B when A.start < B.end AND B.start < A.endPROCEDURE offer_next(room, slot) // SC7, called when a booking is cancelled or released
entry ← first WAITING entry for (room, slot) ORDER BY joined_at // queue: first in, first out
IF entry = NULL THEN RETURN // nobody waiting: the slot simply becomes free
entry.state ← "offered"; entry.offered_at ← now
send offer to entry.student (link expires in 15 minutes)
END PROCEDURE
PROCEDURE every_5_minutes(now) // run by the scheduler
FOR EACH booking WHERE status = "confirmed" AND start + 10 min < now AND NOT checked_in
booking.status ← "no_show"; offer_next(booking.room, booking.start) // SC8
FOR EACH entry WHERE state = "offered" AND offered_at + 15 min < now
entry.state ← "expired"; offer_next(entry.room, entry.slot) // SC7
END PROCEDURENotation and legend
| Symbol or part | Meaning |
|---|---|
| Rounded terminator | START / END |
| Parallelogram | Input or output |
| Rectangle | Process |
| Diamond | Decision with labelled exits (Yes / No) |
| Arrows | Flow of control |
Design decisions it communicates
A diagram earns marks when you explain the decisions it shows. In PracticePal's documentation these would each be one sentence:
- The cheap checks come first; the transaction comes last so the lock is held briefly.
- Every rejection outputs a reason, which becomes the error message (SC5, SC6).
- The overlap check is repeated inside the lock, which is what prevents double bookings.
Common mistakes
- Copying code into boxes: describe the logic, not the syntax.
- Unlabelled decision exits.
- Drawing the whole program as one flowchart.
- Calling a data flow diagram a flowchart.
Checklist for your own version
Ticks are saved in this browser only, so you can use the list while you draft.