Sunteți pe pagina 1din 170

Mathematics for Computing and

Informatics 1A (MCI511S)
Lecture Notes
2020
By G. Tapedzesa

2020 TAPEDZESA G., NUST 1


CHAPTER 1: NUMBER SYSTEMS
• The number system that you are familiar with,
that you use every day, is the decimal number
system, also commonly referred to as the base-10
positional number system.
• When you perform computations such as
3 + 2 = 5, 𝑜𝑟 21 – 7 = 14
you are using the decimal number system.
• This decimal system is ingrained into your
subconscious; it’s the natural way that you think
about numbers.
2020 TAPEDZESA G., NUST 2
• Computers can most readily use two symbols, and
therefore a base-2 system, or binary number system,
is most appropriate.
• The base-2 system has exactly two symbols: 0 and 1.
• The base-10 symbols are termed digits. The base-2
symbols are termed binary digits, or bits for short.
• All base-10 numbers are built as strings of digits
(such as 6349).
• All binary numbers are built as strings of bits (such as
1101). Just as we would say that the decimal number
12890 has five digits, we would say that the binary
number 11001 is a five-bit number.
2020 TAPEDZESA G., NUST 3
The Decimal Number System
The decimal (base 10) system contains
ten digits denoted by the symbols
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Any positive integer in the decimal
system can be expressed, in expanded
notation, as a sum of powers of 10
multiplied by a digit. For instance,
8253
= 8 × 103 + 2 × 102 + 5 × 101 + 3 × 100
2020 TAPEDZESA G., NUST 4
The Decimal Number System
• Any fractional number, represented in the
decimal system by a string of decimal digits
together with an embedded decimal point
may also be expressed in expanded notation
by using negative powers of 10. For example,
𝟖𝟓𝟑. 𝟓𝟐𝟔 = 𝟖 × 𝟏𝟎𝟐 + 𝟓 × 𝟏𝟎𝟏 + 𝟑 × 𝟏𝟎𝟎 + 𝟓 × 𝟏𝟎−𝟏 + 𝟐 × 𝟏𝟎−𝟐 + 𝟔 × 𝟏𝟎−𝟑

• This decimal fraction is said to have three


decimal places, which is the number of digits
to the right of the decimal point

2020 TAPEDZESA G., NUST 5


Binary System
• All data in a computer is represented in binary.
The pictures stored on your hard drive—it’s all
bits. The YouTube video of the cat falling off
the chair that you saw this morning—bits.
Your Facebook page—bits. The tweet you
sent—bits. Everything is bits.
• To understand how computers work, you have
to speak the language. And the language of
computers is the binary number system.

2020 TAPEDZESA G., NUST 6


The Binary Number System
• The binary system is a positional numeration
system to the base 2.
• Those binary numbers that have no fractional
part are called binary integers.
• A string of eight bits (such as 11000110) is
termed a byte.
• The table in the next slide gives some idea
of the correspondence between binary
numbers and the more familiar decimal
numbers.
2020 TAPEDZESA G., NUST 7
You should “memorize” the binary representations
of the decimal digits 0 through 15 shown below

• Here we used the 4-bit representation.


• When you are given the size of the storage location, include the
leading zeros to show all bits in the storage location. For example,
if told to represent decimal 5 as an 8-bit binary number, your
answer should be 00000101
2020 TAPEDZESA G., NUST 8
• The idea of describing numbers using a
positional system, as we have illustrated for
base-10 and base-2, can be extended to any
base.
• To avoid confusion when the base in use if
not clear from the context, or when using
multiple bases in a single expression, we
append a subscript to the number to indicate
the base, and write:
510 = 1012

2020 TAPEDZESA G., NUST 9


You should, henceforth, be able to readily shift
between the binary and decimal number
representations.

2020 TAPEDZESA G., NUST 10


Binary-to-Decimal Conversion
• To convert a binary number to a decimal number,
we simply write the binary number as a sum of
powers of 2. For example,
10112 = 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20 = 8 + 2 + 1 = 1110

1101012 = 1 × 25 + 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20
= 32 + 16 + 4 + 1 = 5310
Exercise: Convert each of the following binary numbers
as decimal numbers
1101102 , 10000012 , 101.11012

2020 TAPEDZESA G., NUST 11


Decimal-to-Binary Conversion
• Given a binary number, you can now convert it to
the equivalent decimal number.
• The method of converting a decimal number to a
binary number, which is much more readily
adaptable to programming on a computer, entails
repeatedly dividing the decimal number by 2,
keeping track of the remainder at each step.
• To convert the decimal number, say x, to binary
we follow the steps on the next slide:

2020 TAPEDZESA G., NUST 12


Step 1. Divide 𝑥 by 2 to obtain a quotient and remainder.
The remainder will be 0 or 1.
Step 2. If the quotient is zero, proceed to Step 3. Otherwise,
go back to Step 1, assigning 𝑥 to be the value of the
most-recent quotient from Step 1.
Step 3. The sequence of remainders from bottom up forms
the binary representation of the number.
Example: Convert the decimal number 53 to its binary
equivalent. Ans = 110101
53 ÷ 2 = 26 𝑟 1
26 ÷ 2 = 13 𝑟 0
13 ÷ 2 = 6 𝑟 1
6÷2=3𝑟0
3÷2=1𝑟1
1÷2=0𝑟1

2020 TAPEDZESA G., NUST 13


If a decimal number has a fractional part, you
convert the integral part and the fractional
part separately as illustrated with the decimal
number 109.78125 below.
• First, convert the integral part 109 to its
binary equivalent: 109 = 11011012 (verify)
• Then convert the fractional part 0.78125 to
its binary equivalent by successively
multiplying the fractional part by 2, noting
the integral part of the product, as follows:

2020 TAPEDZESA G., NUST 14


Decimal-to-Binary Conversion
0.78125 × 2 = 𝟏. 56250
0.5625 × 2 = 𝟏. 1250
0.125 × 2 = 𝟎. 250
0.25 × 2 = 𝟎. 50
0.5 × 2 = 𝟏. 0
You stop when you have a zero fractional part. The
sequence of integral part digits (in red) from top down
yields the required binary representation. That is,
0.78125 = 0.110012
The binary equivalents of the decimal number 109.78125 is
the sum of the binary equivalents of its integral and
fractional parts:
109.78125 = 1101101.110012
2020 TAPEDZESA G., NUST 15
Binary Arithmetic
The execution of numerical calculations is
essentially the same in all positional numeration
systems.
Binary Addition
The algorithm for the addition of decimal numbers
holds also for the addition of binary numbers; the
only addition facts needed for binary addition are:
0+0=0
0+1=1
1+0=1
1 + 1 = 0, with a carry of 1
1 + 1 + 1 = 1, with a carry of 1

2020 TAPEDZESA G., NUST 16


Binary Addition
Go through examples 1.5 and 1.6 in the
prescribed textbook.
Exercise: In each of the following cases, perform
the addition of the binary numbers:

1.

2.

2020 TAPEDZESA G., NUST 17


Binary Multiplication
The algorithm for decimal multiplication
also holds for binary multiplication. Please
note that when performing the operation of
multiplication, it is extremely important to
line up the numbers in the correct columns.

For practice, attempt examples 1.8 and 1.9


in the prescribed textbook

2020 TAPEDZESA G., NUST 18


Binary Subtraction
The same “borrowing” procedure followed
in the decimal system is applied in the
binary system. The only subtraction tion
facts needed for binary subtraction are:
0−0=0
1−0=1
1−1=0
10 − 1 = 1
0 − 1 = 1, with a borrow of 1 from the next column
Examples 1.12 – 1.14
2020 TAPEDZESA G., NUST 19
Binary Division
• The algorithm for binary division is simply
repeated subtraction of the divisor.
• As in decimal division of integers, a
remainder is possible when one binary
integer is divided by another.
• Also, the division of binary fractions is
handled the same way as the division of
decimal fractions.

2020 TAPEDZESA G., NUST 20


Complements
• All computers represent integers in a manner that
allows both positive and negative numbers
• Remember: (including the negative sign) must be
represented as bits; that is, ones and zeros!
• Many computers store negative numbers in the
form of their arithmetic complements
• Complements are used to reduce subtraction to
addition
• First we discuss these complements in the familiar
decimal system, known as the nines complement
and the tens complement
2020 TAPEDZESA G., NUST 21
Decimal Complements
The nines complement of a decimal number, say
A, is obtained by subtracting each digit of A from
9; and the tens complement of A is its nines
complement plus one.
Example
Decimal number Nine complement Tens complement

4308 5691 5692


123 123 876 876 876 877

9672 0327 0328


751 620 248 379 248 380

2020 TAPEDZESA G., NUST 22


• To illustrate the use of complements in subtraction,
let A and B be two decimal integers with the same
number of digits, say 4 digits, and suppose that A is
less than B
• We can simplify the difference 𝐵 − 𝐴 as
𝐵 − 𝐴 = 𝐵 − 𝐴 + 10 000 − 10 000
= 𝐵 − 𝐴 + (9999 + 1 − 10 000)
= 𝐵 + (9999 − 𝐴 + 1) − 10 000
= 𝐵 + 9999 − 𝐴 + 1 − 10 000
Thus, we can calculate B − 𝐴 either by adding the tens
complement of A to B and then subtracting 10 000, or
by adding the nines complement of A and then
adding 1 and subtracting 10 000.
Attempt example 1.18
2020 TAPEDZESA G., NUST 23
• Suppose now that A is greater than B. For
instance, let us consider A=5872 and
B=2148. Then the difference A-B is negative:
• We can simplify the difference 𝐵 − 𝐴 as
𝐵 − 𝐴 = 2148 + (9999 − 5872 + 1) − 10 000

= 2148 + 4128 − 10 000


= −3724

2020 TAPEDZESA G., NUST 24


Binary Complements
• The terminology and principle of complements in
the decimal system can be easily translated into
the binary system
• Specifically, if A is a binary number, the ones
complement of A is obtained by subtracting each
digit of A from 1, and the twos complement of A
is its ones complement plus 1.
Example Binary number Ones complement Twos complement
11011100 00100011 00100100
00100111 11011000 11011001
00011000 11100111 11101000

2020 TAPEDZESA G., NUST 25


Binary Complements
• Observe that taking the ones complement simply
inverts each digit, that is 0 is replaced by 1 and vice
versa.
• Specifically, if A is a binary number, the ones
complement of A is obtained by subtracting each digit
of A from 1, and the twos complement of A is its ones
complement plus 1.
Example Binary number Ones complement Twos complement
11011100 00100011 00100100
00100111 11011000 11011001
00011000 11100111 11101000

Attempt examples 1.20 and 1.21 in the prescribed textbook


2020 TAPEDZESA G., NUST 26
So, to find the representation of a negative
decimal number, do the following:
• First find the binary representation of the
number without the negative sign
• Then take the two’s complement. The result is
the representation of the negative number.
Every computer today uses two’s
complement notation for the storage of
integers.
Note: a binary number, added to its two’s
complement, results in zero, as expected.
2020 TAPEDZESA G., NUST 27
Tutorial Exercises
1. Find the face value and the place value of the
digit 4 in the following decimal numbers.
(a) 7425 (b) 146 723 (c) 305.54 (d) 0.012345
2. Rewrite in expanded notation.
a) 2468 (b) 54.321
3. Give the face value and the place value of each
of the underlined bit:
(a) 10110 (b) 1011001 (c) 101.11010(d) 110.0010
4. Rewrite in expanded notation.
a) 1101102 (b) 11.011012
2020 TAPEDZESA G., NUST 28
5. Convert each binary number to its decimal form:
(a) 1110011 (b) 110.1011
6. Convert the decimal number 437.206 251 to its
binary equivalent.
7. Evaluate the following binary sums:
a) 11011 + 1010 (b) 110.1101 + 1011.011
8. Evaluate the following binary products:
a) 110111 × 101 (b) 110.001 × 1.11
9. Evaluate the following binary differences:
a) 1110001 − 111011 (b) 1101.0011 − 110.11011
10.Evaluate 111001 ÷ 1001 to two binary places.

2020 TAPEDZESA G., NUST 29


11. Determine the nines and tens complements of the
following decimal numbers:
(a) 3268 (b) 479 200 (c) 99 132 756
12. Find the following differences using tens complements:
(a) 53 726 − 14 503 (b) 2658 − 4321
13. Determine the ones and twos complements of the
binary numbers:
a) 11011 + 1010 (b) 110.1101 + 1011.011
14. Evaluate the following binary products:
a) 110110 (b) 1101001101 (c) 1111000001110
15. Find the following binary differences using ones
complements:
a) 111000 − 110100 (b) 101010011 − 111011001

2020 TAPEDZESA G., NUST 30


CHAPTER 2: COMPUTER CODES
• To be processed by the computer, data must be
encoded in some fashion into sequences of bits
(binary numbers)
• However, we often have to deal with large positive
binary numbers.
• For instance, consider that computers connect to
the Internet using a Network Interface Card (NIC).
Every NIC in the world is assigned a unique 48-bit
identifier as an Ethernet address. The intent is that
no two NICs in the world will have the same
address.
• A sample Ethernet address might be:
𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟏𝟎𝟎𝟎𝟏𝟏𝟏𝟎𝟏𝟎𝟏𝟏𝟏𝟏𝟎𝟎𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟎𝟎𝟏𝟎𝟎𝟏𝟎𝟎𝟎𝟏𝟏𝟎𝟏𝟏𝟎

2020 TAPEDZESA G., NUST 31


• Computer engineers must oftentimes look at
the contents of a specific item in computer
memory.
• You might, for instance, have to look at a
variable that is stored at address:
00000000000100101111111101111100
• Surely, such long binary strings would be
cumbersome to transcribe or to read off to a
colleague.
• Even if you have come to love the binary number
system, you would still likely agree that these long
strings are too much of a good thing.
2020 TAPEDZESA G., NUST 32
• Fortunately, large binary numbers can be made much
more compact, and hence easier to work with, if
represented in other number systems, the octal (base 8)
and the hexadecimal (base 16) systems.
• Since 8 and 16 are powers of 2, there is almost instant
interconversion between the octal and hexadecimal
systems and the binary system.
• Although the decimal system is more compact than the
binary system, the octal and hexadecimal systems are in
fact comparable in compactness with the decimal system
• Converting between binary and hexadecimal is
exceedingly easy—much easier than converting between
binary and decimal.
2020 TAPEDZESA G., NUST 33
Converting from any base to base 10
• We can convert a base 𝑏 number, 𝑁𝑏 ,
into its decimal representation by writing
𝑁𝑏 in expanded notation and calculating
by decimal arithmetic
• This conversion is accomplished by the
following algorithm, which distinguishes
between the integral part and the
fractional part of the number:

2020 TAPEDZESA G., NUST 34


Converting from any base 𝑏 to base 10
Integral part: Multiply the leftmost digit by the
base 𝑏 and add the next digit to the right. Multiply
the sum by the base 𝑏 and add the next digit.
Repeat the process until the rightmost digit is
added. The final answer is the required decimal
integral part.
Fractional part: Multiply the rightmost digit by the
base 1Τ𝑏 and add the next digit to the right.
Multiply the sum by the base 1Τ𝑏 and add the next
digit. Repeat the process until the leftmost digit is
added and the sum is multiplied by 1Τ𝑏. The final
answer is the required decimal fractional part.
2020 TAPEDZESA G., NUST 35
Example: Consider the quintal number 2401.23145 .
Then
• We convert 2401 (the integral part) into its decimal
form using the above algorithm as follows:
𝟐 × 𝟓 → 𝟏𝟎 + 𝟒 → 𝟏𝟒 × 𝟓 → 𝟕𝟎 + 𝟎 → 𝟕𝟎 × 𝟓 → 𝟑𝟓𝟎 + 𝟏 → 𝟑𝟓𝟏
Thus, 351 is the decimal form for 24015 .
• We convert 0.2314 (the fractional part) into its
decimal form as follows:
𝟒 × 𝟎. 𝟐 → 𝟎. 𝟖 + 𝟏 → 𝟏. 𝟖 × 𝟎. 𝟐 → 𝟎. 𝟑𝟔 + 𝟑 → 𝟑. 𝟑𝟔 × 𝟎. 𝟐 → 𝟎. 𝟔𝟕𝟐 + 𝟐
→ 𝟐. 𝟔𝟕𝟐 +× 𝟎. 𝟐 → 𝟎. 𝟓𝟑𝟒𝟒
The final product, 0.5344, is the decimal form for
0.23145 .
The decimal representation of 2401.2314 is therefore
351.5344.
2020 TAPEDZESA G., NUST 36
Decimal-to-base-b Conversion
We can convert a decimal number to its base-b representation
using the following algorithm, which also distinguishes between
the integral part of the number and its fractional part.
Integral part: Divide the decimal number and each succeeding
quotient by b until a zero quotient is obtained. The sequence of
remainders, from bottom up, yields the required base-b
representation.
Fractional part: Multiply the decimal number and the fractional
part of each succeeding product by b until a zero fractional part
is obtained. Then the finite (or infinite repeating) sequence of
integral parts of the products gives the base-b digit
representation, from top down, yields the required base-b
representation.
2020 TAPEDZESA G., NUST 37
Example 1: Convert the decimal number 684 to its
quintal (base 5) representation.
Solution: We divide 684, and each subsequent
quotient, by 5, noting all remainders.
Divisions Quotients Remainders
684 ÷ 5 136 4
136 ÷ 5 27 1
27 ÷ 5 5 2
5÷5 1 0
1÷5 0 1

The sequence of remainders from bottom up gives


the quintal form for 68410 = 102145 .

2020 TAPEDZESA G., NUST 38


Example 2: Convert the decimal number 0.4704 to
its quintal (base 5) representation.
Solution: We multiply 0.4704, and each
subsequent fractional part, by 5, noting the integral
part of each product.
Multiplications Products Integral parts
0.4704 × 5 2.352 2
0.352 × 5 1.76 1
0.76 × 5 3.8 3
0.8 × 5 4.0 4
The sequence of integral parts from top down
yields the required quintal form for 0.470410 =
0.21345 .
2020 TAPEDZESA G., NUST 39
Octal and Hexadecimal System
To be discussed in class

2020 TAPEDZESA G., NUST 40


Binary-Coded Decimal Codes
• There are many ways of representing numerical
data in binary form
• One way is simply to write the numbers to the
base 2, known as the straight binary coding
• Another way is to encode decimal numbers digit
by digit
• These codes, which require at least 4 bits for each
decimal digit are called binary-coded decimal
(BCD) codes
• In this section we shall explore 4-bit, 6-bit and 8-
bit BCD codes
2020 TAPEDZESA G., NUST 41
4-Bit BCD Codes
There are two most popular 4-bit BCD codes – the weighted
8-4-2-1 BCD code and the non-weighted excess-3 (XS-3 BCD)
code Decimal BCD Codes
Digits 8-4-2-1 XS-3
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100

2020 TAPEDZESA G., NUST 42


Weighted 8-4-2-1 BCD Code
This is a (weighted) coding system in which the bits
are given, from left to right, the weights 8, 4, 2, and
1, respectively
Example: The 8-4-2-1 BCD representation of 469 is
4 6 9
0100 0110 1001

On the other hand, the straight binary


representation of 469 is
469 = 1110101012
which involves 3 fewer bits.

2020 TAPEDZESA G., NUST 43


Non-weighted XS-3 BCD Code
• The XS-3 (excess-3) BCD code is related to the 8-4-2-1 BCD code
as follows:
• The XS-3 code for a decimal digit 𝑑 is obtained by adding 3 =
00112 to the 8-4-2-1 BCD code for 𝑑.
Example: The XS-3 BCD representation of 469 is
4 6 9
0100 0110 1001
+0011 +0011 +0011
0111 1001 1100
For the decimal integer 530, the XS-3 coding is
5 3 0
0101 0011 0000
+0011 +0011 +0011
1000 0110 0011

2020 TAPEDZESA G., NUST 44


Non-weighted XS-3 BCD Code
• The XS-3 has an important arithmetic property:
it encodes a pair of nines complements as a pair
of ones complements (this is verified in the
example above)
• Because of this feature, arithmetic in the XS-3
BCD code is simpler in many respects than
arithmetic in the 8-4-2-1 BCD code.
Exercise: What are the advantages and disadvantages
of the XS-3 BCD code relative to straight binary coding?

2020 TAPEDZESA G., NUST 45


6-Bit BCD Code
• The computer processes both numerical data
and non-numerical data
• Non-numerical data are expressed in a set of
characters consisting of 10 digits, 26 letters,
and a dozen or more special characters
• Data consisting of both numeric and non-
numeric items are called alphanumeric data
• The 6-bit BCD code adds two bits, called zone
bits, to the 4-bit 8-4-2-1 numeric bits
2020 TAPEDZESA G., NUST 46
• Digits are coded with 0s for both zone
bits and their 8-4-2-1 BCD code for the
numeric bits
• The digit 0 is exceptionally coded as if it
were ten
• Alphabetical characters (letters) are
divided into 3 groups: the first 9, A
through I, have zone bits 11; the next 9, J
through R, have zone bits 10; and the
remainder have zone bits 01
2020 TAPEDZESA G., NUST 47
2020 TAPEDZESA G., NUST 48
Example 1
Show the binary digits used to record (store) the
word LOVE in 6-bit BCD code.
Solution:
L=100011, O=100110, V=010101, E=110101
So the binary digits
100011 100110 010101 110101
Will record the word LOVE in 6-bit BCD coding.

2020 TAPEDZESA G., NUST 49


6-bit BCD Codes With Parity
• In practice a 6-bit code appears within the
computer in a 7-bit form
• The inclusion of the 7th bit, called a check bit or
parity bit, shall be explained in class
• For each character, the value of the check bit (0
or 1) is such as to make the sum of the bits,
including the check bit, odd or even, according as
the machine operates on odd or even parity.

2020 TAPEDZESA G., NUST 50


Example; If the computer uses odd parity, the characters 7,
9, P, and W are stored as follows:
Check Zone Numeric
7 0 00 0111
9 1 00 1001
P 1 10 0111
W 0 01 1100
• The purpose of the check bit is to ensure that no bit is
lost or gained when data is transmitted internally in a
computer
• After a character is transmitted, the computer adds up
the bits in the character
• If a single error occurred, the sum of the bits will not
have the same parity as the parity of the computer. The
computer would then retransmit the data

2020 TAPEDZESA G., NUST 51


8-bit BCD Codes
• Modern data processing frequently requires many
special characters, and even both lowercase and
uppercase letters
• Accordingly, various 8-bit codes have been
developed
• Each coded character of byte is normally divided
into 4 zone bits and four 8-4-2-1 numeric bits (to
be demonstrated in class)
• There are two 8-bit BCD codes predominant in the
computer industry today: EBCDIC and ASCII
2020 TAPEDZESA G., NUST 52
EBCDIC
• The Extended Binary-Coded Decimal Interchange
Code (EBCDIC) was developed by IBM as an
extension of the 6-bit BCD code
• Study the tables below:

2020 TAPEDZESA G., NUST 53


EBCDIC Zoned Decimal Format
• Zoned decimal formats are used to represent
numeric values (positive, negative, or unsigned)
in EBCDIC
• However, the sign of a number is not encoded
by an 8-bit group at the beginning of the
number, but by a 4-bit group which occupies
the zone portion of the rightmost digit
• The sign 4-bit coding is as follows:
+ → 1100, − → 1101, 𝑢𝑛𝑠𝑖𝑔𝑛𝑒𝑑 → 1111
• Note that the code for unsigned (positive)
number is the normal numeric zone code 1111
2020 TAPEDZESA G., NUST 54
For example, the numbers 275, +275, and -275 are encoded as
follows, in zoned decimal format:
2 7 5
1111 0010 1111 0111 1111 0101

2 7 + 5
1111 0010 1111 0111 1100 0101

2 7 - 5
1111 0010 1111 0111 1101 0101

• Although one can transmit data in zoned decimal format, the


arithmetic\logic unit of the computer cannot generally handle
data in this form, and the data must be converted to another
form before calculation can occur
• One acceptable form for calculations is the packed decimal
format
2020 TAPEDZESA G., NUST 55
EBCDIC Packed Decimal Format
• Here, each digit is encoded in 4-bit BCD, as is
the sign, with the code for the sign placed at the
end of the number. For example,
2 7 5
0010 0111 0101 1111

2 7 5 +
0010 0111 0101 1100

2 7 5 -
0010 0111 0101 1101

2020 TAPEDZESA G., NUST 56


EBCDIC Packed Decimal Format
• Conversion from zoned decimal format to
packed decimal format is accomplished in
two steps
Step 1: the zone and numeric portions of the
rightmost byte are interchanged, bringing the sign
of the number to the end of the format
Step 2: the other zone portions are deleted and the
remaining numeric portions packed together.
• Packed decimal format requires fewer
number of bytes than zoned decimal format
• Numbers represented in packed decimal
format can be used for arithmetic operations
2020 TAPEDZESA G., NUST 57
CHAPTER 3: COMPUTER ARITHMETIC
Compile your own notes using the following sub-headings:
• Significant digits
• Rounding numbers
• Truncating
• Absolute value
• Binary exponential form
• Integer representation
• Floating-point representation
• Computer arithmetic
• Errors

2020 TAPEDZESA G., NUST 58


CHAPTER 4: LOGIC, TRUTH TABLES
Definitions:
• Logic is the science of reasoning, which allows us to
determine which statements are true and which are
false based on a set of basic assumptions called axioms
• A statement or proposition is an assertion which is
either true or false
• The truth of falsity of a statement is called its truth
value
• If a statement is true, we assign it the truth value T
• If a statement is false, we assign it the truth value F
• We usually use letters to denote statements
2020 TAPEDZESA G., NUST 59
Think Pair and Discuss
Which of the following are statements? Give their truth
values.
1. Carlo passed the exam.
2. What time is it?
3. Look out for that car!
4. Ethiopia is in Africa.
5. All even numbers are divisible by 2.
6. Close the door!
7. Sit down.
8. Jupiter is the closest planet to the sun.
9. What a great book!
10. It is currently raining in Singapore.
11. If a number is smaller than 0 then it is positive.
2020 TAPEDZESA G., NUST 60
• A compound statement is one formed by joining other
statements together with logical connectives
• Common connectives are and, or, not, conditional, bi-
conditional
• The fundamental property of a compound statement is that
its truth value is completely determined by the truth values
of its sub-statements together with the way in which they
are connected to form the compound statement
• A truth table is a tool used to determine when a compound
statement is true or false
• A truth table gives all possible values (T or F) of a statement
which combines a number of simpler statements

2020 TAPEDZESA G., NUST 61


Conjunction, 𝒑 ∧ 𝒒
• Any two statements can be combined by the word “and” to form
a compound statement called the conjunction of the original
statements, denoted by
𝑝 ∧ 𝑞 (𝑝 and 𝑞)
• The truth value of the compound statement 𝑝 ∧ 𝑞 is given by the
following table:
p q 𝒑∧𝒒
T T T
T F F
F T F
F F F
For example, let p be the statement “I am at home” and q be the
statement “It is raining”, then 𝑝 ∧ 𝑞 is the statement “I am at home
and it is raining”.
2020 TAPEDZESA G., NUST 62
Observe that 𝑝 ∧ 𝑞 is true only in the case
that both sub-statements are true
Exercise: Which of the following
statements is/ are true?
1. Etosha is in Namibia and 2+2=5.
2. Etosha is in Zambia and 2+2=4.
3. Etosha is in Namibia and 2+2=4.
4. Etosha is in Zambia and 2+2=5.

2020 TAPEDZESA G., NUST 63


Disjunction, 𝒑 ∨ 𝒒
• Any two statements can be combined by the word
“or” to form a compound statement called the
disjunction of the original statements, denoted by
𝑝 ∨ 𝑞 (𝑝 or 𝑞)
• The truth value of the compound statement 𝑝 ∧ 𝑞
is given by the following table:
p q 𝒑∧𝒒
T T T
T F T
F T T
F F F

2020 TAPEDZESA G., NUST 64


Observe that 𝑝 ∨ 𝑞 is false only when both
sub-statements are false.
Exercise: Which of the following
statements is/ are true?
1. Etosha is in Namibia or 2+2=5.
2. Etosha is in Zambia or 2+2=4.
3. Etosha is in Namibia or 2+2=4.
4. Etosha is in Zambia or 2+2=5.
Note that the word “or” is inclusive; it is
used in the sense of “p or q or both”.
2020 TAPEDZESA G., NUST 65
Negation, ¬𝒑
• Given any statement 𝑝, another statement called the
negation of p (not p), can be formed and is denoted by
¬𝑝 or ~𝑝
• The truth value of ¬𝑝 is given by the following table:
p ¬𝒑
T F
I
F T

• The truth value of thenegation of any statement is


always the opposite of the truth value of the original
statement
• In other words, if p is true then ¬𝑝 is false, and if p is
false then ¬𝑝 is true

2020 TAPEDZESA G., NUST 66


Exercise: Which of the following statements are
negations of each other?
1. Etosha is in Namibia.
2. 2+2=5.
3. Etosha is in Zambia
4. 2 + 2 ≠ 4.
5. Etosha is not in Namibia
6. 2+2=4
7. It is false that Etosha is in Namibia
8. It is false that 2+2=5
Note that the logical notation for the
connectives “and”, “or”, “not” is not standard –
some texts use different notations.
2020 TAPEDZESA G., NUST 67
Conditional/ Implication 𝒑 → 𝒒
• If p and q are statements, then 𝑝 → 𝑞 is a conditional
statement or implication which reads “if p then q” and
has the truth value given by the following table:
p q 𝒑→𝒒
T T T
T F F
F T T
F F T

p is the hypothesis (premise) and q is the conclusion


(consequence).
For example, if p is “It is raining” and q is “The streets are
wet”, then 𝑝 → 𝑞 is “ If it is raining then the streets are wet”.
2020 TAPEDZESA G., NUST 68
Conditional/ Implication 𝒑 → 𝒒
• Note that, from a false premise anything can be implied!
• In 𝑝 → 𝑞 there does not need to be any connection
between the premise (antecedent) and the consequent.
The meaning depends only on the truth values of p and q
• This implication is perfectly fine, but may not be used in
ordinary English
• Here are some examples of valid but counterintuitive
implications:
1. If the moon is made of cheese then you get a PhD in
physics tomorrow. True!
2. If 2 + 3 = 6 then it rains today. True.
3. If horses have wings, then elephants can dance. True!

2020 TAPEDZESA G., NUST 69


Bi-conditional 𝒑 ↔ 𝒒
• If p and q are statements, then 𝑝 ↔ 𝑞 is a biconditional statement
which means “p if and only if q” and has the truth value given by the
following table:
p q 𝒑↔𝒒
T T T
T F F
F T F
F F T
• In other words, 𝑝 ↔ 𝑞 is true iff p and q have the same truth value;
otherwise, if p and q have different truth values, the biconditional is
false
For example, if p is “You buy an airline ticket” and q is “You can take a
flight”, then 𝑝 ↔ 𝑞 is “You can take a flight iff you buy an airline ticket”:
• True only if you do both or neither
• Doing only one or the other makes the proposition false

2020 TAPEDZESA G., NUST 70


Converse, Inverse, Contrapositive
• From the conditional statement 𝑝 → 𝑞 we
can form new conditional statements

How are these statements related to the


original?
How are they related to each other?

2020 TAPEDZESA G., NUST 71


Converse, Inverse, Contrapositive
Example: Consider the implication
“It is raining → streets are wet” (True)
• The converse is “streets are wet → it is raining”.
(False)
• The inverse is “it’s not raining → streets are not
wet”. (False)
• The contrapositive is “streets are not wet → it’s not
raining”. (True)
Exercise: Find the converse, inverse, and
contrapositive of
“If it is raining then I will not go to town.”
2020 TAPEDZESA G., NUST 72
Propositions and Truth Tables
• By repetitive use of the logical connectives, we
can construct compound statements/
propositions that are more involved
• All logical operations can be applied to build up
arbitrarily complex propositions
• For instance, if p, q, r, t are simple propositions,
then 𝑝 ∨ ¬𝑞 → 𝑡 and 𝑝 ∨ 𝑞 ∧ 𝑟 ∨ ¬𝑡
combine simple propositions into more complex
compound propositions
• Parenthesis indicate the order of evaluation
2020 TAPEDZESA G., NUST 73
Propositions and Truth Tables
• To reduce number of parentheses we use the following
precedence rules: Operation Precedence
¬ 1
∧ 2
∨ 3
→ 4
↔ 5

2020 TAPEDZESA G., NUST 74


Propositions and Truth Tables
• The truth value of a proposition is derived form
the truth values of its sub-statements
• The truth table of the proposition ¬ 𝑝 ∧ ¬𝑞 ,
for example, is constructed as follows:

2020 TAPEDZESA G., NUST 75


Exercises
1. Construct the truth table of the proposition:
¬𝑝 ∨ 𝑞 ∧ 𝑟 , 𝑝 → 𝑞 ↔ ¬𝑝 ∨ 𝑞
2. Attempt problems 4.26, 4.27, 4.35, 4.36 on page 92 - 3.
3. Consider the compound proposition: “If there is a test tomorrow, then I
will go home early today and study till late.”
a) Identify the atomic propositions and assign variables to each atomic
proposition.
b) Write down the corresponding logical form, and hence construct the
corresponding truth table.
4.

2020 TAPEDZESA G., NUST 76


Tautologies and Contradictions
• A tautology is a compound proposition that is
always true
• A contradiction is a compound proposition that is
always false
• A contingency is neither a tautology nor a
contradiction
• It is easy to see that 𝐴 ∨ ¬𝐴 is a tautology and
that 𝐴 ∧ ¬𝐴 is a contradiction. Verify

2020 TAPEDZESA G., NUST 77


Exercise: Investigate whether each of the
following propositions is a tautology, a
contradiction or neither:
1. 𝑝 ∨ ¬ 𝑝 ∧ 𝑞
2. 𝑝 ∧ 𝑞 ∧ ¬ 𝑝 ∨ 𝑞
3. 𝑝 → 𝑞 ∧ 𝑝 → 𝑞 → 𝑝 → 𝑟

2020 TAPEDZESA G., NUST 78


Principle of Substitution
If 𝑃(𝑝, 𝑞, ⋯ ) is a tautology, then 𝑃(𝐴, 𝐵, ⋯ ) is a
tautology for any propositions 𝐴, 𝐵, ⋯.
Example: Recall that 𝑝 ∨ ¬𝑝 is a tautology.
Substituting 𝐴 ∧ 𝐵 for 𝑝 we obtain the
proposition 𝐴 ∧ 𝐵 ∨ ¬ 𝐴 ∧ 𝐵 , which by the
Principle of Substitution, should be a tautology.
Verify.

2020 TAPEDZESA G., NUST 79


Logical Equivalence
• Two compound propositions 𝑃(𝑝, 𝑞, ⋯ )and
𝑄(𝑝, 𝑞, ⋯ ) are logically equivalent, or simply
equivalent, denoted by
𝑃(𝑝, 𝑞, ⋯ ) ≡ 𝑄(𝑝, 𝑞, ⋯ )
if they have identical truth tables.
• For instance, the truth tables of ~ 𝑝 ∧ 𝑞 and
~𝑝 ∨ ~𝑞 are identical, hence
~ 𝑝 ∧ 𝑞 ≡ ~𝑝 ∨ ~𝑞
• Verify that he following statements are logically
equivalent
“It is false that roses are red and violets are blue.”
“Roses are not red, or violets are not blue.”

2020 TAPEDZESA G., NUST 80


Logical Equivalence
Exercise: Which of the converse, inverse, or
contrapositive of an implication is/ are
equivalent to the implication itself?
• Sometimes truth tables become
cumbersome, especially when many
variables are involved
• We can make use of laws of the algebra of
propositions to transform propositions into
equivalent forms (page 81)
2020 TAPEDZESA G., NUST 81
2020 TAPEDZESA G., NUST 82
Exercises

2020 TAPEDZESA G., NUST 83


Arguments
• An argument is an assertion that a set of
statements, called the premises, yields another
statement, called the conclusion
• An argument is valid if and only if the
conjunction of the premises implies the
conclusion
• An invalid argument is called a fallacy
• In many cases, the validity of an argument can
be checked by constructing a truth table

2020 TAPEDZESA G., NUST 84


Arguments
• Formally, an argument, denoted by
𝑃1 , 𝑃2 , ⋯ , 𝑃𝑛 ⊣ 𝑄
is valid if 𝑄 is true whenever all the premises
𝑃1 , 𝑃2 , ⋯ , 𝑃𝑛 are true.
• For example, the following argument (known
as the Law of Detachment) is valid:
𝑝 → 𝑞, 𝑝 ⊣ 𝑞
• On the other hand, the following argument is a
fallacy:
𝑝 → 𝑞, 𝑞 ⊣ 𝑝

2020 TAPEDZESA G., NUST 85


Exercise: In each of the following cases, determine
whether, or not, the argument is valid.

2020 TAPEDZESA G., NUST 86


Arguments
• Note that the argument 𝑃1 , 𝑃2 , ⋯ , 𝑃𝑛 ⊢ 𝑄 is valid
if and only if 𝑃1 ∧ 𝑃2 ∧ ⋯ ∧ 𝑃𝑛 → 𝑄 is a
tautology
Example (Law of Syllogism): This is the fundamental
principle of logical reasoning, which states:
“If p implies q and q implies r, then p implies r.”
In other words, the following argument is valid:
𝑝 → 𝑞, 𝑞 → 𝑟 ⊢ p → 𝑟
This result can be verified (try it) by means of a truth
table which shows that the proposition
𝑝→𝑞 ∧ 𝑞→𝑟 → p→𝑟
Is a tautology.
2020 TAPEDZESA G., NUST 87
Arguments
• At this juncture, we emphasize that the validity of an
argument does not depend upon the truth values or the
content of the statements appearing in the argument,
but only upon the formal structure of the argument.
• Consider the following argument, as an example:
S1: If a man is a bachelor, he is unhappy.
S2: If a man is unhappy, he dies young.
……………………………………………………………….
Q: Bachelors die young.
Here the statement Q denotes the conlusion of the
argument, and the statements S1 and S2 are the premises.
We claim that the argument is valid, since it is of the form
𝑝 → 𝑞, 𝑞 → 𝑟 ⊢ p → 𝑟

2020 TAPEDZESA G., NUST 88


Exercises
In each of the following cases, determine whether,
or not, the argument is valid.
1. If Anne is wealthy, then she is happy.
Anne is happy.
Therefore
Anne is wealthy.
2. If John drinks beer, he is at least 18 years old.
John does not drink beer.
Conclusion
John is not yet 18 years old.
2020 TAPEDZESA G., NUST 89
3. If Bob is a good dad, he will go to the parent-
teacher meeting.
Bob did not go to the parent-teacher meeting.
Therefore
Bob is not a good dad.
4. If Luci smokes cigarettes every day, she
increases her risk of lung cancer.
Luci doesn’t smoke cigarettes everyday.
Conclusion
Luci has no increased risk of lung cancer.

2020 TAPEDZESA G., NUST 90


5. When a politician engages in shady business
dealings, it ends up on the front page of the
newspapers.
No Austrian senator has ever appeared on the
front page of a newspaper.
Thus
No Austrian senator engages in shady business
dealings.
6. If Moni is a registered voter, then she is over 18.
Moni is not a registered voter.
Therefore
Moni is not over 18.
2020 TAPEDZESA G., NUST 91
3. If the factory closes, then more people will be
unemployed.
If more people are unemployed, then more
children will be maltreated.
Therefore
If the factory closes , then more
children will be maltreated.

2020 TAPEDZESA G., NUST 92


2020 TAPEDZESA G., NUST 93
Logical Implication
• A proposition 𝑃(𝑝, 𝑞, ⋯ ) is said to logically
imply a proposition 𝑄(𝑝, 𝑞, ⋯ ), written
𝑃(𝑝, 𝑞, ⋯ ) ⇒ 𝑄(𝑝, 𝑞, ⋯ )
if 𝑄(𝑝, 𝑞, ⋯ ) is true whenever P(𝑝, 𝑞, ⋯ ) is true.
For example, 𝑝 logically implies 𝑝 ∨ 𝑞. Veify using
truth tables.
In fact, for any propositions 𝑃(𝑝, 𝑞, ⋯ ) and
Q(𝑝, 𝑞, ⋯ ), the following statements are
equivalent:

2020 TAPEDZESA G., NUST 94


Logical Implication
1. 𝑃(𝑝, 𝑞, ⋯ ) logically implies 𝑄 𝑝, 𝑞, ⋯ .
2. The argument 𝑃(𝑝, 𝑞, ⋯ ) ⊢ 𝑄(𝑝, 𝑞, ⋯ ) is
valid.
3. The proposition 𝑃 𝑝, 𝑞, ⋯ → 𝑄(𝑝, 𝑞, ⋯ ) is a
tautology.
• Further, if P ⇒ 𝑄 and Q ⇒ 𝑃 then P ≡ 𝑄.

2020 TAPEDZESA G., NUST 95


Joint Denial, 𝒑 ↓ 𝒒
• The propositional connective ↓ is called the joint
denial; 𝑝 ↓ 𝑞 is read “Neither 𝑝 nor 𝑞”.
• Now 𝑝 ↓ 𝑞 is true only in the case that 𝑝 is not true
and 𝑞 is not true; hence the truth table of 𝑝 ↓ 𝑞 is
as follows:
𝒑 𝒒 𝒑↓𝒒
T T F

T F F

F T F

F F T

In fact, 𝑝 ↓ 𝑞 ≡∼ 𝑝 ∧∼ 𝑞. (Verify)
2020 TAPEDZESA G., NUST 96
Exercises

2020 TAPEDZESA G., NUST 97


CHAPTER 7: BOOLEAN ALGEBRA ,
LOGIC GATES
Algebraic Structures in General
General algebraic structures are usually formulated
based on following axioms:
1. Closure
2. Associativity
3. Commutativity
4. Distributivity
5. Identity
6. Invertibility
2020 TAPEDZESA G., NUST 98
Boolean Algebra
Boolean algebra is defined by a set of elements, B,
on which are defined two binary operations + and
*, and a unary operation ’ satisfying the following
axioms:
1. Closure
2. Associativity
3. Commutativity
4. Distributivity
5. Identity
6. Invertibility
7. Complementation
2020 TAPEDZESA G., NUST 99
Boolean Algebra
• The element 0 is called the zero element, the
element 1 is called the unit element, and a’ is
called the complement of a.
• The result of the operation + is called sum and
the result of the operation * is called product.
• We frequently write a*b simply as ab.
• We adopt the usual convention that, unless
we are guided by parentheses, ‘has
precedence over *, then +
For example, a+b*c =a+(b*c) or a+bc.
2020 TAPEDZESA G., NUST 100
Examples and Exercises
1. Consider the Boolean algebra
𝐷70 = 1, 2, 5, 7, 10, 14, 35, 70
Define the operations +, * and ‘ on 𝐷70 by
𝑎 + 𝑏 ≡ 𝑙𝑐𝑚 𝑎, 𝑏
𝑎 ∗ 𝑏 ≡ 𝑔𝑐𝑑 𝑎, 𝑏

70
𝑎 =
𝑎
a) Identify the zero element and the unit element of
𝐷70 .
b) Find the value of
i. 35 ∗ (2 + 7′ ) (ii) 35 ∗ 10 + 14′ (iii) 2 + 7 ∗ (14 ∗ 10)′

2020 TAPEDZESA G., NUST 101


2. Consider the Boolean algebra
𝐷110 = 1, 2, 5, 10, 11, 22, 55, 110
Define the operations +, * and ‘ on 𝐷110 by
𝑎 + 𝑏 ≡ 𝑙𝑐𝑚 𝑎, 𝑏
𝑎 ∗ 𝑏 ≡ 𝑔𝑐𝑑 𝑎, 𝑏

110
𝑎 =
𝑎
a) Identify the zero element and the unit element
of 𝐷110 .
b) Find the value of
i. 22 ∗ (5 + 10) (ii) 55 ∗ 10 ′ + 2 (iii) 2 + 11′ ∗ 22

2020 TAPEDZESA G., NUST 102


3. Consider the Boolean algebra
𝐵 = 0, 1
with operations + and * as defined in the tables
below:
+ 1 0 * 1 0

1 1 1 1 1 0
0 1 0 0 0 0

Suppose that complements are defined by 1′ = 0 and 0′ = 1.


Evaluate
a) 1 ∗ 0 + 1′
b) 1 + 1 ∗ 0′ + 0
c) 1′ + 0′ + (1 ∗ 0′ )′

2020 TAPEDZESA G., NUST 103


The Principle of Duality
The dual of any statement in a Boolean
algebra B is the statement obtained by
interchanging the operations of + and
*, and interchanging the
corresponding identity elements 0 and
1, in the original statement.

2020 TAPEDZESA G., NUST 104


Exercises: Duality
Write the dual of each of the following
Boolean equations:

1. 𝑎 ∗ 1 ∗ 0 + 𝑎 = 0
2. 𝑎 + 𝑎′ 𝑏 = 𝑎 + 𝑏
3. 𝑎 𝑎′ + 𝑏 = 𝑎𝑏
4. 𝑎 + 1 𝑎 + 0 = 𝑎
5. 𝑎 + 𝑏 𝑏 + 𝑐 = 𝑎𝑐 + 𝑏
2020 TAPEDZESA G., NUST 105
Boolean Algebra Identities

2020 TAPEDZESA G., NUST 106


Boolean Expressions;
Sum-of-Products Form
• A Boolean expression is any variable or any
expression built up from the variables using the
Boolean operators =, * and ‘.
• The following are examples of Boolean
expressions:
𝐸 = 𝑥 + 𝑦 ′ 𝑧 ′ + 𝑥𝑦𝑧 ′ + 𝑥 ′ 𝑦 ′
and
𝐹 = 𝑥𝑦 ′ 𝑧 ′ + 𝑦 + 𝑥 ′ 𝑧 ′
• A literal is a variable or a complemented variable, e.g.
𝑥, 𝑥 ′ , 𝑦, 𝑦 ′ , ⋯

2020 TAPEDZESA G., NUST 107


Boolean Expressions;
Sum-of-Products Form
• A fundamental product is a literal or a product
of two or more literals in which no two literals
involve the same variable
• For example, 𝑥𝑧 ′ , 𝑥𝑦 ′ 𝑧, 𝑥, 𝑦 ′ , 𝑥 ′ 𝑦𝑧 are
fundamental products.
• However, xyx’z and xyzy are not fundamental products
(why?)
• In fact, 𝑥𝑦𝑥 ′ 𝑧 = 0 and 𝑥𝑦𝑧𝑦 = 𝑥𝑦𝑧. Verify.
• Any Boolean product can be reduced to either 0 or a
fundamental product.
2020 TAPEDZESA G., NUST 108
Fundamental Product
• A fundamental product, P, is said to be included
in or contained in another fundamental product,
Q, if the literals of P are also literals of Q.
• For example, x’z is included in x’yz, since x’ and
z are literals in x’yz. However, x’z is not
contained in xy’z, since ….
• If P is included in Q, then by the absorption law
𝑃+𝑄 =𝑃
For example, 𝑥 ′ 𝑧 + 𝑥 ′ 𝑦𝑧 = 𝑥 ′ 𝑧

2020 TAPEDZESA G., NUST 109


Sum-of-Products Form
• A Boolean expression E is said to be in sum of-
products form or in minterm form if E is
fundamental product or the sum of two or more
fundamental products none of which is included
in another
• For example, consider the expressions
𝐸1 = 𝑥𝑧 ′ + 𝑦 ′ 𝑧 + 𝑥𝑦𝑧 ′ 𝑎𝑛𝑑
𝐸2 = 𝑥𝑧 ′ + 𝑥 ′ 𝑦𝑧 ′ + 𝑥𝑦 ′ 𝑧
• Any nonzero Boolean expression E can be put
into a sum-of-products form

2020 TAPEDZESA G., NUST 110


Complete Sum-of-Products Form
• A Boolean expression, E, is said to be in complete sum-of-
products form if E is in a sum-of-products form and each
product involves all the variables
• For example, we can put the following Boolean expression
𝑬𝟏 = 𝒙 𝒚′ 𝒛 ′ into sum-of-product form, and then into
complete sum-of-products form:
𝐸1 = 𝑥 𝑦 ′ 𝑧 ′ = 𝑥 𝑦 + 𝑧 ′ = 𝑥𝑦 + 𝑥𝑧
which is in sum-of-products form). Next we have
𝐸1 = 𝑥𝑦 + 𝑥𝑧 ′ = 𝑥𝑦 𝑧 + 𝑧 ′ + 𝑥𝑧 ′ 𝑦 + 𝑦 ′
= 𝑥𝑦𝑧 + 𝑥𝑦𝑧 ′ + 𝑥𝑦𝑧 ′ + 𝑥𝑦 ′ 𝑧 ′ = 𝑥𝑦𝑧 + 𝑥𝑦𝑧 ′ + 𝑥𝑦 ′ ,
which is in the complete sum-of-products form.
Every nonzero Boolean expression, E, can be put into
complete sum-of-products form, and such a representation is
unique.
2020 TAPEDZESA G., NUST 111
Exercises
1. Put each of the following Boolean expressions into
sum-of-products form, and then into complete
sum-of-products form:
a) 𝑥 𝑥𝑦 ′ + 𝑥 ′ 𝑦 + 𝑦 ′ 𝑧
b) 𝑧 𝑥 ′ + 𝑦 + 𝑦′
c) 𝑥 ′ + 𝑦 + 𝑥 ′ 𝑦
d) 𝑥 + 𝑦 ′ 𝑧 𝑦 + 𝑧′
e) 𝑥 ′ 𝑦 ′ 𝑥 ′ + 𝑥𝑦𝑧′
f) 𝑥 + 𝑦 ′ 𝑥𝑦 ′ ′
g) 𝑥 ′ + 𝑦 ′ + 𝑦 ′ 𝑧
h) 𝑦 𝑥 + 𝑦𝑧 ′
2. Let 𝐸 = 𝑥𝑦 ′ + 𝑥𝑦𝑧 ′ + 𝑥 ′ 𝑦𝑧′. Prove that 𝑥𝑧 ′ + 𝐸 = 𝐸.

2020 TAPEDZESA G., NUST 112


Logic Gates
• Logic circuits perform operations on digital signals and
are usually implemented as electronic circuits where
the signal values are restricted to a few discrete values.
• In binary logic circuits there are only two values, 0
and 1: In decimal logic circuits there are 10 values,
from 0 to 9: Since each signal value is naturally
represented by a digit, such logic circuits are
referred to as digital circuits.
• In contrast, there exist analog circuits where the
signals may take on a continuous range of values
between some minimum and maximum levels.
2020 TAPEDZESA G., NUST 113
Logic Gates
• A logic gate is an elementary building block of a
digital circuit
• Most logic gates have two inputs and one
output. At any given moment, every terminal is
in one of the two conditions True (0) or False (1).
• The logic state of a terminal can, and generally
does, change often, as the circuit processes
data.
• There are seven basic logic gates: AND, OR, XOR,
NOT, NAND, NOR, and XNOR.
2020 TAPEDZESA G., NUST 114
The AND Gate
• The AND gate is so named because, if 0 is called
"false" and 1 is called "true," the gate acts in the
same way as the logical "and" operator
• The output is "true" when both inputs are "true."
Otherwise, the output is "false.“
For example, suppose A and B are inputs assigned
the following sequences of bits:
𝐴 = 11000110 and 𝐵 = 01101101
Then the AND gate will produce the sequence
𝐴 ⋅ 𝐵 = 01000100
2020 TAPEDZESA G., NUST 115
The AND Gate
• The circuit symbol for an AND gate is
shown below. Note that AND gates may
have more than two inputs
• In the circuit symbol, the input terminals
are at left and the output terminal is at
right

2020 TAPEDZESA G., NUST 116


The AND Gate
• Usually we want to know the output of a logic circuit for all
different possible combinations of input bits
• In general, special sequences which give these different
combinations for n inputs will contain 2n bits
• The value of the output for these special sequences is
called the truth table for the circuit
• Below is the truth table for the AND gate:
A B 𝑨⋅𝑩
1 1 1
1 0 0
0 1 0
0 0 0

2020 TAPEDZESA G., NUST 117


The OR Gate
• The OR gate gets its name from the fact that it behaves
after the fashion of the logical inclusive "or."
• The output is "true" if either or both of the inputs are
"true." If both inputs are "false," then the output is
"false”.
For example, suppose A and B are inputs assigned the
following sequences of bits:
𝐴 = 11000110 and 𝐵 = 10010101
Then the OR gate will produce the sequence
𝐴 + 𝐵 = 11010111

2020 TAPEDZESA G., NUST 118


The OR Gate
• The circuit symbol and truth table for an OR gate are
shown below. An OR gate may also have more than two
inputs

A B A+B
1 1 1
1 0 1
0 1 1
0 0 0

2020 TAPEDZESA G., NUST 119


The NOT Gate
• The NOT gate, also known as the logical inverter, reverses
the logic state
• The output is "true" if either or both of the inputs are
"true." If both inputs are "false," then the output is
"false”.

2020 TAPEDZESA G., NUST 120


Logic Circuits
• A logic circuit or a logic network is simply a network of gates
• Using combinations of logic gates, complex operations can
be performed
• In theory, there is no limit to the number of gates that can
be arrayed together in a single device
• But in practice, there is a limit to the number of gates that
can be packed into a given physical space
• In general, a logic function can be implemented with a
variety of different networks, probably having different costs
• This raises an important question: How does one find the
best implementation for a given function?

2020 TAPEDZESA G., NUST 121


Logic Circuits
• Logic circuits satisfy the same laws as do
propositions and hence they form a Boolean algebra
• The circuits come in various patterns, but in this
section we will only be concerned with a pattern
that corresponds to a Boolean sum-of-products form
• Specifically, an AND-OR circuit has several inputs,
including complemented inputs, fed into a single or
more AND gates
• The outputs of all the AND gates are then fed into a
single OR gate which gives the output for the circuit

2020 TAPEDZESA G., NUST 122


• The complexity of a given network has a direct
impact on its cost
• Because it is always desirable to reduce the cost
of any manufactured product, it is important to
find ways for implementing logic circuits as
inexpensively as possible
• Any given logic function can be implemented
with a number of different networks
• This raises an important question: How does
one find the best implementation for a given
function?
2020 TAPEDZESA G., NUST 123
Logic Circuit Design
• A designer of digital systems is faced with two
basic issues
• For an existing logic network, it must be
possible to determine the function performed
by the network. This task is referred to as the
analysis process
• The reverse task of designing a new network
that implements a desired functional behavior
is referred to as the synthesis process

2020 TAPEDZESA G., NUST 124


Example
Consider the logic circuit below:

We label the first AND gate with inputs 𝑥1 and 𝑥2 , and output 𝑥1 ⋅
𝑥2 ; the second AND gate with inputs 𝑥1′ and 𝑥2 , and output 𝑥1′ ⋅ 𝑥2 ;
and the third 𝑥1′ and 𝑥2′ , and output 𝑥1′ ⋅ 𝑥2′ . The output of the OR
gate which is the output of the circuit, is the Boolean expression
(which is already a Boolean sum-of-products):
𝑓 = 𝑥1 ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2′

2020 TAPEDZESA G., NUST 125


The truth table of the circuit is therefore
𝑥1 𝑥2 𝑥1′ 𝑥2′ 𝑥1 ⋅ 𝑥2 𝑥1′ ⋅ 𝑥2 𝑥1′ ⋅ 𝑥2′ 𝑓
1 1 0 0 1 0 0 1
1 0 0 1 0 0 0 0
0 1 1 0 0 1 0 1
0 0 1 1 0 0 1 1

• Although this network implements 𝑓


correctly, it is not the simplest such network
• To find a simpler network, we can
manipulate the obtained expression using
the axioms and theorems of Boolean algebra
as follows:
2020 TAPEDZESA G., NUST 126
The output 𝑓 of the original logic circuit can be
simplified as
𝑓 𝑥1 , 𝑥2 = 𝑥1 ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2′
= 𝑥1 ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2 + 𝑥1′ ⋅ 𝑥2′
= (𝑥1 +𝑥1′ ) ⋅ 𝑥2 + 𝑥1′ (𝑥2′ + 𝑥2 )
= 1 ⋅ 𝑥2 + 𝑥1′ ⋅ 1
= 𝑥2 + 𝑥1′
Thus the original logic circuit can be replaced by the
simpler, but equivalent, logic circuit shown below:

Obviously, the cost of this simpler network is much


less than the cost of the original network.

2020 TAPEDZESA G., NUST 127


Exercises
1. How would each of the following pairs of
sequences of bits be processed by (a) an AND
gate? (b) an OR gate?
i. 110001 and 101101
ii. 10001111 and 00111100
iii. 101 100 111 000 and 000 111 001 101
2. How would a NOT gate process each of the
following sequences?
(a) 110001 (b) 10001111 (c) 101 100 111 000
2020 TAPEDZESA G., NUST 128
3. If
𝐴 = 1100110111,
𝐵 = 0001110110,
𝐶 = 1010110011
evaluate
a) 𝐴′ + 𝐵 ∗ 𝐶 ′
b) 𝐵(𝐴 + 𝐶)′

4. For each of the logic circuits on the next slide


a) formulate the output 𝑓 as a Boolean expression in
the inputs 𝑥1 , 𝑥2 and 𝑥3 .
b) find the truth table of the circuit.

2020 TAPEDZESA G., NUST 129


i.

ii.

iii.

2020 TAPEDZESA G., NUST 130


5. Show, by means of truth tables, that the
following logic circuits are equivalent, and
hence comment.

2020 TAPEDZESA G., NUST 131


CHAPTER 8: COMBINATORICS
Counting seems very simple; but it can be really
quite complex.
Combinatorial analysis is concerned with
determining the number of logical possibilities
of some event without necessarily enumerating
each case, lest we run out of space and time.
In this chapter we shall discuss three basic
counting rules:
• the fundamental principle of counting
• the permutations rules
• the combinations rules.
2020 TAPEDZESA G., NUST 132
The Fundamental Principle of Counting
If some event can occur in 𝑛1 different ways,
and a second event can occur in 𝑛2 different
ways, a third event can occur in 𝑛3 different
ways, and so on and so on; then the number of
ways the events can collectively occur is
𝑛1 × 𝑛2 × 𝑛3 × ⋯
Example: A restaurant menu has a choice of four
starters, 10 main courses and six desserts. What
is the total number of possible different meals
that can be ordered from this restaurant?

2020 TAPEDZESA G., NUST 133


Solution: There are three events:
starter (𝑛1 = 4), main course (𝑛2 = 10) and dessert (𝑛3 = 6)
The total number of possible (unique) meals
(each consisting of a starter, a main and a
dessert) that can be ordered is 4 × 10 × 6 = 240.
Exercise: A computer store sells 6 different CPUs,
4 different monitors, 5 different printers, and 3
different multimedia packages. How many
different computer systems are available?

2020 TAPEDZESA G., NUST 134


Factorial Notation
The notation 𝑛!, which reads “𝑛 factorial” denotes the
product of all whole numbers from 1 to 𝑛. That is,
𝑛! = 1 × 2 × 3 × ⋯ × 𝑛 − 2 𝑛 − 1 𝑛
with 1! = 1 and 0! = 1.
Examples:
1. 3! = 1 × 2 × 3 = 6
2. 5! = 1 × 2 × 3 × 4 × 5 = 120
8! 1×2×3×4×5×6×7×8
3. = = 8 × 7 = 56
6! 1×2×3×4×6

12! 9!×10×11×12
4. = = 10 × 11 × 12 = 1320
9! 9!

2020 TAPEDZESA G., NUST 135


Exercises
1. Compute
13! 7!
a) 7! (b) (c)
11! 12!
2. Write in terms of factorials:
1
a) 26 ∙ 27 (b)
14∙13∙12

2020 TAPEDZESA G., NUST 136


𝒏
Binomial Coefficients
𝒓
𝑛
The binomial coefficients, denoted by , are
𝑟
defined by
𝑛 𝑛!
=
𝑟 𝑟! 𝑛 − 𝑟 !
Examples:
8 8! 8! 7×8×6! 7×8
a) = = = = = 28
2 2! 8−2 ! 2!6! 2!6! 1×2
10 10! 8×9×10
b) = = = 120
3 3!7! 1×2×3

2020 TAPEDZESA G., NUST 137


Exercises
1. Compute
9 15 13 16
a) (b) (c) (d)
4 5 1 3
2. Simplify
𝒏! (𝒏−𝟐)!
a) (b)
𝒏−𝟏 ! 𝒏!
3. Suppose a state’s license plate consists of 3 numbers followed
by 3 letters. However, no two letters or numbers can be the
same (i.e. no repetition is allowed). How many different license
plates can be made?
4. Prove that
𝒏 𝒏
a) 𝒓
=
𝒏−𝒓
𝒏+𝟏 𝒏 𝒏
b) = +
𝒓 𝒓−𝟏 𝒓

2020 TAPEDZESA G., NUST 138


Pascal’s Triangle
𝑛
The numbers are called binomial coefficients since
𝑟
they appear as the coefficients in the expansion of
(𝑎 + 𝑏)𝑛 . The coefficients in the expansions of the
successive powers of 𝑎 + 𝑏 can be arranged in a triangular
array of numbers, called Pascal’s triangle, as shown:

DETAILED NOTES ON BINOMIAL EXPANSIONS ARE ATTACHED SEPARATELY

2020 TAPEDZESA G., NUST 139


2020 TAPEDZESA G., NUST 140
Permutations
An arrangement of a set of n objects or elements in a given order is called a
permutation of the objects (taken all the n objects at a time).
Any arrangement of any number of these objects, say r, in a given order is
called a permutation of n objects taken r at a time.
Consider, for example, the set of letters a, b, c and d. Then
a) abcd, abdc, acbd, acdb, adcb, adbc, bacd, badc, bcad, bcda, bdac,
bdca, cabd, cadb, cbad, cbda, cdab, cdba
are all the possible permutations of the 4 letters (taken all at a time).
b) abc, acb, abd, adb, acd, adc, bac, bca, bad, bda, bcd, bdc, cab, cba,
cbd, cdb
are all the possible permutations of the 4 letters taken 3 at a time).
c) ab, ba, ac, ca, ad, da, bc, cb, bd, db, cd, dc
are permutations of the 4 letters taken 2 at a time.

2020 TAPEDZESA G., NUST 141


Permutations
The number of permutations of n objects taken r at a
time is denoted by 𝑃 𝑛, 𝑟 , 𝑃𝑛,𝑟 , etc., is defined by
𝑛!
𝑃 𝑛, 𝑟 =
𝑛−𝑟 !
In the special case in which 𝑟 = 𝑛, we have
𝑃 𝑛, 𝑟 = 𝑛 𝑛 − 1 𝑛 − 2 ⋯ 3 ∙ 2 ∙ 1 = 𝑛!
In other words, there are 𝑛! Permutations of 𝑛 objects
(taken all at a time).
For instance, there are 3! = 1 ∙ 2 ∙ 3 = 6 different
permutations of the three letters 𝑎, 𝑏, 𝑐. Verify.

2020 TAPEDZESA G., NUST 142


Exercises
1. Lynn is taking thirteen pre-schoolers to
the park. How many ways can the
children line up, in single file, to board
the van?
2. How many different permutations, of
four letters, can be made from the
letters of the word LOVE
3. How many different permutations,
taking 3 at a time, can be made from
the 4 letters above?
2020 TAPEDZESA G., NUST 143
4. In how many ways can we assign 8
people to eight different jobs?
5. In how many ways can 4
mathematics books, 3 history books,
3 chemistry books and 2 sociology
books be arranged on a shelf so that
all books of the same subject are
together?

2020 TAPEDZESA G., NUST 144


6.The are 4 bus lines between A and
B; and 3 bus lines between B and C.
In how many ways can a commuter
travel
a) by bus from A to C via B?
b) roundtrip by bus from A to C via B?
c) roundtrip by bus from A to C via B,
without using any bus line more
than once?

2020 TAPEDZESA G., NUST 145


7. In how many ways can a
party of seven people
arrange themselves in a
row of seven chairs?
8.Find n if (a) 𝑃 𝑛, 2 = 72 ;
(b) 𝑃 𝑛, 4 = 42𝑃(𝑛, 2) ;
(c) 2𝑃 𝑛, 2 + 50 = 𝑃(2𝑛, 2)
2020 TAPEDZESA G., NUST 146
Permutations with Repetitions; Partitions
Quite often, we want to find the number
of permutations of objects some of which
are alike. The general formula is as
follows:
The number of permutations of n objects
of which 𝒏𝟏 are alike in one respect, 𝒏𝟐
are alike in another respect, …, 𝒏𝒓 are
alike in yet another respect, is
𝑛!
𝑛1 ! 𝑛2 ! ⋯ 𝑛𝑟 !
2020 TAPEDZESA G., NUST 147
Example
1. Find the number of distinct permutations
that can be formed from all the letters of
each word:
a) RADAR
b) UNUSUAL
c) STATISTICS
d) SOCIOLOGICAL
e) CHARACTERISTICS
f) MISSISSIPPI
2020 TAPEDZESA G., NUST 148
Ordered Partitions
A partition is ordered if different subsets of
the partition have at least one characteristic
that distinguishes one from the other.
A set with n elements can be partitioned
into r ordered cells of 𝒏𝟏 , 𝒏𝟐 , ⋯ , 𝒏𝒓
elements in the following number of ways
𝑛!
𝑛1 ! 𝑛2 ! ⋯ 𝑛𝑟 !
where 𝒏𝟏 + 𝒏𝟐 + ⋯ + 𝒏𝒓 = 𝒏
2020 TAPEDZESA G., NUST 149
Example 1
Six friends Alan, Cassie, Maggie, Seth, Roger and
Beth have volunteered to help at a fundraising
show. One of them will hand out programs at
the door, two will run a refreshments stand and
three will help guests find their seats. In
assigning the friends to their duties, we need to
divide or partition the set of 6 friends into
disjoint subsets of 3, 2 and 1. There are a
number of different ways to do this, a few of
which are on the next slide:
2020 TAPEDZESA G., NUST 150
Clearly, it is easier to count the number of such partitions by
using our counting principles than it is by listing all of them.
Observe that all three subsets of the partition have
different sizes, so they are distinguishable from
each other. Hence, there are
𝑛! 6!
= = 60
𝑛1 ! 𝑛2 ! ⋯ 𝑛𝑟 ! 3! 2! 1!
possible partitions (ways that the 6 friends can assign
the duties among themselves).

2020 TAPEDZESA G., NUST 151


Example 2
If we wish to partition the group of six
friends into three groups of two, and assign
two to hand out programs, two to the
refreshments stand and two as ushers, we
have an ordered partition because the
groups have different assignments. The
following 6 partitions are counted as
different ordered partitions:

2020 TAPEDZESA G., NUST 152


𝑛! 6!
Hence, there are = = 90
𝑛1 !𝑛2 !⋯𝑛𝑟 ! 2!2!2!
possible partitions of two people for
each assignment.

2020 TAPEDZESA G., NUST 153


Exercises
1. A group of 12 new recruits at the Car Assembly Company
will be split into 3 groups. Four will be sent to the North,
three to the South and five to the East. In how many ways
can the group of new recruits be divided in this way?
Ans: 27 720
2. In how many ways may 9 toys be divided among 4 children,
if the youngest child is to get 3 toys and each of the other
children 2 toys?
3. A pre-school teacher will split her class of 15 pupils into
three groups with 5 pupils in each group. One group will
colour, a second group will play in the sand box and the
third group will take a nap. In how many ways can the
teacher form the groups? Ans: 756 756
2020 TAPEDZESA G., NUST 154
Unordered Partitions
A partition is unordered when no distinction is
made between subsets (that is, the order of the
subsets does not matter).
We use the following principle to determine the
number of unordered partitions:
The number of unordered pairs of n distinct
elements into 𝒏𝟏 cells containing 1 element each;
𝒏𝟐 cells containing 2 elements each, ⋯ , 𝒏𝒓 cells
containing r elements each is
𝑛!
[(1!)𝑛1 𝑛1 !] ∙ [(2!)𝑛2 𝑛2 !] ⋯ [(𝑟!)𝑛𝑟 𝑛𝑟 !]
where 1(𝑛1 ) + 2(𝑛2 ) + ⋯ + 𝑟(𝑛𝑟 ) = 𝑛

2020 TAPEDZESA G., NUST 155


Example
Suppose we wish to split our group of six friends Alan,
Cassie, Maggie, Seth, Roger and Beth into three groups with
two people in each group. In this case we do not have any
particular task for each group in mind and we are interested
in only finding out how many different ways we can divide
the group of 6 into pairs. We immediately observe that the
six pairings:

are just but the same unordered partition and is therefore


counted as a single unordered partition. Hence a set of 6
elements can be partitioned into 3 unordered subsets of 2
6!
elements in 2! 33! = 15 ways.
2020 TAPEDZESA G., NUST 156
Exercises
1. The draw for the first round of a soccer
tournament is about to be made. There are
32 teams in this competition. In how many
ways can they be paired up for the matches
in the first round.
2. Find the number partitions of a set of 20
elements into subsets of 2,2,2,4,4,3,3. No
distinction will be made between the
subsets except for their size.
Ans: 611 080 470 000
2020 TAPEDZESA G., NUST 157
3. In how many ways may 9 toys be sorted into
a pile of 3 toys, a pile of 2 toys, a pile of 2
toys and another pile of 2 toys? (compare
with exercise 2 in the previous section)
4. A math teacher wishes to split a class of
thirty students into groups. All groups will
work on the same problem. Five groups will
have 4 students, two groups will have 3
students and two groups will have 2
students. In how many way can the teacher
assign students to the groups?
Ans: 481 947 949 543 123 000 000
2020 TAPEDZESA G., NUST 158
Combinations
• In a permutation, the order of the selected elements is
essential. In contrast, a combination of given objects
means any selection (groping) of such objects without
regard to order.
• Each separate grouping of the r objects is called a
combination.
• The number of ways of selecting r objects from n
objects, not considering order of selection, denoted by,
𝑛!
𝐶(𝑛, 𝑟), is given by 𝐶 𝑛, 𝑟 =
𝑟! 𝑛−𝑟 !
Example: How many committees of three can be formed
from eight people?
8! 8!
Solution: 𝐶 8,3 = = = 56 different
3! 8−3 ! 3!5!
committees can be formed.

2020 TAPEDZESA G., NUST 159


Mixed Exercises
1.How many samples of 4 bolts can be drawn
from a lot of 80 bolts?
2.In how many different ways can we choose a
committee of 3 from 20 nominees?
3.A company produces fruit juice in 10
different flavours. A local supermarket sells
the product, but has only sufficient shelf
space to display three of the company’s 10
fruit juice flavours at a time. How many
possible combinations (groupings) of three
flavours can the fruit juice company display
on the local supermarket shelf ?
2020 TAPEDZESA G., NUST 160
Mixed Exercises
4. For a balanced investment portfolio
consisting of four equities, an investor must
select only one equity from each of nine
economic sectors (labelled 1 to 9). How many
different portfolios consisting of four equities
can be selected?
5. A selection of 10 tourist attractions is
available in Cape Town. How many separate
selections are there of three attractions, not
considering the order in which the three
attractions are visited?
2020 TAPEDZESA G., NUST 161
6.A planning committee for a major
development project, such as a shopping mall,
must consist of two architects and four
engineers. There are four architects and seven
engineers available from which to choose.
a)How many different combinations of
committee members can be formed?
b)If the committee must also include an
environmental lawyer, of which there are two
available, how many different committee
compositions are now possible?
2020 TAPEDZESA G., NUST 162
7. There are 12 students in a class.
a) In how many ways can the 12 students
perform three different tasks if 4 students are
to perform each task?
b) In how many ways can the 12 students be
partitioned into 3 teams, so that each team
contains 4 students?
c) In how many ways can the 12 students be
partitioned into 4 teams, such two teams
contain 4 students each and two teams
contain 2 students each?
2020 TAPEDZESA G., NUST 163
8. In how many different ways can we select a committee
consisting of 3 engineers, 2 biologists, and 2 chemists
from a pool of 10 engineers, 5 biologists, and 6 chemists?
9. A shipment of 10 television sets includes 3 that are
defective. In how many ways can a hotel purchase 4 of
these sets and receive at least 2defective sets?
10. Ten people are going to watch a world cup match in
three cars that will hold 2, 3, and 5 passengers
respectively. In how many ways is it possible to
transport the 9 people to the stadium using all cars?
11.A college plays 12 football games during a season. In
how many ways can the team end the season with 7
wins, 3 losses, and 2 ties?
2020 TAPEDZESA G., NUST 164
Tree Diagrams
A (rooted) tree diagrams augments
the fundamental principle of
counting by exhibiting all possible
outcomes of a sequence of events
where each event can occur in a
finite number of ways.

2020 TAPEDZESA G., NUST 165


Illustrative Examples
1. A café has a lunch special consisting of an
egg or a ham sandwich (E or H); milk, juice,
or coffee (M, J, or C); and yogurt or pie for
dessert (Y or P).
a) One item is chosen from each category. List
all possible meals. Use a tree diagram to
organize your work.
b) How many possible meals are there? Count
the ends of the branches of your tree
diagram.
c) How can you determine the number of
possible meals without listing all of them?
2020 TAPEDZESA G., NUST 166
2. A computer store sells 3 different
computers, 2 different monitors, 3
different printers, and 2 different
multimedia packages. How many
different computer systems are
available?
3. A golfer has 4 different hats, 3 gloves
and 2 pairs of shoes to pick from for his
round of golf. In how many ways can
he make his choices?
2020 TAPEDZESA G., NUST 167
4. You are ordering dinner at a restaurant. How many ways
can you order a meal if you have two choices for a drink (
coffee or tea ), three main courses to choose from (
chicken, beef, or fish ) and two desserts ( pie or cake ) ?
a) Use a tree diagram
b) Use the fundamental counting principle
5. Suppose you own a small deli. You offer 4 types of
meat (ham, turkey, roast beef, and pastrami) and 3
types of bread (white, wheat, and rye). How many
choices do your customers have for a meat sandwich?
a) Use a tree diagram.
b) Use the fundamental counting principle
2020 TAPEDZESA G., NUST 168
6.When you get ready to get dressed for school
you open your closet to find that you have the
following choices: a red, blue, or white shirt;
jeans or sweatpants; tennis shoes or sandals.
How many different outfits could be made with
these choices?
7.The school cafeteria restaurant offers a lunch
combo for $6 where a person can order: 1
sandwich (chicken, turkey, or grilled cheese); 1
side (fruit, yogurt, or soup); and 1 drink (juice,
or milk). Determine the possible number of
lunch combos.
2020 TAPEDZESA G., NUST 169
Limitation of Tree Diagrams
In cases where there are a large
number of operations being performed
together, it is not feasible to construct
a tree diagram. It is more reasonable to
use the Fundamental Counting
Principle to determine the number of
ways of performing all the tasks
together.
2020 TAPEDZESA G., NUST 170

S-ar putea să vă placă și