Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem
Computer Science1 course

Algorithms

Searching, sorting, recursion and Big-O analysis.

About Algorithms

Algorithms is the study of procedures for solving problems efficiently and of proving that they are correct. A first course covers searching and sorting, recursion, divide and conquer, greedy methods, dynamic programming and graph algorithms such as breadth-first search and shortest paths.

Analysis is as important as design. Binary search halves the range each step, so it needs about log⁡2n\log_2 n comparisons; merge sort runs in O(nlog⁡n)O(n \log n) while insertion sort is O(n2)O(n^2) in the worst case. Recurrences such as T(n)=2T(n/2)+nT(n) = 2T(n/2) + n describe divide-and-conquer running times.

Algorithms power search engines, navigation apps, recommendation systems, compression, scheduling and logistics. Knowing the standard techniques lets you recognise when a problem is a known one in disguise, which is often the fastest route to an efficient solution.

Algorithms

Designing and analyzing algorithms. (College)

Big-O Notation

Big-O notation describes how an algorithm's running time or memory grows as the input size nn grows, ignoring constant factors and lower-order terms. An algorithm that takes 3n2+5n+23n^2 + 5n + 2 steps is O(n2)O(n^2), because for large nn the n2n^2 term dominates everything else.

Searching and Sorting

Searching finds an item in a collection. Linear search checks each element in turn and works on any list in O(n)O(n) time. Binary search works only on sorted data: it checks the middle element and discards half the list each step, finding any item among a million in about 20 comparisons.

Recursion

A recursive function solves a problem by calling itself on a smaller version of the same problem. Every recursive function needs a base case that is answered directly and a recursive case that moves toward it. Factorial is the classic example: n!=n×(n−1)!n! = n \times (n - 1)!, with 0!=10! = 1 as the base case.

Full Algorithms course outline

How to study Algorithms

  • Run each algorithm by hand on a small input and record every step.
  • State an invariant, a fact that stays true on every loop iteration, to explain why the algorithm is correct.
  • For dynamic programming, define the subproblem in words before writing the recurrence.
  • Compare growth rates numerically, for example n2n^2 against nlog⁡nn \log n at n=106n = 10^6.
Before you start
Programming, data structures and discrete mathematics.
Where it leads
Advanced algorithms, machine learning or competitive programming. The same techniques also appear in operations research, bioinformatics and in most technical interviews for software engineering roles.

Key terms in Algorithms

Binary search
Finding a value in a sorted list by halving the search range each step, which takes O(log⁡n)O(\log n) comparisons.
Merge sort
Divide the list in half, sort each half recursively, then merge; it always runs in O(nlog⁡n)O(n \log n) time.
Greedy algorithm
One that makes the best-looking local choice at each step; it is fast but correct only when a proof shows local choices are safe.
Dynamic programming
Solving a problem by combining stored answers to overlapping subproblems instead of recomputing them.
Recurrence
An equation like T(n)=2T(n/2)+nT(n) = 2T(n/2) + n that describes a recursive algorithm's cost and can be solved for its growth rate.
Graph traversal
Visiting every reachable vertex, either breadth first with a queue or depth first with a stack or recursion.

More in Computer Science