Beyond "It Works"
An algorithm is a finite, well-defined sequence of steps that solves a problem or computes a result. A good one is judged on several qualities, and getting the right answer is only the first.
Correctness comes first: the algorithm must produce the right output for every valid input, including the awkward edge cases. An algorithm that is fast but wrong is useless. Correctness is argued, ideally, with a proof or at least clear reasoning about why every case is handled — not just "it passed my tests."
Efficiency is next: how the algorithm's time and space grow with input size, expressed in Big-O. Two correct algorithms can differ by astronomical factors — an method versus an one — so for large inputs efficiency often decides whether a problem is solvable at all.
Clarity and simplicity matter too: a clear algorithm is easier to verify, implement without bugs, and maintain. A subtle, "clever" algorithm that no one can follow is a liability.
An algorithm must also be finite (it terminates) and definite (each step is unambiguous). "Guess the answer" is not an algorithm; "for each item, do this exact thing, then stop" is. Algorithms are usually described in pseudocode — precise enough to reason about, free of any one language's syntax.
Common pitfall: optimizing for speed before establishing correctness. A fast algorithm that gives wrong answers is worthless; a correct-but-slow one at least works. Get it right first, prove or argue why it is correct, and only then make it efficient. Premature optimization of an incorrect method wastes effort on the wrong thing.