chapter

    Algorithm Basics and Analysis Notes for Cmi M.sc. and Ph.d. Computer Science

    Algorithm Basics and Analysis notes for CMI M.Sc. and Ph.D. Computer Science: 31 study cards covering concepts, formulas, shortcuts and exam traps, plus solve

    Algorithm Basics and Analysis notes

    The five properties of an algorithm

    Intuition

    The five properties of an algorithm

    An algorithm is a finite sequence of definite, effective instructions that transforms zero or more inputs into at least one output and terminates.

    The problem it solves

    You write instructions to compute . The instructions must end after finitely many steps, each step must be unambiguous, the instructions must accept as input, they must produce the sum as output, and each step must be something you can actually carry out. The analogy to a recipe stops at vagueness: a recipe can say "add salt to taste", but an algorithm cannot tolerate ambiguity.

    The idea made exact

    The five properties are finiteness, definiteness, input, output, and effectiveness. Finiteness means the procedure halts after a bounded number of steps. Definiteness means each step has a single, clear meaning. Input means the procedure accepts zero or more values. Output means the procedure produces at least one value. Effectiveness means each step can be carried out exactly and in finite time by a person using pencil and paper.

    finiteness definiteness input output effectiveness

    Why each property is necessary

    Derivation

    Why each property is necessary

    Each property prevents a specific failure mode in a computational procedure.

    computational procedure five properties
    1. Step 1: without finiteness, the procedure never produces output, so it fails its purpose.prevents infinite execution
    2. Step 2: without definiteness, the same input can lead to different executions, so the result is not reproducible.prevents ambiguity
    3. Step 3: the input property allows zero or more inputs; an algorithm with zero inputs is valid.allows constant algorithms
    4. Step 4: without the output property, the procedure produces nothing, so it is useless.prevents silent execution
    5. Step 5: without effectiveness, a step like "compute the exact value of " cannot be carried out in finite time.prevents uncomputable steps
    Result

    An algorithm must satisfy all five properties to be considered a valid computational procedure.

    CHECK

    The sum algorithm terminates after additions (finiteness), each addition is definite (definiteness), takes as input, outputs the sum, and uses only integer addition (effective).

    Every program is an algorithm

    WRONG BELIEF

    Every program is an algorithm.

    WHY IT FEELS RIGHT

    Programs are written to compute things, and algorithms compute things, so the two concepts seem interchangeable.

    SMALLEST COUNTEREXAMPLE

    The program while true do x := x + 1 never terminates, so it violates finiteness. It runs forever without producing any output.

    COUNTER-RULE

    A program is an algorithm only if it terminates on every input. A program that loops forever is not an algorithm, even if it is syntactically valid.

    HOW IT SHOWS UP IN OPTIONS

    A question lists several programs and asks which are algorithms; the trap is to include a program with an infinite loop and expect you to recognize it as not an algorithm.

    28 more cards in this chapter

    Free preview ends here

    Login to view the complete notes

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Algorithm Basics and Analysis Notes for CMI M.Sc. and Ph.D. Computer Science

    Algorithm Basics and Analysis notes for CMI M.Sc. and Ph.D. Computer Science: 31 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    The five properties of an algorithm

    Intuition

    The five properties of an algorithm

    An algorithm is a finite sequence of definite, effective instructions that transforms zero or more inputs into at least one output and terminates.

    The problem it solves

    You write instructions to compute . The instructions must end after finitely many steps, each step must be unambiguous, the instructions must accept as input, they must produce the sum as output, and each step must be something you can actually carry out. The analogy to a recipe stops at vagueness: a recipe can say "add salt to taste", but an algorithm cannot tolerate ambiguity.

    The idea made exact

    The five properties are finiteness, definiteness, input, output, and effectiveness. Finiteness means the procedure halts after a bounded number of steps. Definiteness means each step has a single, clear meaning. Input means the procedure accepts zero or more values. Output means the procedure produces at least one value. Effectiveness means each step can be carried out exactly and in finite time by a person using pencil and paper.

    finiteness definiteness input output effectiveness

    Why each property is necessary

    Derivation

    Why each property is necessary

    Each property prevents a specific failure mode in a computational procedure.

    computational procedure five properties
    1. Step 1: without finiteness, the procedure never produces output, so it fails its purpose.prevents infinite execution
    2. Step 2: without definiteness, the same input can lead to different executions, so the result is not reproducible.prevents ambiguity
    3. Step 3: the input property allows zero or more inputs; an algorithm with zero inputs is valid.allows constant algorithms
    4. Step 4: without the output property, the procedure produces nothing, so it is useless.prevents silent execution
    5. Step 5: without effectiveness, a step like "compute the exact value of " cannot be carried out in finite time.prevents uncomputable steps
    Result

    An algorithm must satisfy all five properties to be considered a valid computational procedure.

    CHECK

    The sum algorithm terminates after additions (finiteness), each addition is definite (definiteness), takes as input, outputs the sum, and uses only integer addition (effective).

    Every program is an algorithm

    WRONG BELIEF

    Every program is an algorithm.

    WHY IT FEELS RIGHT

    Programs are written to compute things, and algorithms compute things, so the two concepts seem interchangeable.

    SMALLEST COUNTEREXAMPLE

    The program while true do x := x + 1 never terminates, so it violates finiteness. It runs forever without producing any output.

    COUNTER-RULE

    A program is an algorithm only if it terminates on every input. A program that loops forever is not an algorithm, even if it is syntactically valid.

    HOW IT SHOWS UP IN OPTIONS

    A question lists several programs and asks which are algorithms; the trap is to include a program with an infinite loop and expect you to recognize it as not an algorithm.

    An algorithm must have input

    WRONG BELIEF

    An algorithm must have at least one input.

    WHY IT FEELS RIGHT

    Most algorithms take parameters, so it feels like input is required.

    SMALLEST COUNTEREXAMPLE

    The algorithm "output 42" has zero inputs and one output. It terminates in one step, is definite, effective, and produces output. It satisfies all five properties despite having no input.

    COUNTER-RULE

    An algorithm may have zero or more inputs; the requirement is that it produces at least one output. The asymmetry is intentional: an algorithm without output is useless, but an algorithm without input can still compute a constant or a fixed sequence.

    HOW IT SHOWS UP IN OPTIONS

    A question asks which properties are necessary for an algorithm, and "must have input" is offered as a tempting choice alongside "must have output".

    More notes in this unit