What is an algorithm?
AnswerA finite sequence of well-defined steps to solve a problem
An algorithm is a precise, step-by-step procedure that takes input and produces a result.
Coding · Facts & stats
7 fact-checked facts about algorithms, each with the reason behind it. 5 more are in today's round and join this page after it closes.
AnswerA finite sequence of well-defined steps to solve a problem
An algorithm is a precise, step-by-step procedure that takes input and produces a result.
AnswerHow running time or memory grows with input size
Big O notation expresses how an algorithm's cost scales as the input grows.
AnswerO(log n)
Each step of binary search halves the remaining items, giving logarithmic time.
AnswerO(n²)
Bubble sort may compare and swap neighbors across the list many times, giving quadratic time.
AnswerShortest paths in a graph with non-negative edge weights
Dijkstra's algorithm finds the shortest paths from a starting node when edge weights are not negative.
AnswerA queue
BFS visits nodes in order of distance using a first-in, first-out queue; depth-first search uses a stack.
AnswerO(n²)
Quicksort averages O(n log n), but consistently bad pivot choices degrade it to O(n²).