Skip to main content

137 docs tagged with "computer-science"

View all tags

A* & Heuristic Search

Dijkstra's algorithm finds the shortest path to every vertex by always expanding the closest

Amortized Analysis

Some structures cannot be made cheap on every single call, but can be made cheap *on average over any

Arrays & Dynamic Arrays

An array is a block of contiguous memory holding equally-sized elements. That one property gives it

Backtracking

Backtracking searches a space of candidate solutions by building them one choice at a time, and

Balanced Trees

A binary search tree is $O(\log n)$ only while it stays short, and nothing in the plain

Big-O Notation

Big-O describes an upper bound on growth. Saying an algorithm is $O(n^2)$ claims that beyond some

Binary Search

Binary search compares the target against the middle element of a sorted array and discards half

Bubble Sort

Bubble sort repeatedly walks the array comparing adjacent pairs and swapping them when they are out

Buses & I/O — Overview

A CPU, RAM, storage, and peripherals are separate physical chips — a bus is the shared electrical

Cache Coherence and MESI

How several caches holding the same line stay consistent, and why two unrelated variables in one line can destroy performance.

Character Encoding

Text is stored as bits too — a character encoding is the mapping between abstract characters

Choosing a Sort

In almost every situation the correct answer is call your language's built-in sort. Those

Combinatorics & Counting

"How many ways" questions tempt a direct answer: generate every arrangement, every selection, every

Common Complexities

In practice you meet perhaps eight growth classes. Recognising which one a piece of code falls into —

Complexity Cheat Sheet

This page is a reference, not a tutorial — each numbered page in this section explains the reasoning

Computer Science

A structured, top-down path through how computers actually work: from a single instruction executing

CPU Caches

A CPU cache is a small amount of fast SRAM that sits between the core and main memory, holding

Cycle Detection

A cycle is a path that leaves a vertex and, by following edges, returns to it. That definition reads

Data Representation

Every value a computer manipulates — an integer, a character, a color, an instruction — is ultimately

Databases — Overview

A database management system (DBMS) exists to store data reliably, query it efficiently, and let

Divide & Conquer

Divide and conquer breaks a problem into independent subproblems of the same kind, solves those

DNS (Domain Name System)

DNS is the Internet's naming system — it translates human-readable names like example.com into the

Dynamic Programming

Dynamic programming applies when a problem has overlapping subproblems — the same sub-computation

Fast & Slow Pointers

A singly-linked list, or anything shaped like one — a permutation's i -> p[i] mapping, a

Filesystems Basics

A raw storage device — HDD or SSD — just exposes a flat array of addressable blocks; it has no

Floating Point: IEEE 754

Floating point is a way to represent a huge range of real numbers — from 1e-300 to 1e300 — in

Graphs

A graph is a set of vertices and a set of edges connecting them. That is nearly no structure

Greedy Algorithms

A greedy algorithm makes the choice that looks best right now and never reconsiders it. When that

Hard Disk Drives (HDDs)

A hard disk drive stores data as magnetized regions on spinning platters, read and written by a

Hash Tables

A hash table turns a key into an array index by running it through a hash function, then reads or

Heapsort

Heapsort is selection sort with a better way of selecting. Selection sort scans

HTTP and HTTPS

HTTP is the request/response protocol underlying the Web and most modern APIs: a client sends a

Insertion Sort

Insertion sort builds the sorted result one element at a time, taking the next element and sliding it

Interrupt Controllers

The hardware between a device asserting a line and a CPU taking an interrupt: PIC, APIC, MSI, and Arm's GIC.

Intervals & Sweep Line

A calendar full of meetings, a set of (start, end) ranges to merge, a question like "how many

KMP & the Z-Algorithm

The naive substring scan tries the pattern at every text position and, on a mismatch, throws away

Linear Search

Linear search examines each element in turn until it finds what it is looking for or runs out. It is

Linked Lists

A linked list stores each element in its own node, together with a pointer to the next one. Nothing

LRU & LFU Caches

A cache with unlimited capacity is just a hash table. The interesting problem

Math & Number Theory

Every algorithm folder so far has assumed arithmetic just works: a hash function combines numbers,

Memory Management

The OS gives every process the illusion of a large, private, contiguous address space, even though

Mergesort

Mergesort splits the array in half, sorts each half recursively, and merges the two sorted halves

Minimum Spanning Trees

Given a connected, undirected, weighted graph, a spanning tree picks exactly V - 1 edges that keep

Monotonic Stack & Queue

"For each element, find the nearest element to the right that is bigger" looks like it needs a nested

Multicore & Parallelism

Making a single CPU core faster (higher clock speed, deeper pipelines, wider superscalar execution)

Network Flow

A flow network is a directed graph where every edge has a capacity, one vertex is a source pumping

NoSQL & the CAP Theorem

Once a database is replicated across multiple machines to survive failures and scale reads, it

NUMA and Memory Topology

When "main memory" stops being one thing: node distance, local versus remote latency, and what interleaving trades away.

NVMe & Storage Interfaces

The physical storage medium (platters, NAND cells) is only half the story — data still has to travel

P, NP & Intractability

Most complexity analysis on this site asks how fast a known algorithm runs. This page asks a

Pipelining

Pipelining overlaps the fetch-decode-execute stages of multiple instructions so that, once the

Primes & Sieves

Testing whether a single number n is prime is a small, self-contained problem: try dividing it by

Processes & Threads

A process is the OS's unit of isolation: a running program with its own private address space,

Quickselect

Finding the k-th smallest element does not require sorting the whole array. Sorting throws away no

Quicksort

Quicksort picks an element as the pivot, rearranges the array so that everything smaller sits to

RAM Fundamentals

"RAM" isn't one technology — it's a family. The RAM that makes up multi-gigabyte main memory

Reading Disassembly

Disassembly is the practical skill this whole section builds toward: given compiled machine code —

Relational Model & SQL

The relational model, introduced by Edgar F. Codd in 1970, represents all data as relations

Scheduling

There are almost always more runnable threads than CPU cores. The scheduler is the kernel

Selection Sort

Selection sort divides the array into a sorted prefix and an unsorted remainder. Each round it scans

Shortest Paths

"Shortest" means fewest edges on an unweighted graph and lowest total weight on a weighted one, and

Sorting Cheat Sheet

This page is a reference, not a tutorial — each algorithm's own page derives the bound it gets here.

Space Complexity

Time complexity answers "how does the work grow?"; space complexity asks the same question about

SSDs & NAND Flash

A solid-state drive has no moving parts — it stores bits as trapped electrical charge in NAND

Stacks & Queues

Stacks and queues are not new storage — they are restrictions on storage. Both hold a sequence,

String Fundamentals

Every algorithm in this folder assumes a cost model for three operations that look free and are

Strings & Text

A string is an array — but three things about it break the assumptions the rest of this section

The Data Link Layer

The data link layer is responsible for moving frames between devices on the same local network

Top-K & Streaming

"Find the k largest" looks like a sorting problem, and sorting solves it — but sorting also computes

Topological Sort

A topological sort orders the vertices of a directed acyclic graph so every edge points forward —

Transactions & ACID

A transaction groups multiple reads/writes into a single logical unit of work. ACID —

Traversal: BFS & DFS

Breadth-first and depth-first search both visit every vertex reachable from a start point, in

Tries (Prefix Trees)

A hash set answers "is this exact string in the set?" and nothing else. It cannot answer "what strings

Virtual Memory & Paging

Every process behaves as if it owns the entire address space and as if its memory is one large,