DNA is written with four bases that pair A–T and G–C, so one strand determines the other.

highlighted = computed this step

The four DNA bases

DNA is written with 4 bases: A, C, G, and T. Each base pairs with exactly one partner — A with T, and G with C — so one strand fixes the other.

AT,GC\text{A} \leftrightarrow \text{T}, \quad \text{G} \leftrightarrow \text{C}
Base pairingEach DNA base sits above its complementary partner.strandATGCpartnerTACG

Complementing twice returns the original

Replacing every base by its partner is its own inverse: do it twice and the original strand comes back. The bottom row here is the partner of the partner, and it matches the top row.

comp(comp(s))=s\operatorname{comp}(\operatorname{comp}(s)) = s
Complement twiceComplementing the partner strand returns the original.strandATGCpartnerTACGpartner againATGC

The reverse complement

The two strands run in opposite directions (antiparallel). The partner of the strand is its per-base complement; read that partner backwards and you get the reverse complement, here TTATTTGCATGCCAT. Honesty note: this is the Watson–Crick pairing idealization — real DNA also has modified bases and occasional mismatches.

revcomp(strand)=TTATTTGCATGCCAT\operatorname{revcomp}(\text{strand}) = \text{TTATTTGCATGCCAT}
A strand and its partnerThe partner strand is the per-base complement; reading it backwards gives the reverse complement.strandATGGCATGCAAATAApartnerTACCGTACGTTTATT