Solving 2-Variable and 3-Variable Karnaugh Maps with Worked Examples

Learn 2-variable and 3-variable Karnaugh Maps through worked examples, Gray-code layouts, wrap-around grouping, simplification steps, and common mistakes.

Kalana Sandeep8 min read
Comparison of 2-variable and 3-variable Karnaugh maps with their cell layouts.

Small Karnaugh Maps are a convenient place to learn Boolean grouping, because with only 4 or 8 cells you can check every adjacency by hand. When you begin with a 16-cell grid, it is easy to get lost in visual patterns and miss why terms simplify. In contrast, 2-variable and 3-variable maps are compact enough to solve manually in minutes, yet they introduce every core grouping mechanic: Gray-code indexing, rectangular groups, edge wrap-around, and the exact reason variables drop out of an expression.

If you need a refresher on basic minterm definitions or truth tables before starting, read our introductory guide on what a Karnaugh Map is. Otherwise, let us work through the layouts, calculations, and student traps on 2- and 3-variable grids.

2-Variable K-Map Layout

A 2-variable Boolean function has two inputs, usually written as A and B. Because each variable has two possible states, there are 2² = 4 input combinations, giving minterms m0 through m3.

The map is arranged as a 2×2 grid:

  • Row axis: variable A (values 0 and 1)
  • Column axis: variable B (values 0 and 1)
A \ B01
0m0 (00, A'B')m1 (01, A'B)
1m2 (10, AB')m3 (11, AB)

Each cell holds the output for one specific input combination. For instance, cell (row 1, col 0) corresponds to A=1, B=0, which is minterm m2 (AB').

Because each step along a row or column changes exactly one bit, every cell in a 2×2 map directly touches its logical neighbors on paper.

Worked Example 1 — A 2-Variable Map Where One Variable Disappears

Consider this function:

F(A, B) = Σm(2, 3)

1. Minterms and Filled Map

The function requires 1s at minterms m2 (AB') and m3 (AB):

A \ B01
000
111

2. Group Selection and Variable Behavior

Both 1s sit in the bottom row (A=1), forming a horizontal 2-cell group—a pair. Valid K-Map group sizes must be powers of two (1, 2, 4), so this pair is valid.

Now check what happens across the two cells:

  • Variable A: A=1 in m2 and A=1 in m3. Variable A remains constant.
  • Variable B: B=0 in m2 and B=1 in m3. Variable B toggles.

Because B takes on both states (B' and B) while A stays fixed at 1, B cancels algebraically:

F = AB' + AB = A(B' + B) = A(1) = A

Simplified Term

F = A

A pair of size 2 removes one variable, leaving a single literal.

Worked Example 2 — A Vertical Pair Where A Drops Out

Now look at a vertical pair:

F(A, B) = Σm(0, 2)

A \ B01
010
110

Here, m0 (A'B') and m2 (AB') form a vertical pair in column B=0. Across this column, A changes from 0 to 1 while B stays fixed at 0. The changing variable A drops out, yielding F = B'.

The Diagonal Trap

Diagonal cells do not form a pair. Take m0 (00) and m3 (11):

A \ B01
010
101

They cannot. Look at the coordinates between m0 (00) and m3 (11):

  • A changes from 0 to 1
  • B changes from 0 to 1

Both variables change at once. The Hamming distance is 2 bits. In Boolean algebra:

m0 + m3 = A'B' + AB

Neither variable can factor out; this is an unminimizable XOR/XNOR relationship. Grouping requires a Hamming distance of exactly 1 bit.

On a 2×2 map, opposite edges already touch physically. Column 0 sits directly next to column 1, and row 0 sits directly next to row 1. Edge wrap-around across separated columns only becomes visible when we expand to 3 variables.

Moving from 2 Variables to 3 Variables

Moving from 2 variables to 3 variables (A, B, C) doubles the state space from 4 cells to 8 cells (2³ = 8).

Three key differences emerge:

  1. Grid Shape: The map expands from a 2×2 square into a 2×4 rectangle, with row variable A and column variables BC.
  2. Gray-Code Sequence: The four columns cannot use standard binary ordering (00, 01, 10, 11). They must follow Gray code: 00, 01, 11, 10. Swapping the last two columns ensures adjacent columns differ by only one bit.
  3. Larger Groups: In addition to pairs, you can now form 4-cell quads and an 8-cell octet. A quad eliminates two variables simultaneously, reducing a term to a single literal.
Educational illustration of adjacent cell grouping in 2-variable and 3-variable Karnaugh maps.

A 2-variable map uses 4 cells where pairs eliminate one variable; a 3-variable map expands to 8 cells with Gray-code columns where quads eliminate two variables.

3-Variable K-Map Layout

Using standard convention, A defines the rows and BC defines the columns:

  • Rows: A = 0 (top), A = 1 (bottom)
  • Columns: BC = 00, 01, 11, 10
A \ BC00011110
0m0 (000, A'B'C')m1 (001, A'B'C)m3 (011, A'BC)m2 (010, A'BC')
1m4 (100, AB'C')m5 (101, AB'C)m7 (111, ABC)m6 (110, ABC')

Notice the column order: m3 appears before m2, and m7 appears before m6. If you write 0, 1, 2, 3 across the top row, you are using standard binary. That breaks cell adjacency and invalidates your groupings.

Worked Example 3 — Two Groups Producing a Two-Term Expression

Let us simplify an original 3-variable function that demonstrates how overlapping cells produce a smaller circuit:

F(A, B, C) = Σm(0, 1, 4, 5, 7)

1. Populate the Grid

Place a 1 into cells 0, 1, 4, 5, and 7, with 0 elsewhere:

A \ BC00011110
01100
11110

2. Look for the Largest Groups

Larger groups eliminate more variables, so start by looking for the biggest power-of-two blocks of 1s. Cells m0, m1, m4, and m5 form a 2×2 block of four 1s—a quad.

Examine the variables across these four cells:

  • Row A: The quad covers row A=0 and row A=1. Because A changes, it drops out.
  • Columns BC: The quad covers column 00 (B=0, C=0) and column 01 (B=0, C=1).
    • B stays fixed at 0
    • C toggles from 0 to 1, so it drops out

With both A and C eliminated, this quad simplifies to:

B'

3. Cover the Remaining Cell with Overlap

Only minterm m7 (A=1, BC=11) remains uncovered.

Leaving m7 as an isolated 1-cell group yields the 3-literal term ABC. Instead, look at its neighbors in row A=1. Directly to its left sits m5 (A=1, BC=01), which is already a 1.

Groups are allowed to overlap. Sharing m5 allows us to form the pair {m5, m7}:

  • Both cells lie in row A=1, so A is retained as A.
  • Between columns 01 and 11, variable B changes from 0 to 1 (drops out), while C remains fixed at 1 (retained as C).

This pair simplifies to:

AC

4. Combine the Terms

F = B' + AC

Why Smaller Groups Are Suboptimal

An alternative is to use three separate pairs: {m0, m4}, {m1, m5}, and {m5, m7}. That produces:

F = B'C' + B'C + AC

This is a correct expression for the function, but it has 3 terms and 6 literals, against 2 terms and 3 literals for B' + AC. The quad {m0, m1, m4, m5} covers the cells of the first two pairs in a single term, which is why it wins here.

Be careful not to turn that into a rule of thumb. Enlarging each group as far as the map allows is how you find the prime implicants, but the minimal expression comes from choosing the combination of groups that covers every 1 using the fewest terms and then the fewest literals. That choice is made across the whole map; it is not made by taking the biggest group first and carrying on, and in some functions a large group turns out to be unnecessary. The prime implicants guide shows such a case. For the formal grouping rules, see our guide to Karnaugh Map grouping rules.

Worked Example 4 — A 3-Variable Wrap-Around Case

Wrap-around across the outer edges is one of the most frequently missed steps in manual simplification:

F(A, B, C) = Σm(0, 2, 6)

1. Populate the Grid

A \ BC00011110
01001
10001

Cell m0 sits on the far-left edge in column 00, while cells m2 and m6 sit on the far-right edge in column 10.

2. Recognize Outer Column Adjacency

Compare the column labels for the first and fourth columns:

  • Column 1: BC = 00 (B=0, C=0)
  • Column 4: BC = 10 (B=1, C=0)

Only variable B changes; variable C remains fixed at 0. Because they differ by exactly one bit, the leftmost and rightmost columns are adjacent.

In row A=0, cells m0 and m2 form a valid horizontal wrap-around pair:

  • A = 0 stays constant → retain A'
  • C = 0 stays constant → retain C'
  • B toggles between 0 and 1 → eliminate

This wrap-around pair simplifies to:

A'C'

3. Cover the Remaining Cell

Cell m6 (A=1, BC=10) pairs vertically with m2 (A=0, BC=10) in column 10:

  • A toggles between rows 0 and 1 → eliminate
  • B = 1 stays constant → retain B
  • C = 0 stays constant → retain C'

This pair simplifies to:

BC'

4. Combine the Terms

F = A'C' + BC'

3-variable Karnaugh Map showing wrap-around adjacency between the first and last columns

Columns 00 and 10 differ by only one bit, allowing cells on the outer edges to wrap around into valid pairs; diagonal groupings remain invalid because two bits change.

Diagnosing Realistic Mistakes

  • Leaving m0 as a singleton: Missing the wrap-around leaves m0 isolated, producing F = A'B'C' + BC'. This is unminimized and wastes gate inputs.
  • Diagonal grouping: Trying to connect m0 (000) and m6 (110) diagonally across the grid. Because both A and B change (Hamming distance 2), this is mathematically invalid.

If minterm m4 (100) were also a 1, cells {m0, m2, m4, m6} would merge into a single 4-cell wrap-around quad spanning the outer columns, collapsing to just C'.

What Actually Changes Inside a Group?

Simplification is governed by a consistent rule:

  • If a variable holds the same value across every cell in a group, retain it.
  • If a variable changes value between cells in a group, eliminate it.

Look at the wrap-around pair {m0, m2} from Example 4:

m0:  A = 0,  B = 0,  C = 0   (000)
m2:  A = 0,  B = 1,  C = 0   (010)
----------------------------------
     Same    Diff    Same
      A'     Drop     C'
  • Variable A is 0 in both cells → retain A'
  • Variable B toggles from 0 to 1 → eliminate
  • Variable C is 0 in both cells → retain C'

Because group sizes must be powers of two, variable elimination scales predictably:

  • A singleton (1 cell, 2⁰) eliminates 0 variables
  • A pair (2 cells, 2¹) eliminates 1 variable
  • A quad (4 cells, 2²) eliminates 2 variables
  • An octet (8 cells, 2³) eliminates 3 variables (collapsing the map to 1)

Common Traps on Small K-Maps

Six ways a small K-Map goes wrong:

  1. Using binary order instead of Gray code: Writing columns as 00, 01, 10, 11 instead of 00, 01, 11, 10, which breaks adjacency between columns 2 and 3.
  2. Treating diagonal cells as adjacent: Diagonal cells differ by at least two bits and can never form a pair on their own.
  3. Missing outer column wrap-around: Overlooking the adjacency between column 00 and column 10 in 3-variable maps.
  4. Forming two pairs instead of one quad: Leaving four adjacent 1s as two pairs rather than merging them into a 4-cell quad.
  5. Keeping a changing variable: Retaining a variable in the final product term even though its bit toggled across the group.
  6. Mixing SOP and POS logic: Grouping 1s for one term and 0s for another in the same pass. Use only 1s for Sum-of-Products and only 0s for Product-of-Sums. For details, see our guide on SOP vs POS in Karnaugh Maps, and learn when to incorporate optional cells in our guide to don't-care conditions in Karnaugh Maps.

Check the Result with the Karnaugh Map Solver

Automated solvers provide a fast way to verify manual calculations and confirm that your expression is minimal.

Here is how to check Worked Example 3 (F(A,B,C) = Σm(0, 1, 4, 5, 7)):

  1. Open the Karnaugh Map Solver homepage.
  2. Set the variable selector to 3 Variables.
  3. Confirm the output form is set to SOP.
  4. Click on cells 0, 1, 4, 5, and 7 to toggle them to 1 (or enter 0, 1, 4, 5, 7 into the minterm field).
  5. Review the highlighted grouping: the result map outlines the four-cell group m0, m1, m4, m5 (the term B') and the overlapping pair m5, m7 (the term AC), each in its own colour.
  6. Check the simplified expression:

F = B' + AC

The solver also shows how it reached that result in a step-by-step Quine-McCluskey explanation. It is written as text: it lists the prime implicants it found (here B' and AC), summarises the prime implicant chart and marks which prime implicants are essential, but it does not draw the full Quine-McCluskey table or the chart grid. A gate-level circuit diagram for the simplified expression is shown as well.

2-Variable vs 3-Variable K-Maps at a Glance

Feature2-Variable K-Map3-Variable K-Map
Total Cells4 (2²)8 (2³)
Grid Dimensions2 rows × 2 columns2 rows × 4 columns
Row Variable(s)A (values 0, 1)A (values 0, 1)
Column Variable(s)B (values 0, 1)BC (Gray code: 00, 01, 11, 10)
Largest Non-Trivial GroupQuad (4 cells → output 1)Octet (8 cells → output 1)
Pair SimplificationEliminates 1 variable (leaves 1 literal)Eliminates 1 variable (leaves 2 literals)
Quad SimplificationEliminates 2 variables (leaves constant 1)Eliminates 2 variables (leaves 1 literal)
Wrap-Around AdjacencyCells directly touch on paperLeftmost column (00) wraps to rightmost column (10)
Key Thing to CheckDo not pair m0 with m3: diagonal cells differ in two bitsKeep the columns in Gray-code order, and check the wrap-around between columns 00 and 10

Final Takeaway

Karnaugh Maps are visual tools for algebraic factoring, not arbitrary shape-matching. Every pair or quad you draw exists solely to identify which variables remain constant while others toggle between 0 and 1.

Once you are comfortable with Gray-code column ordering and edge wrap-around on 2-variable and 3-variable maps, scaling up to a 4-variable Karnaugh Map or a 5-variable Karnaugh Map follows the exact same logic across larger grids.

Frequently Asked Questions

How many cells are in a 2-variable and 3-variable K-Map?

A 2-variable K-Map has 4 cells (2² = 4) arranged as a 2×2 grid. A 3-variable K-Map has 8 cells (2³ = 8) arranged as a 2×4 grid.

Why does a 3-variable K-Map use the column order 00, 01, 11, 10?

The columns follow Gray code so that every pair of adjacent columns differs by only one bit. Moving from 01 to 10 would change two bits at once, breaking the adjacency required for Boolean simplification.

Can cells on the left and right edges of a 3-variable K-Map form a group?

Yes. Column 00 and column 10 differ by only one variable (B toggles between 0 and 1 while C remains 0), making the outer edges logically adjacent through horizontal wrap-around.

Why can't diagonal cells be grouped in a Karnaugh Map?

Diagonal cells differ by two or more bits simultaneously. Because no single variable remains constant while another toggles, algebraic cancellation cannot occur.

How many variables does a pair or quad eliminate in a 3-variable map?

In a 3-variable map, a pair (2 cells) eliminates one variable, leaving a 2-literal term. A quad (4 cells) eliminates two variables, leaving a 1-literal term.