CSS Prepare

optional · CSS study notes

Properties of an Algorithm (2017)

The 5 Essential Properties (Knuth's Criteria)

  1. Input — zero or more well-defined inputs
  2. Output — at least one well-defined output, related to the input
  3. Definiteness — each step must be precisely and unambiguously defined
  4. Finiteness — must terminate after a finite number of steps (distinguishes an algorithm from a general "computational procedure")
  5. Effectiveness — every step must be basic enough to be carried out, in principle, by a person using pencil and paper (i.e., feasible/executable)

Concrete Examples for Each Property

  • Input: a sorting algorithm takes an array as input — but "zero inputs" is also valid (a program that just prints "Hello World" has zero inputs and is still a valid algorithm).
  • Output: a search algorithm outputs the found index or -1 — output MUST relate to the given input, not just print something unrelated.
  • Definiteness: "add a large amount of salt" is NOT definite ("large" is ambiguous); "add exactly 5 grams of salt" IS definite.
  • Finiteness: "keep dividing n by 2 (integer division) until n=0" terminates — finite. "Keep printing the next prime number forever" never terminates — this is an infinite process, not a valid algorithm.
  • Effectiveness: "sort the array using intuition" is not effective (not concretely executable); "compare arr[i] and arr[i+1], swap if out of order" is effective — basic enough to actually carry out step by step.

Self-Test: Spot the Violated Property

  1. "Compute the sum of the series 1+2+3+... continuing forever." — which property is violated? (Answer: Finiteness — never terminates by design.)
  2. An algorithm step says: "Multiply the numbers using an intuitive approach." — which property is violated? (Answer: Definiteness — "intuitive" is ambiguous, not a precise instruction.)
  3. An algorithm step says: "Solve the equation using imagination." — which property is violated? (Answer: Effectiveness — not a basic, concretely executable step.)

Common Confusion

  • A process or program that runs indefinitely (e.g., an OS scheduler loop) is not a pure algorithm by strict definition, since it lacks finiteness — frequently tested distinction

Exam Angle / MCQ Trap

Examiners love asking "which property distinguishes an algorithm from a mere sequence of steps?" — answer: Finiteness (must halt) combined with Definiteness (unambiguous). Memorize all 5 by name, not just concept.

📌 Sample & Repeated FPSC Questions (2016–2026)

FPSC has not directly isolated this exact definitional sub-topic (naming/listing the 5 properties of an algorithm) as a standalone question in the 2016–2026 CS-optional papers — it typically appears folded into a broader "define an algorithm and its properties" question, if asked at all.