How to Solve 3-Variable K-Maps?

Last Modified:

Layouts of a 3-Input K-Map

In a 3‑input Karnaugh map, one variable is assigned to the rows and the other two to the columns or vice versa, creating a fixed \(\mathsf{2\times{}4}\) or \(\mathsf{4\times{}2}\) matrix of eight cells. The Gray codes themselves serve as the row and column labels, representing the specific combinations of variable values along each axis. This structured labeling is essential for identifying valid groupings during simplification, with each cell corresponding to a unique input combination in the 3‑variable K‑map shown here.

Do we Need to Solve a Given Function in All Possible Layouts of the K-map?

It should be noted that it’s unnecessary to solve the function in every possible K‑map layout — for instance, both the \(\mathsf{2\times{}4}\) and \(\mathsf{4\times{}2}\) arrangements of a 3‑input K‑map. A single correctly applied layout is sufficient, as all valid layouts will produce the same result. In later examples, we’ll demonstrate this equivalence using both shapes, but for the actual solution, using any one form is perfectly acceptable.

Alternative Labeling

In some K-map layouts, the row and column labels are presented not as Gray codes, but directly as complemented and uncomplemented variables. However, Gray code ordering still governs the cell arrangement to preserve adjacency. These variable-based labels may offer a more intuitive bridge between the map and the original Boolean function, and may appeal more to some readers. A 3-variable K-map with alternative labels and input combinations, in both \(\mathsf{2\times{}4}\) and \(\mathsf{4\times{}2}\) forms, is shown here:

this image shows the labeling of the rows and columns of a 3-input k-map using input literals and the corresponding input combinations in each cell
this image shows the labeling of the rows and columns of a 3-input k-map using input literals and the corresponding input combinations in each cell

Minterms in a 3-Variable K-map

In the figures below, each cell is annotated with its corresponding minterm, determined by the input combination specified by the variables’ row and column labels, for both \(\mathsf{2\times{}4}\) and \(\mathsf{4\times{}2}\) forms.

this image shows the minterms placement in a 3-input 2x4 k-map
this image shows the minterms placement in a 3-input 4x2 k-map

Adjacency Discussion

In a 3‑input Karnaugh map (arranged as \(\mathsf{2\times{}4}\) or \(\mathsf{4\times{}2}\)), the Gray‑coded axes wrap, so cells on opposite outer edges are adjacent. Along the 4‑cell dimension, you can form groups of 4 (quads) in a continuous run, or groups of 2 (pairs) that straddle the first and last column (or row). These wrap‑around pairs and quads are valid because adjacent labels differ by exactly one bit, and they yield larger implicants or prime implicants when filled with 1s. The same wrap rule exists in the 2‑input (\(\mathsf{2\times{}2}\)) K‑map: a pair may appear side‑by‑side “in front” or be formed across opposite edges—both are equivalent under Gray adjacency. Remember, group sizes must be powers of two (1, 2, 4, 8), and corners participate via their edge adjacencies.

For the diagrams: highlighting the top and bottom edges in green and the left and right edges in orange, then using double‑headed arrows to show wrap adjacency, correctly communicates that opposite edges can be combined. This notation makes it clear that 1s on those edges may be grouped into larger implicants, even when they appear separated on the flat layout.

this image shows the adjacency of the border minterms in 2x4 3-input k-map
this image shows the adjacency of the border minterms in 4x2 3-input k-map

Example 1: Construct a K-map

Construct a K-map for the function \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,2\right)}\)

this image shows the solution of the given function in 2x4 k-map
this image shows the solution of the given function in 4x2 k-map

Example 2: Construct a K-map

Construct a K-map for the function \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,2\right)}\). \(\mathsf{m_3}\) is a Don’t Care, \(\mathsf{X}\).

this image shows the solution of the given function in 2x4 k-map
this image shows the solution of the given function in 4x2 k-map

How to Solve a K-map?

This section outlines the general procedure for solving a K‑map, illustrated first with a simple 2‑input example. Starting with this basic case ensures that anyone can grasp the core concepts, regardless of which page they begin on. More complex examples—matching the number of inputs featured on the page—are introduced afterwards. To explore specific cases in detail, select the relevant page for 2‑, 3‑, 4‑, or 5‑input K‑maps. For an overall introduction to K‑maps, Gray codes, and minterms ordering, refer to their dedicated pages or sections.

The following steps are followed while solving a K-map.

  1. Identify Implicants: Identify groups of adjacent 1s that can be grouped in powers of 2 (1, 2, 4, 8, …).
  2. Make Prime Implicants: Form largest possible groups that collectively include all the relevant minterms.
  3. Determine the Product Term: For each group, determine the variable(s) that remain constant across it.
  4. Write Minimum Cost Solution: Combine terms using OR to generate the solution in SOP form.

In more precise terms, the process of grouping the largest possible sets of minterms in powers of two is essentially the search for prime implicants among all possible implicants. The resulting Sum of Products (SOP) expression is considered to be in its simplest form when it achieves the minimum cost—typically measured in terms of the fewest possible literals or logic gates required for implementation.

Step 1: Identify Implicants

An implicant is simply a product term that describes one or more specific input combinations where the function’s output is 1. The simplest implicants are the individual minterms. However, implicants aren’t limited to single minterms — by combining adjacent implicants in groups whose sizes are powers of two, we can form larger implicants that cover more minterms while still remaining valid.

We will explain the process with the help of a \(\mathsf{2\times{}2}\) 2-inputk-map for ease. Consider the following K‑map:

this image shows an example for understanding implicants and prime implicants

It contains a total of five implicants as highlighted in the figure. Of these, three are individual minterms, while the other two arise from grouping pairs of adjacent 1’s, \(\mathsf{m_0,m_2}\) and \(\mathsf{m_2,m_3}\), each forming a valid implicant.

this image shows the implicants and prime implicants of the given function

Step 2: Make Prime Implicants

A prime implicant is an implicant that cannot be combined with any other implicant to form a larger valid group. In a K‑map, it represents the largest possible block of 1’s that contains no 0’s. It may or may not cover all the 1’s in the map, and in most cases, multiple prime implicants exist. In the above example, the two implicants which are formed by the groupings of \(\mathsf{m_0\textsf{ & }m_2}\), and \(\mathsf{m_2\textsf{ & }m_3}\), are the prime implicants.

Step 3: Determine the Product Term for Each Prime Implicant

To determine the product term for each prime implicant, identify the variables that remain constant across all 1’s in that group. Iteratively check each variable, and drop any literal that changes within the grouping. The remaining literals — whether in complemented or uncomplemented form — represent the constant variables for that largest valid block.

In the example, for the first prime implicant, covering minterms \(\mathsf{m_0}\) and \(\mathsf{m_2}\), input B is fixed at 0 across both minterms, while A changes from 0 in \(\mathsf{m_0}\) to 1 in \(\mathsf{m_2}\). Since A varies, it is dropped. The constant B = 0 corresponds to the literal \(\mathsf{B’}\).

this image shows the first prime implicant in the discussed example

For the second prime implicant, covering minterms \(\mathsf{m_2}\) and \(\mathsf{m_3}\), A remains fixed at 1 in both cases, while B changes. Thus, A = 1 is retained, giving the product term \(\mathsf{A}\).

this image shows the second prime implicant in the discussed example

Step 4: Write Minimum Cost Solution

Once all essential prime implicants have been selected, the final Boolean expression is obtained by combining their corresponding product terms using the OR operator (\(\mathsf{+}\)). If there are remaining prime implicants that can be included in multiple ways at equal minimal cost, any such combination may be chosen, as all yield functionally equivalent minimal solutions. The simplest function is:

\[\mathsf{Z=A+B’}\]

Example 3: Express in the simplest form \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,2\right)}\)

We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:

\[\mathsf{Z=A’C’}\]

This is obtained by joining the minterms \(\mathsf{m_0}\) and \(\mathsf{m_2}\) around the edge as shown in the picture. Also, note that we get the same result when using the \(\mathsf{4\times{}2}\) k-map but the grouping is more obvious on that as it lies on the front face.

this image shows the largest groupings for the given example
this image shows the largest groupings for the given example

Example 4: Express in the simplest form \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,1,2\right)}\)

We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:

\[\mathsf{Z=A’C’+A’B’}\]

The solution is graphically presented in both layouts for better understanding.

this image shows the largest groupings for the given example
this image shows the largest groupings for the given example

Example 5: Express in the simplest form \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,2\right)}\) with \(\mathsf{X}\) at \(\mathsf{m_1}\)

We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:

\[\mathsf{Z=A’C’}\]

Using \(\mathsf{X}\) as 0 helped us keep the cost to minimum. Treating it as 1 would have added a term with 2 literals. This increases the cost by 6 as 2 gates (1 AND and 1 OR) with 2 inputs each would be added. The solution is graphically presented in both layouts for better understanding.

this image shows the largest groupings for the given example
this image shows the largest groupings for the given example

Example 6: Express in the simplest form \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,2,4,6,7\right)}\) with \(\mathsf{X}\) at \(\mathsf{m_5}\)

A group formed using minterms \(\mathsf{m_0, m_2, m_4,}\) and \(\mathsf{m_6}\) yields the prime implicant \(\mathsf{C’}\), since variable \(\mathsf{C}\) remains fixed at 0 while \(\mathsf{A}\) and \(\mathsf{B}\) vary across the group. By treating the don’t-care, \(\mathsf{X}\) at \(\mathsf{m_5}\) as 1, we can pair it with \(\mathsf{m_7}\) to form a valid group. Upon closer inspection, \(\mathsf{m_5}\) and \(\mathsf{m_7}\) can also be joined with \(\mathsf{m_4}\) and \(\mathsf{m_6}\) to create a larger 4-cell group in which \(\mathsf{A}\) remains constant at 1. This produces the prime implicant \(\mathsf{A}\).

Had we treated the don’t-care at \(\mathsf{m_5}\) as 0, this larger grouping would not have been possible, resulting in a higher-cost expression. This example highlights how strategic use of don’t-cares can lead to more efficient simplification.

Thus, the minimal expression becomes \(\mathsf{Z\left(A,B,C\right)=A+C’}\) with a cost of 3.

The solution is graphically presented in both layouts for better understanding.

this image shows the largest groupings for the given example
this image shows the largest groupings for the given example

Frequently Asked Questions

Do we get different final results by using a different layout of K-maps?

No. It should be noted that it’s unnecessary to solve the function in every possible K‑map layout — for instance, both the \(\mathsf{2\times{}4}\) and \(\mathsf{4\times{}2}\) arrangements of a 3‑input K‑map. A single correctly applied layout is sufficient, as all valid layouts will produce the same result.

Can we take the complement of a function using K-maps?

Yes, we can obtain the complement of a function using K‑maps. Instead of grouping 1s, we carry out the usual K‑map simplification process with the 0s. The largest possible groups of 0s, formed in sizes that are powers of two, will yield the complement of the function in sum‑of‑products form.

Example 7: Express the complement in the simplest form \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,1,2\right)}\)

The zeros at positions
\(\mathsf{m_4,m_5,m_6,}\) and
\(\mathsf{m_7}\) can be grouped into a quad, forming the implicant
\(\mathsf{A}\), since
\(\mathsf{A}\) remains constant across all four minterms. The remaining zero at
\(\mathsf{m_3}\) can be paired with
\(\mathsf{m_7}\) to form a valid group, yielding the implicant
\(\mathsf{BC}\). Therefore, the complement of the function simplifies to:

\[\mathsf{Z’=A+BC}\]

the image shows the process of calculating the complement of a function using k-map
Can we solve a function using maxterms in K-maps?

Yes — the function can also be solved using maxterms in K‑maps. The process mirrors that for minterms, but instead of grouping 1s, we identify the largest possible groupings of 0s. From these, we write the corresponding constant terms in sum form. Each prime implicant equivalent derived in this way is then combined using the AND gate (·) operator.

Example 8: Express in the simplest form using Maxterms \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,1,2\right)}\)

The zeros at positions
\(\mathsf{M_4,M_5,M_6,}\) and
\(\mathsf{M_7}\) can be grouped into a quad, forming the implicant
\(\mathsf{A’}\), since
\(\mathsf{A}\) remains constant at 1 across all four maxterms. The remaining zero at
\(\mathsf{M_3}\) can be paired with
\(\mathsf{M_7}\) to form a valid group, yielding the implicant
\(\mathsf{B’+C’}\). Therefore, the complement of the function simplifies to:
\[\mathsf{Z’=A’\left(B’+C’\right)}\]

the image shows the process of calculating the complement of a function using k-map
Can we take the complement of a function using maxterms in K-maps?

Yes — we can find the complement of a function using maxterms in a K‑map. The approach is the same as the standard maxterm method, but instead of grouping 0s to get the original function, we group the 1s instead. The largest possible groups of 1s, formed in powers of two, give the complement in product‑of‑sums form, with each term representing the constant values across the group.

Example 9: Express the complement in the simplest form using Maxterms \(\mathsf{Z\left(A,B,C\right)=\sum\left(0,1,2\right)}\)

In this case, we have two largest groups of 1s: one formed by combining \(\mathsf{M_0}\) with \(\mathsf{M_1\), and another formed by combining \(\mathsf{M_0}\) with \(\mathsf{M_2}\). In the first group, A and B remain fixed at 0, giving the term A+B. In the second group, A and C stay fixed at 0, giving the term A+C. Since we’re working with maxterms, these terms are combined using the AND operation. Therefore, the complement of the function is:

\[\mathsf{Z’=\left(A+B\right)\left(A+C\right)}\]

This matches the result from the previous example and can also be confirmed directly from the truth table.

this image shows the largest groupings for the given example