consider the truth table shown on the screen how can we take the data in its truth table and write a function using the variables a b and c enter carnot maps the karnaugh map will be very helpful for us to write a function that describes this truth table so we have three variables so we need a three variable karnaugh map with eight squares now the eight squares will match the eight different input possibilities that we have here so this is just one of the two ways in which we can draw a three variable cardinal map so we're going to have two rows and four columns so on top i'm going to put for the inputs a b on the bottom c so now the inputs a b it could be 0 0 0 1 1 1 and 1 0. now the input for c is only 0 or 1. now the values that we're going to put inside the square are the function values that we see here so for this first square a b is 0 and c is 0 which corresponds to a function value of 0. now for the next one a b is still zero which means we're dealing with this column and c is one so we're dealing with this particular square the function value for that is still zero now for the third row we can see that a b is 0 1 and c is 0 and the function value is 1 so we're going to put a 1 for that square now for the next one a b is still 0 1 and c is 1. so here's where a b is 0 1 and c is 1 giving us this square which the function value is 0. next a b is 1 0 so we're dealing with the last column and c is zero so the function value is one now for this one a b is one zero still c is one and the function value is one next we have a b is one one so that's the third column c is zero and the function value is one and for the last one the function value is zero where a b and c is one so that's how we can take the data in a truth table and put it on a karnaugh map or for short we could say k map now how can we take this data and turn it into a function what we need to do is basically circle groups of ones together we can circle one one or we could circle two ones but we cannot circle three once the number of ones that you can circle could be one two four eight and so forth it has to be a power of two so you can't circle three ones five ones six ones not gonna work so the best thing we can do is circle two groups or two pairs of ones let me use a different color so you can see it so let's start with this one now what type of what information can we derive from that group of ones those two ones highlighted do they depend on the input a notice that the input a varies between 0 and 1 yet the output is the same so the output for those two ones does it depend on a notice that it depends on b when b is one the output is one so we're looking for the variable that doesn't change b doesn't change so should we write b or not b because b is one and the output is one we're gonna write b now these two or this pair of ones also corresponds to a c value of zero notice that c is always zero for that pair of ones so because z c is zero and the output is one we need to write not c now let's move on to the next pair of ones so let's put an or symbol represented by the plus sign so for the second pair of ones what variables do not change so notice that c changes so for this pair of ones it is independent of c but notice that a b is the same a is one b is zero so which one is going to be not a is it air b so because a is one and it matches the output function one we're going to leave it as a but because b is zero we need to put not b because not zero is one so this is the function that explains this truth table now we could test it out so let's see if a is zero and if b is one and if c is one if we get a function value of zero so b is one c is one a is zero and b is one so if we put if we write the complement of one that's going to be zero so we have zero times one which is zero and zero times zero is zero so we get an output of zero so that worked let's try another one let's try this one let's see if the function will give us the correct output so b is zero c is one a is one and b is zero now the complement of one is zero and the complement of zero is one zero times zero is zero one times one is one zero plus one is one so we get the right output now for the sake of practice let's make sure that we have the right function let's try the last one so b is one c is one a is one and b is one as well so the complement of one is zero and one times zero is zero zero plus zero is zero and we can see that we have the correct output so we have the correct function so that's how you could use a karnaugh map to quickly write a function that corresponds to a truth table now let's take the function that we have and turn it into a circuit diagram so the function that we have was b times the complement of c plus a times the complement of b so we can write that as b c prime plus a b prime so we need an and gate to connect b and c prime so let's start with that and we need another and gate to connect a and b prime so this is going to be b and c prime and here we have a and b prime now notice that we have a plus symbol between these two terms so we need to use an or gate the plus symbol is associated with the or operation so the output of this and gate is going to be b c prime and the output of this and gate is going to be a b prime and the output of the or gate is going to give us the function f which is what we have here so that's the circuit diagram that corresponds to this function let's try another example let's use this truth table to create a k-map and then use that to write a function which will then use that to turn it into a circuit diagram if you want to pause the video and try this problem feel free now the type of k-met that i'm going to draw is going to be a little bit different than the last one the last one was a three variable k-map drawn in the horizontal direction but i'm going to draw one with a vertical orientation so instead of having two rows four columns i'm going to have two columns and four rows so i'm going to put one variable above the diagonal line two variables below it so a has two possibilities zero or one bc can be zero zero zero one one one or one zero so that's how you can draw a three variable k map with vertical orientation now let's fill in a table so for this first column a is zero which we can see it for the first four inputs so here when b is when b and c is zero the function is going to be zero and when bc is 0 1 the function is going to be 1. when bc is 1 0 the function is 0 and when bc is 1 the function is 1. now for the second column a is always one which will correspond to these four so when bc is zero the function is one and when bc is zero one the function is also one when bc is one zero the function is one and when bc is one one the function is zero so that's how we can quickly fill out this k-map now how can we use it to write a function for the truth table so let's start with this pair of ones notice that a is always zero so we need to write the complement of a because the complement of zero will give us an output of one now for those pair of ones notice that b changes so the output is independent of b so we're not going to include b but notice that c is one so we're just going to write c now let's draw the next pair of ones so notice that a is always one for that group and this time c changes so it's independent of c but b is consistent b is always zero so we're going to write b prime now there's only one last one that we need to consider and that's here so a is one we're just gonna write a b is one we're gonna write b and because c is zero we're gonna write c prime so this is the function that corresponds to this truth table now let's test the function to make sure that we do indeed have the right one so let's start with what we have here so a is zero c is a zero a is still zero b prime b is one and then we have a b c prime so a is zero b is one c is zero the complement of zero is one the complement of one is zero and the complement of zero is one one times zero is zero zero times zero is zero and zero times one is also zero so this adds up to zero which we can see that's the case now let's try one more let's try this one where a b and c is a one so we have the complement of one times one plus one times the complement of one plus one times one times the complement of one the complement of one is a zero so automatically zero times one is zero one times zero is still zero and the last one is going to be zero so the output is once again zero okay let's try one that's gonna give us a value of one let's try this one so a is one c is one b is zero and a is one b is zero c is one so the complement of one is zero the complement of zero is one and the complement of one is zero zero times one is zero one times one is one one times zero times zero is zero zero plus one plus zero is one so this function works so now you know how to write a function using the k-map but now let's turn this function into a circuit diagram let's draw the logic circuit that corresponds this function so let's start with the first term that we have so we need an and gate so it's going to be a prime c and the output will be a prime c now for the second and gate the input will be a and the second input is going to be b prime giving us the output a b prime now for the last one i'm going to use a three input and gate so the three inputs will be a b and c prime now we need a three input or gate so then this will give us the output function f and so that's how you can draw the logic circuit for this particular function consider the four variable k map that we have on the screen go ahead and write a function for this k-map feel free to pause the video so first let's begin by analyzing those two pair of ones so notice that a and b is always one for that selection so we have a and b and for that selection notice that c is always zero but d changes so it depends on c but not d so we have a b and since c is zero we're gonna have c prime now let's select another pair of ones so let's go with that now notice that a is always zero so we're gonna have a prime b changes so it's gonna be independent of b now c is always one and d is always zero so we're going to write d prime now let's select this pair of ones that we have there so a is always one and b is always zero so let's write b prime for for that part now notice that c changes with the numbers zero and one but d remains the same d is always one so this is going to be a b prime d so this is the function that corresponds to this particular four variable k map let's try another example go ahead and try this one so instead of selecting two ones we can select a group of four ones so for that particular group which variables remain the same notice that a is always 0 and b is always 0. so we're going to have a prime and b prime now c can be 0 or 1 so it's independent of c and d can also be zero or one so it's only going to depend on a and b for that first selection now the next selection we can basically take a square of ones so which variables are constant notice that a is always one so we're going to write a b changes between one and zero so it's independent of b on this side notice that d is always one so it's going to depend on d c changes so it's independent of c so this particular function is represented by this equation it's a prime b prime plus a d so now you know how to take the information from a four variable k map and turn it into a function now let's say that we're given a function ac plus a b prime so how can we take this function and create a three variable k map and let's create it in the horizontal direction so we're gonna need two rows and four columns so we're gonna put a b above the diagonal line and c below it so a b can be 0 0 0 1 1 1 or 1 0 and c could be 0 or 1. now let's focus on the ac term notice that we don't have any compliments here so we're looking for when a is one and when c is one c is one anywhere in this row a is one here so what we're going to do is we're going to put a 1 in those boxes now let's focus on the next term a b prime so we just have a we're going to put one we have the complement of b so we're going to write zero so let's identify where a is one and b is zero so this is when a is one and b is zero so anywhere in this region so we need to fill this row with a one and we have an overlapping one there now every other box we're going to put a 0 in it so that's how we can take a function and draw a k map from it now let's try another example so let's say the function is a b prime plus ac plus a prime bc prime so let's create another three variable k map but in the vertical orientation so we're going to have two columns and four rows so we're going to put the letter a on top bc below the diagonal line so a can be 0 or 1 bc can be 0 0 0 1 1 1 or 1 0. now let's start with this term a b prime so a is going to be 1 b is going to be 0. a is 1 in this column so let me just highlight that in red and b is 0 here so that means we're going to put a 1 in those first two boxes on the right now let's move on to the next term ac so that's when a is one and when c is one so we need to put a one here and here now for the next one we have a prime b c prime i forgot to put 1 1 for that now for a prime we're going to write 0 for b we're going to put 1 for c prime we're going to write 0. so a is 0 in the first column and b is 1 here and c is 0 here so we want a to be 0 and b to be 1 and c to be 0. so that only corresponds to this last square so we're going to put a 1 there so every other box we're going to put a 0 and so that is the k-map that corresponds to that function here's another harder example let's say the function is a b prime plus a prime c d plus a b c prime go ahead and draw a k map for that function now what type of k map do we need would you say it's a three variable k map or a four-variable k-map notice that we have four variables a b c and d so this time we're going to need four columns and four rows let's put the letters a b on top and c d on the bottom so a b could be 0 0 0 1 1 1 and 1 0 and the same is true for cd now let's focus on a b prime so we have a which we're going to put a 1 for that and for the complement of b let's put a zero so one is a one and one is b zero a is one and b is zero anywhere in this column so we're gonna put a one everywhere in that column now let's move on to the next term a prime c d so let's put the zero for the complement of a and a one for c and d so notice that c and d is one in this region and a is zero in the first two columns so therefore we have to put a one at the intersecting squares now for the last term a b c prime we're going to put a 1 for a and b and a 0 for the complement of c so a and b are 1 in this region c is 0 in the first two rows so we're going to put a 1 here everywhere else we're going to fill it in with a zero and so now we've completed the four variable k map let's work on one more example so this one i'm going to color code differently so let's say the function is c a d prime plus a prime b c prime d plus a b prime c so go ahead and fill out the four variable k map given this function so let's start with the lettuce c so since we have c and not the complement of c it's just going to be one c is one in this region so that's anywhere in the last two rows so we're gonna have to put a one in all of those rows i mean in the in those two rows so i'm gonna color code this group of eight ones notice that when we have just a term with one variable we're going to get eight ones for a term with two variables we're going to get four ones for a term with three variables we're going to get two ones and four a term with four variables we're only going to get one one so let's move on to the next one a d prime so for a i'm gonna put one and for d prime is zero so a is one in the last two columns on the right and d is zero here so we're going to have a 1 and these as well so now i'm going to circle those ones with a red color so as we can see for a term with two variables we have a total of four ones highlighted in red now let's move on to the next term which has four variables so we should only get one one in the k map so for a prime we're gonna write zero for b one c prime 0 d1 so when a is 0 and b is 1 here c is 0 and d is 1 here we're just going to put a 1 in this region and i'm going to highlight it in green now for the last one a b prime c so we're going to have a 1 for a 0 for b prime and a 1 for c so first let's identify where a b is 1 0 so that's going to be in this region and now let's identify where c is one c is one in the second and the third row from the top so we're gonna need a one here and the one that we already have here so as you can see for a term with three variables we get a pair of ones or two ones everything else let's put a zero and so now you know how to turn a function into a k-map so that's it for this video thanks for watching