## Discrete mathematics for Computer ScienceDiscrete mathematics is used to provide good knowledge across every area of computer science. In computer science, the applications of discrete mathematics are very vast and described as follows: ## Boolean algebraThe bits like one or zero is used to represent all data of the computer at a most fundamental level. Computers perform the calculations when they do some modification in these bits in accordance with The logical operators like 'and', 'or', and 'not' are used to develop low-level programming languages. When software developers develop any project, they mostly prefer high-level languages. Sometimes they want to optimize their code by reducing the low-level operations, and sometimes, they also directly operate on bits. Programmers can also control the program flow by using Boolean logic. That means they can define certain conditions and then control which instructions will be executed. Boolean algebra has various laws, which is described as follows: ## Commutative law:According to 1. A.B = B.A 2. A + B = B + A ## Associative law:According to 1. (A.B).C = A.(B.C) 2. (A + B) + C = A + (B + C) ## Distributive law:According to A.(B + C) = A.B + A.C ## AND law:If the binary operation uses 1. A.0 = 0 2. A.1 = A 3. A.A = A 4. A.Ā = 0 ## OR law:If the binary operation uses 1. A + 0 = A 2. A + 1 = 1 3. A + A = A 4. A + Ā = 1 ## Inverse Law:According to ```
A + Ā+= 1
``` Boolean algebra also has ## De morgan's First lawAccording to the (A.B) = A + B ## De morgan's Second lawAccording to the (A+B) = A.B ## Example of Boolean AlgebraIn this example, we will solve the expression We can write the above expression as below on the basis of Demorgan's law: C + (B + C) Now we will use the commutative law like this: (C + C) + B After that, we will use complement law like this: ```
1 + B = 1
``` Therefore, ```
C + BC = 1
``` ## Probability
A randomized algorithm is known as the more efficient and best algorithm when it comes to practice because they provide the exact computing of those tasks that are difficult to compute. Probability can be described as one of the foundations of data science as well as statistics. It is also known as one of the hottest fields in the industry. If students are studying probability on the basis of computer science, it will provide them a quantitative intuition, and it is useful in their everyday life and throughout their careers. We have the formula to specify the probability, Probability of event to happen P(E) = Number of favorable outcomes/Total Number of outcomes ## Example of ProbabilitySuppose there are 6 suits in a shop, in which 3 are green, 2 are purple, and 1 is orange. We will find the probability to pick an orange suit.
The probability will be calculated by dividing the number of orange suits in a shop by the total number of suits. So 2/6 = 1/3 ## Propositional LogicWhen a developer develops any project, it is important that he should be confident of getting desired results by running their code. We can use mathematics to describe the programs. The reason for their correctness is The most formal specification language can be called ## Examples of propositional logic:3+3=5 Narendra Modi is the Prime Minister. 'a' is a vowel. This example has three sentences that are propositions. Where the first sentence is False or invalid, and the last two sentences are True or Valid. Some examples are not propositional, which is described as follows: 1 + a = 5 Go on vacation and enjoy This example has two sentences that are not propositions because the first sentence may be false or true because the value of 'a' is not specified, so we can't say that it is true or false unless we specify the value and the last sentence don't have a truth value. ## Induction and RecursionIf we want to know the functional paradigm of programming, the key concepts which will be used are Many industries and companies like Facebook (Haskell), Amazon, Microsoft research(F*, Haskell), Apple(Swift), Oracle(JavaScript, Java 8), and Microsoft(F#) increases the adoption of functional paradigm for the general use and niche tasks. Data structure and algorithm can also be easily described using the ## Example of induction:Using the mathematical induction, show n < 2
We will assume that proposition of n is P(n): n < 2
We will assume that P(n): n < 2 Then we will show P(n+1): n+1 < 2 n + 1 < 2 ## Example of recursion:
We will describe the example of recursive defined function: f(0) = 5 f(n) = f(n-1) + 2
We will calculate the function's value like this: f(0) = 5 f(1) = f(0) + 2 = 5 + 2 = 7 f(2) = f(1) + 2 = 7 + 2 = 9 f(3) = f(2) + 2 = 9 + 2 = 11 This recursively defined function is equivalent to an explicitly defined function, which is described as follows: f (n) = 2n + 5
We will describe the example of recursive defined function: f(0) = 0 f(n) = f(n-1) + 2n-1
We will calculate the function's value like this: f(0) = 0 f(1) = f(0) + (2)(1) -1 = 0 + 2 - 1 = 1 f(2) = f(1) + (2)(2) -1 = 1 + 4 - 1 = 4 f(3) = f(2) + (2)(3) -1 = 4 + 6 -1 = 9 f(4) = f(3) + (2)(4) -1 = 9 + 8 -1 = 16 This recursively defined function is equivalent to an explicitly defined function, which is described as follows: f (n) = n ## Number TheoryIn the number theory, we will learn about the sets of positive whole numbers that can be 1, 2, 3, 4, 5, 6, etc. They are also known as the set of The mathematical basis for hashing is described by modular arithmetic, and it is the most useful tool for several applications. The files which are transferred by the internet are verified by the Checksum, and it is based on hashing. Data structures like hash map perform efficient operations by using modular arithmetic. In the operating system and computer architecture, number theory also provides the facility to use memory-related things. There are many familiar and non-familiar examples of number theory, which is described as follows: Even: 2, 4, 6, 8, 10, 12?.. Odd: 1, 3, 5, 7, 9?? Triangular: 1, 3, 6, 10, 15, 21?.. Prime: 2, 3, 5, 7, 11, 13, 17?? Fibonacci: 1, 1, 2, 3, 5, 8, 13, 21?.. Square: 1, 4, 9, 16, 25?. Cube: 1, 8, 27, 64??. Perfect: 6, 28, 496?. ## CountingWe can also develop quantitative intuitions by using The real-world application has a lot of different available resources that have a complicated tradeoff. Some tasks don't have a lot of space that's why they have to sacrifice their time for more space, while others require a fast algorithm because they can afford a huge space to achieve the speed. In a complex situation, we require to achieve a sweet spot in resource usages so that the system does not face the problem related to resource starvation and keeps running perfectly. Using counting, we are able to create these considerations in a structural manner. It can also provide a formal guarantee related to resource usage. ## Examples of Counting
In this example, we will calculate that how many 3-digit numbers can be formed from 2, 3, 4, 5 7, and 9 digits.
(6)(6)(6) = 216
Suppose Jack goes to a pizza shop and chooses to create his own pizza. The shop has 4 different kinds of sauces, 4 different kinds of breads, and 3 different kinds of cheese, but he can only choose one of each category. Now we have to find that how many different ways a pizza can be created.
(4)(4)(3) = 48 ## Graphs
The graph has the ability to answer questions and model the relationship. For example, when we use our navigation app to search for the fastest route from our office to our home, this app uses the graph search algorithm to search it. It will also show us the time during according to our vehicle. The graph is extensively used in computer science to represent a file system. It is also used in database, deep learning, functional programming, and other applications. ## Examples of Graphs:
In this graph, V = {u, v, w, x, y} E = {uv, uw, vx, wx, xy}
In this graph, V = {5, 6, 7, 8, 9} E = {56, 67, 78, 89, 59, 69, 68} Next TopicAbelian Groups in Discrete Mathematics |