Discrete Math

Siraj Raval
19 Mar 201911:08

Summary

TLDRIn this video, Suraj introduces the importance of discrete mathematics in computer science, showcasing its relevance through a cybersecurity scenario involving cracking a password-protected database. He explains the foundational concepts of discrete math, such as graph theory, algorithms, number theory, recursion, and set theory, and demonstrates their practical applications. Suraj also highlights the role of logic in creating proofs for algorithms, providing a comprehensive overview of how discrete math underpins computer science.

Takeaways

  • 😀 Discrete mathematics is essential for coding and computer science, including areas like machine learning.
  • 🔍 Discrete math is a collection of mathematical branches that deal with discrete rather than continuous objects.
  • 📚 It is a fundamental part of computer science education and is included in most degree programs.
  • 🛣️ Discrete math helps in designing networks, message routing paths, web searches, algorithm analysis, and cryptographic protocols.
  • 🌐 Graph theory, a part of discrete math, is used to model relations between objects and find optimal paths, like the shortest path to a lab.
  • 🔑 Dijkstra's algorithm is highlighted as a famous method in computer science for finding the shortest path in a graph.
  • 🔒 The script discusses a scenario where a password-protected database needs to be accessed, requiring knowledge of discrete math to decrypt it.
  • 🔢 The concept of brute-forcing a password is introduced, along with combinatorics to calculate the number of possible combinations.
  • 🔄 Recursion is presented as a method in discrete math to solve problems by relying on solutions to smaller instances of the same problem.
  • 🔡 The Caesar cipher, a type of encryption, is explained as an example of how characters can be shifted to encode and decode messages.
  • 📊 Set theory, another aspect of discrete math, underlies relational databases and is used to compile reports from databases like SQL.
  • 📝 Logic in discrete math is crucial for creating proofs and reasoning in computer science, with propositions as the basic building blocks.

Q & A

  • Why is discrete mathematics important for computer science?

    -Discrete mathematics is important for computer science because it provides the mathematical language needed to design high-speed networks, message routing paths, perform web searches, analyze algorithms for efficiency, and design cryptographic protocols, among other applications.

  • What is the difference between discrete and continuous mathematics?

    -Discrete mathematics deals with objects in discrete bundles, such as individual items or integers, while continuous mathematics deals with objects that vary without interruption, like measurements that can take on any value within a range.

  • How is graph theory related to the problem of finding the shortest path in a network?

    -Graph theory is used to represent a network as a graph with vertices and edges. It helps in designing algorithms, like Dijkstra's shortest path algorithm, to compute the fastest route by considering the weights of the edges, which represent the time or distance between nodes.

  • What is Dijkstra's shortest path algorithm, and how does it work?

    -Dijkstra's algorithm is a procedure used to find the shortest path between nodes in a graph. It starts by marking the initial node with a distance of zero and the rest with infinity, then iteratively selects the unvisited node with the smallest distance, updates the distances of its neighbors, and marks it as visited until all nodes are visited.

  • How does the concept of recursion help in solving the password decryption problem?

    -Recursion is a method where a function calls itself with a modified argument to solve a problem by breaking it down into smaller instances. In the case of the password decryption, a recursive function can be used to apply a shift operation to each character in the string until the entire phrase is decrypted.

  • What is the significance of combinatorics in the context of the encrypted password?

    -Combinatorics helps in calculating the total number of possible combinations for the encrypted password. It shows that with 36 characters to choose from for each of the 6 positions, there are over 2 billion possible combinations, indicating the need for a more efficient approach than brute force.

  • How does number theory contribute to understanding the relationships between numbers in cryptography?

    -Number theory involves analyzing the mathematical relationships between numbers, such as odd and even numbers, prime numbers, and sequences like the Fibonacci sequence. This understanding can help in deciphering encryption methods, like the Caesar cipher, which is based on shifting letters by a fixed number of positions in the alphabet.

  • What is a relational database, and how is it connected to set theory?

    -A relational database is a type of database that organizes data into tables with rows and columns, allowing for complex queries and operations. It is based on set theory, which deals with the study of collections of elements, and operations like intersections and unions that are fundamental to SQL queries.

  • What is the role of logic in mathematical reasoning and computer science?

    -Logic provides the rules for understanding and reasoning with mathematical statements. It is the basis for all mathematical reasoning and has practical applications in computer science, such as in the creation of proofs and the development of algorithms and programming languages.

  • How can the concepts of discrete mathematics be applied to real-world problems like cracking a password-protected database?

    -The concepts of discrete mathematics, such as graph theory, combinatorics, recursion, number theory, and logic, can be applied to real-world problems like password decryption by providing the mathematical framework for designing algorithms, analyzing possible combinations, and logically reasoning through the decryption process.

Outlines

00:00

📚 Introduction to Discrete Mathematics in Computer Science

This paragraph introduces the importance of discrete mathematics in computer science and coding. It explains that discrete math is not a traditional branch of mathematics but a collection of topics that deal with discrete rather than continuous quantities. The video aims to provide an overview of foundational topics in discrete math, using a scenario where the viewer plays a cybersecurity agent tasked with cracking a password-protected database. The paragraph sets the stage for the practical applications of discrete math in computer science, such as designing networks, performing searches, analyzing algorithms, and cryptographic protocols.

05:01

🛤️ Applying Graph Theory and Dijkstra's Algorithm

The second paragraph delves into the application of graph theory and Dijkstra's shortest path algorithm in finding the quickest route to a lab. It describes how streets and intersections can be represented as a graph to calculate the fastest path, emphasizing the undirected nature of the graph. The paragraph outlines the steps of Dijkstra's algorithm, from marking the initial node to updating distances and visiting nodes, and concludes with the successful use of a Python script to find the shortest path, demonstrating the practical use of discrete math in problem-solving.

10:04

🔐 Decrypting Passwords with Discrete Math Techniques

This paragraph discusses the process of decrypting an encrypted password using various discrete math concepts. It starts with the idea of brute-forcing all possible character combinations and then moves on to exploring number theory and the relationships between numbers. The paragraph introduces the concept of recursion, explaining it as a method to solve problems by relying on solutions to smaller instances of the same problem. It then describes how a Caesar cipher was used to encrypt the password and how recursion was employed to crack it by shifting characters in the alphabet, ultimately revealing the password.

📊 Set Theory and Logic in Database Analysis

The final paragraph covers the use of set theory and logic in analyzing a database to compile a report of the top 10 wealthiest criminals. It explains how relational databases, such as SQL, are based on set theory and how operations on sets, like intersections and unions, are fundamental to database queries. The paragraph also touches on the role of logic in mathematical reasoning, discussing propositions and how they form the basis for proofs. It concludes with the creation of a proof for the decryption algorithm, showcasing the integral role of discrete math in computer science and logical reasoning.

Mindmap

Keywords

💡Discrete Mathematics

Discrete Mathematics is the study of mathematical structures that are fundamentally discrete rather than continuous. In the context of the video, it is presented as a crucial subject for computer science, covering topics that are not traditionally found in subjects like calculus or linear algebra. The video emphasizes its importance in fields such as designing networks, analyzing algorithms, and cryptographic protocols, illustrating its practical applications with the example of a cybersecurity agent cracking a password-protected database.

💡Graph Theory

Graph Theory is a branch of mathematics concerned with graphs, which are mathematical structures used to model pairwise relations between objects. The video uses the analogy of finding the shortest path to a lab to explain how graph theory can be applied to compute the fastest route on a network of streets represented as a graph. Dijkstra's shortest path algorithm is highlighted as a method to solve such problems within the realm of discrete mathematics.

💡Brute Force

Brute Force, in the context of the video, refers to the method of trying all possible combinations to find a solution, such as decrypting a password. The script mentions a brute-force script to try every combination of characters for a 6-character password, highlighting the impracticality of this approach given the vast number of combinations (over 2 billion), thus prompting the need for a more intelligent strategy.

💡Combinatorics

Combinatorics is the study of counting, both as a means and an end in obtaining results. The video uses combinatorics to calculate the total number of possible password combinations, demonstrating how it is part of discrete mathematics. It shows that with 36 characters to choose from for each of the 6 positions, the number of combinations is 36 to the power of 6.

💡Number Theory

Number Theory is the study of the properties and relationships of numbers, including odd and even numbers, prime numbers, and various sequences. In the video, the protagonist uses number theory to hypothesize that each character in the encrypted password could correspond to a number, leading to the discovery of a Caesar cipher used for encryption.

💡Recursion

Recursion in the video is introduced as a method of problem-solving where the solution depends on solutions to smaller instances of the same problem. It is exemplified by a recursive function used to decrypt the password by shifting characters in the string. The video humorously notes the self-referential nature of the term 'recursion' on Google.

💡Caesar Cipher

The Caesar Cipher is a simple encryption technique where each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. The video uses this method as the encryption technique for the password, which is decrypted by applying a shift operation to each character in the encrypted string.

💡Relational Database

A Relational Database is a type of database that stores data in tables, which is based on set theory, a part of discrete mathematics. The video mentions using SQL queries to compile a report of the top 10 wealthiest criminals from a database, illustrating the application of set theory in the form of operations on sets within a relational database system.

💡Set Theory

Set Theory is the branch of mathematics that deals with sets, which are collections of distinct elements. The video explains how set theory underpins relational databases and SQL operations, such as inner joins, which are analogous to the intersection of sets in set theory.

💡Logic

Logic, as discussed in the video, is the study of the principles of correct reasoning and the criteria for the validity of arguments. It is used to create proofs, such as the proof of the decryption algorithm in the video, where the decrypted text is represented as a function of character shifts within a set of possible characters.

Highlights

Discrete mathematics is essential for coding and computer science, becoming increasingly important in recent years.

Discrete math is a collection of math branches that deal with discrete rather than continuous objects.

Graph theory, a part of discrete math, is used for designing high-speed networks and message routing paths.

Dijkstra's shortest path algorithm is a famous computer science algorithm for finding the fastest route in an undirected graph.

Brute-forcing a 6-character password with alphanumeric characters results in over 2 billion possible combinations.

Combinatorics, a branch of discrete math, helps in counting the number of possible outcomes in a scenario.

Number theory, which involves analyzing mathematical relationships between numbers, is key to decrypting passwords.

Recursion, a method in discrete math, involves functions calling themselves to solve problems based on smaller instances.

The Caesar cipher is a simple encryption method where each letter is replaced by a letter a fixed number of positions down the alphabet.

Set theory, foundational to relational databases like SQL, is based on the concept of sets and their operations.

SQL queries can compile reports by selecting top records based on specific criteria, utilizing set theory principles.

Logic in discrete math specifies the meaning of mathematical statements and helps in reasoning and proving algorithms.

Propositions and truth tables are basic building blocks of logic used to construct proofs in computer science.

The video provides a free, open-source textbook on discrete math for further study.

Discrete math topics such as recursion, logic, and combinatorics form the basis of computer science.

The video concludes with the importance of discrete math in various computer science applications.

Transcripts

play00:00

discrete math will help us build trauma

play00:04

hello world it's Suraj and if you're

play00:07

interested in coding not just machine

play00:09

learning but any kind of coding you need

play00:11

to understand discrete mathematics it's

play00:13

become a really important subject in the

play00:15

past few years because of how useful it

play00:17

is in computer science in fact pretty

play00:20

much every single computer science

play00:22

degree program contains at least one

play00:24

course on discrete mathematics sometimes

play00:26

to liberal arts majors it's okay breathe

play00:29

I'm here now in this video I'm gonna

play00:32

give you an overview of the foundational

play00:34

topics in discrete math to help you

play00:36

understand how it all works

play00:38

learn about each of them by necessity

play00:40

since we'll play the role of a

play00:41

cybersecurity agent working for mi6 our

play00:44

task is to crack a password-protected

play00:46

database of international criminals

play00:49

that's stored on a USB Drive discrete

play00:51

math isn't actually the name of a

play00:53

traditional branch of mathematics like

play00:55

calculus or linear algebra is its

play00:57

instead a description of a set of

play00:59

branches of math that all have in common

play01:01

one feature they're discrete rather than

play01:04

continuous discrete stands for

play01:06

individually separate and distinct while

play01:08

continuous stands for forming an

play01:10

unbroken whole without interruption

play01:12

discrete math deals in objects in

play01:15

discrete bundles like one or two

play01:16

kendrick lamar albums at least three if

play01:19

you're a real fan especially down in

play01:20

contrast continuous math deals with

play01:23

objects that vary continuously like

play01:25

three point four centimeters from a wall

play01:27

a good analogy would be digital watches

play01:29

versus analog watches the ones where the

play01:32

second hand loops around continuously

play01:33

without stopping

play01:34

basically discrete data is able to take

play01:37

on only integer values but continuous

play01:39

data can take on any value discrete math

play01:42

was created several decades ago as the

play01:45

mathematical language of computer

play01:47

science colleges learned that

play01:49

traditional math subjects did not cover

play01:51

the type of math needed by computer

play01:53

scientists so they put a bunch of math

play01:55

topics together and called it discrete

play01:58

math discrete math helps us design high

play02:00

speed networks and message routing paths

play02:02

perform web searches analyzed algorithms

play02:05

for efficiency and design cryptographic

play02:07

protocols that can do things like

play02:09

automatically block any image of Wilson

play02:12

as a genie beyond cringy before we can

play02:15

start cracking the password to get the

play02:17

data on the USB drive we've got to get

play02:19

to the lab and there are a lot of

play02:20

different paths we can take they drive

play02:23

there but we're on a deadline so we want

play02:25

to get to the lab as fast as possible

play02:27

meaning we want to take the shortest

play02:29

path to compute this we'll need to

play02:31

represent the collection of streets and

play02:33

intersections as a graph so that we can

play02:36

design an algorithm that will calculate

play02:37

the fastest way to get there since each

play02:40

street is two-way this is an undirected

play02:42

graph so there's no distinction between

play02:44

the two vertices associated with each

play02:46

edge this is graph theory the study of

play02:49

graphs and an important part of discrete

play02:51

math graphs are mathematical structures

play02:54

used to model relations between objects

play02:56

in our case intersections in graph

play02:59

theory the problem of finding a path

play03:01

between two vertices such that the sum

play03:03

of the weights of its constituent edges

play03:05

is minimized would be ideal the weights

play03:08

in our case would be the time it takes

play03:09

to drive from one vertex to the other

play03:11

here we can use one of the most famous

play03:14

algorithms in computer science

play03:15

Dijkstra's shortest path algorithm which

play03:18

is a five step procedure luckily we're

play03:21

not in LA even Dijkstra is no match for

play03:23

its traffic we start by marking our

play03:26

initial node which is our current

play03:27

location with the current distance of

play03:29

zero and the rest with infinity then we

play03:32

set the non visited node with the

play03:33

smallest current distance as the current

play03:36

node for each neighbor of our current

play03:38

node we add the current distance of the

play03:40

current node with the weight of the edge

play03:42

connecting it to the neighbor if it's

play03:44

smaller than the current distance of n

play03:46

we set it as a new current distance of n

play03:48

we then mark the current node as visited

play03:50

and if there are any non visited nodes

play03:52

left we repeat the process starting at

play03:55

the second step until we visited all the

play03:57

nodes thanks to a little Python script

play04:00

we can easily find the shortest path to

play04:02

the lab saving us a lot of time now that

play04:04

we've arrived at the lab let's plug this

play04:06

USB into the computer to see what we've

play04:08

got here in order to access the database

play04:11

we need a password and we have the

play04:13

password here but it's encrypted we need

play04:15

to figure out how to decrypt it into the

play04:17

actual password the only thing we know

play04:20

is that the length of the password is 6

play04:22

characters long and it can contain

play04:24

either numbers alphab

play04:25

characters or both no emojis thankfully

play04:28

our first strategy here will be to see

play04:31

if we can write a script that will

play04:32

brute-force all possible combinations of

play04:35

every character a through Z and 1

play04:37

through 9 but when we start running the

play04:39

script it starts taking quite a while in

play04:41

the meantime let's try and calculate how

play04:44

many combinations are possible here

play04:46

since there are 26 letters and 10 digits

play04:48

we have a total of 36 characters to

play04:50

choose from for each position if we

play04:53

start from the left we can fill in the

play04:54

first position 36 possible ways for each

play04:57

of the 36 possibilities for the first

play04:59

character there are 36 possibilities for

play05:01

the second character that means our 36

play05:03

squared waste fill in the first two

play05:05

characters for each of the 36 squared

play05:08

ways to fill in the first two characters

play05:09

there are an additional 36 ways to fill

play05:12

in the third character so there are 36

play05:14

cubed ways to fill in the first three

play05:16

characters notice the pattern here and

play05:18

know that number 69 is not involved here

play05:20

the total number of possible

play05:22

combinations is 36 to the n where n is

play05:25

the length of the character field which

play05:27

is 6 in our case making it over 2

play05:29

billion possible combinations way too

play05:31

much to brute-force so we can go ahead

play05:34

and pause our script this is an example

play05:36

of common atour x the study of counting

play05:39

both has a means and an end in obtaining

play05:41

results and it's a part of discrete math

play05:43

we need to think of a smarter way to

play05:46

decode this password what if each of the

play05:48

characters in the string what's

play05:50

equivalent to a number and the actual

play05:52

password was solely numerical what could

play05:55

the mapping from characters and numbers

play05:56

be here

play05:57

maybe if we converted each character to

play06:00

its numerical position in the alphabet

play06:02

it would represent a prime number one

play06:05

that's X counts away from zero but if we

play06:08

try that out it doesn't work never may

play06:12

be the numerical version of it correlate

play06:14

to some sort of sequence here notice how

play06:16

I'm trying to categorize these integers

play06:17

into different numbered types based on

play06:20

their relationships the study of

play06:22

relationships between numbers is called

play06:25

number theory a part of discrete math

play06:27

there are odd numbers and even numbers

play06:30

square numbers Pythagorean triples the

play06:33

Fibonacci sequence number theory

play06:35

involves analyzing the mathematical

play06:37

relationships between numbers

play06:39

right now I'm trying to figure out the

play06:41

theory behind these numbers in

play06:42

particular maybe each letter of this

play06:45

text can actually be replaced by a

play06:47

letter some fixed number of positions

play06:49

down the alphabet the question then

play06:52

becomes how many positions let's write

play06:54

out a function for this one where we can

play06:56

call the function inside of itself for

play06:59

each character in the string we'll apply

play07:01

a shift operation and recursively call

play07:03

our function until we're done shifting

play07:05

the entire phrase recursion a part of

play07:08

discrete math is a way to solve a

play07:10

problem where the solution depends on

play07:12

solutions to smaller instances of the

play07:14

same problem if we google search the

play07:16

word recursion it recursively asks did

play07:19

you mean recursion which is a fun little

play07:21

easter egg from the programmers at

play07:23

Google in fact the internet is riddled

play07:25

with these a popular reddit threads top

play07:28

answer for the question what is

play07:30

recursion is a link to that very same

play07:32

post an example of recursion a recursive

play07:34

function is a function that calls itself

play07:36

until some base condition is true and

play07:39

the execution stops when we write out

play07:41

our recursive function we can try out

play07:43

different lengths of the possible shifts

play07:45

until we get one that works and it turns

play07:47

out that it's three shifts that was the

play07:50

password we just needed to shift the

play07:52

characters it turns out that this

play07:53

password was encrypted using what's

play07:56

called the Caesar cipher one of the

play07:58

simplest methods of encryption each

play08:00

letter of a given text is replaced by a

play08:02

letter some fixed number of positions

play08:04

down the alphabet for example with the

play08:06

shift of one a would be replaced by B B

play08:09

would become C and so on it's named

play08:11

after Julius Caesar who apparently use

play08:13

it to communicate with his officials is

play08:16

this ambition this is Bridgeland

play08:20

we now have the database of known

play08:21

criminals this is a sequel database and

play08:24

we'll want to compile a report for mi6

play08:27

now that we've cracked it and that lists

play08:28

the top 10 most wealthy criminals by

play08:31

amount of money they donated to

play08:32

underground organizations in order to do

play08:35

that we'll write some sequel queries

play08:37

which will select the top 10 highest

play08:39

spenders from a certain section of the

play08:40

database relational databases like

play08:43

sequel are based almost entirely upon

play08:45

set theory a part of discrete math as

play08:48

is nothing more than an unordered

play08:50

collection of elements with absolutely

play08:52

no duplicates even the most complicated

play08:55

sequel statements are nothing more than

play08:57

operations on sets a sequel inner join

play08:59

is the intersection of two sets for

play09:01

example a Venn diagram is an easy way to

play09:04

explain the concept of sets two

play09:06

different sets have distinct values and

play09:08

where they intersect they have similar

play09:10

values unions disjunctions there are all

play09:13

sorts of terminologies related to sets

play09:15

and this is what set theory is all about

play09:17

we can write down the top ten criminals

play09:20

for our report but we have one more step

play09:22

here we need to create a proof for our

play09:25

report to show mi6 how we crack the code

play09:27

the rules of logic a part of discrete

play09:30

math specify the meaning of mathematical

play09:32

statements they help us understand and

play09:34

reason with statements like there exists

play09:37

an integer that is not the sum of two

play09:38

squares it's the basis of all

play09:41

mathematical reasoning and has practical

play09:43

applications in all of computer science

play09:46

one of the basic building blocks of

play09:48

logic are propositions a declarative

play09:50

sentence that is either true or false

play09:52

but not both like DC is the capital of

play09:55

the USA is true while DC is the capital

play09:57

of Mexico is false negations truth

play10:00

tables combinations conjunctions we can

play10:03

build off of the basic rules of logic to

play10:05

create all sorts of proofs so logically

play10:08

speaking we can define the proof of our

play10:10

algorithm with the following equation

play10:12

where the decrypted version of the text

play10:14

is equal to each character shifting n

play10:16

degrees out of 26 possible characters

play10:19

mi6 is going to be very pleased with

play10:22

this we'll probably get a double ho

play10:23

status now license code so those are

play10:26

some of the major concepts in discrete

play10:29

math I've listed them all in the video

play10:31

description as well as a free

play10:33

open-source textbook I found on the

play10:34

topic of discrete math study it there

play10:37

are three things to remember from this

play10:39

video discrete math is a set of branches

play10:41

of math that all have in common the

play10:43

feature that they are discrete rather

play10:45

than continuous discrete data can only

play10:48

take on integer values whereas

play10:50

continuous data can take on any value

play10:52

and discrete math topics like recursion

play10:55

logic and community oryx help define the

play10:57

basis of compute

play10:58

signs what's your favorite topic and

play11:00

Matt let me know in the comments section

play11:01

and please subscribe for more

play11:03

programming videos for now I've got to

play11:05

check my logic so thanks for watching

Rate This

5.0 / 5 (0 votes)

Связанные теги
Discrete MathComputer ScienceCryptographyMI6 MissionGraph TheoryDijkstra's AlgorithmPassword CrackingRecursive FunctionsNumber TheorySet TheorySQL Queries
Вам нужно краткое изложение на английском?