Discrete Math
Key Takeaways
The video covers discrete math, a fundamental subject in computer science, including topics such as graph theory, set theory, number theory, combinatorics, and recursion, with applications in algorithms, databases, and security structures. It explains Dijkstra's shortest path algorithm and the Caesar cipher, and discusses the importance of discrete math in computer science.
Full Transcript
discrete math will help us build trauma hello world it's Suraj and if you're interested in coding not just machine learning but any kind of coding you need to understand discrete mathematics it's become a really important subject in the past few years because of how useful it is in computer science in fact pretty much every single computer science degree program contains at least one course on discrete mathematics sometimes to liberal arts majors it's okay breathe I'm here now in this video I'm gonna give you an overview of the foundational topics in discrete math to help you understand how it all works learn about each of them by necessity since we'll play the role of a cybersecurity agent working for mi6 our task is to crack a password-protected database of international criminals that's stored on a USB Drive discrete math isn't actually the name of a traditional branch of mathematics like calculus or linear algebra is its instead a description of a set of branches of math that all have in common one feature they're discrete rather than continuous discrete stands for individually separate and distinct while continuous stands for forming an unbroken whole without interruption discrete math deals in objects in discrete bundles like one or two kendrick lamar albums at least three if you're a real fan especially down in contrast continuous math deals with objects that vary continuously like three point four centimeters from a wall a good analogy would be digital watches versus analog watches the ones where the second hand loops around continuously without stopping basically discrete data is able to take on only integer values but continuous data can take on any value discrete math was created several decades ago as the mathematical language of computer science colleges learned that traditional math subjects did not cover the type of math needed by computer scientists so they put a bunch of math topics together and called it discrete math discrete math helps us design high speed networks and message routing paths perform web searches analyzed algorithms for efficiency and design cryptographic protocols that can do things like automatically block any image of Wilson as a genie beyond cringy before we can start cracking the password to get the data on the USB drive we've got to get to the lab and there are a lot of different paths we can take they drive there but we're on a deadline so we want to get to the lab as fast as possible meaning we want to take the shortest path to compute this we'll need to represent the collection of streets and intersections as a graph so that we can design an algorithm that will calculate the fastest way to get there since each street is two-way this is an undirected graph so there's no distinction between the two vertices associated with each edge this is graph theory the study of graphs and an important part of discrete math graphs are mathematical structures used to model relations between objects in our case intersections in graph theory the problem of finding a path between two vertices such that the sum of the weights of its constituent edges is minimized would be ideal the weights in our case would be the time it takes to drive from one vertex to the other here we can use one of the most famous algorithms in computer science Dijkstra's shortest path algorithm which is a five step procedure luckily we're not in LA even Dijkstra is no match for its traffic we start by marking our initial node which is our current location with the current distance of zero and the rest with infinity then we set the non visited node with the smallest current distance as the current node for each neighbor of our current node we add the current distance of the current node with the weight of the edge connecting it to the neighbor if it's smaller than the current distance of n we set it as a new current distance of n we then mark the current node as visited and if there are any non visited nodes left we repeat the process starting at the second step until we visited all the nodes thanks to a little Python script we can easily find the shortest path to the lab saving us a lot of time now that we've arrived at the lab let's plug this USB into the computer to see what we've got here in order to access the database we need a password and we have the password here but it's encrypted we need to figure out how to decrypt it into the actual password the only thing we know is that the length of the password is 6 characters long and it can contain either numbers alphab characters or both no emojis thankfully our first strategy here will be to see if we can write a script that will brute-force all possible combinations of every character a through Z and 1 through 9 but when we start running the script it starts taking quite a while in the meantime let's try and calculate how many combinations are possible here since there are 26 letters and 10 digits we have a total of 36 characters to choose from for each position if we start from the left we can fill in the first position 36 possible ways for each of the 36 possibilities for the first character there are 36 possibilities for the second character that means our 36 squared waste fill in the first two characters for each of the 36 squared ways to fill in the first two characters there are an additional 36 ways to fill in the third character so there are 36 cubed ways to fill in the first three characters notice the pattern here and know that number 69 is not involved here the total number of possible combinations is 36 to the n where n is the length of the character field which is 6 in our case making it over 2 billion possible combinations way too much to brute-force so we can go ahead and pause our script this is an example of common atour x the study of counting both has a means and an end in obtaining results and it's a part of discrete math we need to think of a smarter way to decode this password what if each of the characters in the string what's equivalent to a number and the actual password was solely numerical what could the mapping from characters and numbers be here maybe if we converted each character to its numerical position in the alphabet it would represent a prime number one that's X counts away from zero but if we try that out it doesn't work never may be the numerical version of it correlate to some sort of sequence here notice how I'm trying to categorize these integers into different numbered types based on their relationships the study of relationships between numbers is called number theory a part of discrete math there are odd numbers and even numbers square numbers Pythagorean triples the Fibonacci sequence number theory involves analyzing the mathematical relationships between numbers right now I'm trying to figure out the theory behind these numbers in particular maybe each letter of this text can actually be replaced by a letter some fixed number of positions down the alphabet the question then becomes how many positions let's write out a function for this one where we can call the function inside of itself for each character in the string we'll apply a shift operation and recursively call our function until we're done shifting the entire phrase recursion a part of discrete math is a way to solve a problem where the solution depends on solutions to smaller instances of the same problem if we google search the word recursion it recursively asks did you mean recursion which is a fun little easter egg from the programmers at Google in fact the internet is riddled with these a popular reddit threads top answer for the question what is recursion is a link to that very same post an example of recursion a recursive function is a function that calls itself until some base condition is true and the execution stops when we write out our recursive function we can try out different lengths of the possible shifts until we get one that works and it turns out that it's three shifts that was the password we just needed to shift the characters it turns out that this password was encrypted using what's called the Caesar cipher one of the simplest methods of encryption each letter of a given text is replaced by a letter some fixed number of positions down the alphabet for example with the shift of one a would be replaced by B B would become C and so on it's named after Julius Caesar who apparently use it to communicate with his officials is this ambition this is Bridgeland we now have the database of known criminals this is a sequel database and we'll want to compile a report for mi6 now that we've cracked it and that lists the top 10 most wealthy criminals by amount of money they donated to underground organizations in order to do that we'll write some sequel queries which will select the top 10 highest spenders from a certain section of the database relational databases like sequel are based almost entirely upon set theory a part of discrete math as is nothing more than an unordered collection of elements with absolutely no duplicates even the most complicated sequel statements are nothing more than operations on sets a sequel inner join is the intersection of two sets for example a Venn diagram is an easy way to explain the concept of sets two different sets have distinct values and where they intersect they have similar values unions disjunctions there are all sorts of terminologies related to sets and this is what set theory is all about we can write down the top ten criminals for our report but we have one more step here we need to create a proof for our report to show mi6 how we crack the code the rules of logic a part of discrete math specify the meaning of mathematical statements they help us understand and reason with statements like there exists an integer that is not the sum of two squares it's the basis of all mathematical reasoning and has practical applications in all of computer science one of the basic building blocks of logic are propositions a declarative sentence that is either true or false but not both like DC is the capital of the USA is true while DC is the capital of Mexico is false negations truth tables combinations conjunctions we can build off of the basic rules of logic to create all sorts of proofs so logically speaking we can define the proof of our algorithm with the following equation where the decrypted version of the text is equal to each character shifting n degrees out of 26 possible characters mi6 is going to be very pleased with this we'll probably get a double ho status now license code so those are some of the major concepts in discrete math I've listed them all in the video description as well as a free open-source textbook I found on the topic of discrete math study it there are three things to remember from this video discrete math is a set of branches of math that all have in common the feature that they are discrete rather than continuous discrete data can only take on integer values whereas continuous data can take on any value and discrete math topics like recursion logic and community oryx help define the basis of compute signs what's your favorite topic and Matt let me know in the comments section and please subscribe for more programming videos for now I've got to check my logic so thanks for watching
Original Description
Discrete Math is a subject everyone interested in Computer Science needs to understand. It consists of math branches like graph theory, set theory, number theory, & combinatorics. It helps create databases, algorithms, & security structures. In this video, I'll explain the most relevant topics in Discrete Math one by one as we try to decrypt the password for a SQL database. Along the way, we'll use discrete math in various ways. I wanted to see if I could summarize an important course I took in college in a single video. Enjoy!
Code for this video:
https://github.com/llSourcell/DiscreteMath
Please Subscribe! And Like. And comment. Thats what keeps me going.
Want more education? Connect with me here:
Twitter: https://twitter.com/sirajraval
instagram: https://www.instagram.com/sirajraval
Facebook: https://www.facebook.com/sirajology
More learning resources:
http://discrete.openmathbooks.org/home.php
https://cse.buffalo.edu/~rapaport/191/S09/whatisdiscmath.html
https://www.cs.odu.edu/~toida/nerzic/content/intro2discrete/intro2discrete.html
https://www.youtube.com/watch?v=YzfdL58virc
Join us at the School of AI:
https://theschool.ai/
Join us in the Wizards Slack channel:
http://wizards.herokuapp.com/
Please support me on Patreon:
https://www.patreon.com/user?u=3191693
Signup for my newsletter for exciting updates in the field of AI:
https://goo.gl/FZzJ5w Join my AI community: http://chatgptschool.io/ Sign up for my AI Sports betting Bot, WagerGPT! (500 spots available): https://www.wagergpt.xyz
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Siraj Raval · Siraj Raval · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
What is Bitcoin?
Siraj Raval
5 Ways to Use Bitcoin
Siraj Raval
BTC Fever - Siraj [Music Video]
Siraj Raval
5 Reasons to Build Decentralized Apps
Siraj Raval
The Interplanetary File System
Siraj Raval
How to Build a Dapp in 3 min
Siraj Raval
Life Before Smartphones
Siraj Raval
4 Ways to Use Smart Contracts
Siraj Raval
3 Dapps You HAVE to See
Siraj Raval
Char's Life as a BitTorrent Engineer
Siraj Raval
4 Reasons AlphaGo is a Huge Deal
Siraj Raval
Build a Neural Net in 4 Minutes
Siraj Raval
Sentiment Analysis in 4 Minutes
Siraj Raval
The Hackathon Life
Siraj Raval
Your First ML App - Machine Learning for Hackers #1
Siraj Raval
Build an AI Composer - Machine Learning for Hackers #2
Siraj Raval
Build a Game AI - Machine Learning for Hackers #3
Siraj Raval
Build a Movie Recommender - Machine Learning for Hackers #4
Siraj Raval
Build an AI Artist - Machine Learning for Hackers #5
Siraj Raval
Build a Chatbot - ML for Hackers #6
Siraj Raval
Build an AI Reader - Machine Learning for Hackers #7
Siraj Raval
Build an AI Writer - Machine Learning for Hackers #8
Siraj Raval
Build a Chatbot w/ an API - ML for Hackers #9
Siraj Raval
One-Shot Learning - Fresh Machine Learning #1
Siraj Raval
Generative Adversarial Nets - Fresh Machine Learning #2
Siraj Raval
Tone Analysis - Fresh Machine Learning #3
Siraj Raval
Generate Rap Lyrics - Fresh Machine Learning #4
Siraj Raval
Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Siraj Raval
Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Siraj Raval
Build an Antivirus in 5 Min - Fresh Machine Learning #7
Siraj Raval
TensorFlow in 5 Minutes (tutorial)
Siraj Raval
Build a Recurrent Neural Net in 5 Min
Siraj Raval
Build a Simulation in 5 Min
Siraj Raval
Build a TensorFlow Image Classifier in 5 Min
Siraj Raval
Tensorboard Explained in 5 Min
Siraj Raval
Generate Music in TensorFlow
Siraj Raval
Build a Game Bot (LIVE)
Siraj Raval
Deep Learning Frameworks Compared
Siraj Raval
Introduction - Learn Python for Data Science #1
Siraj Raval
Build a Neural Network (LIVE)
Siraj Raval
Twitter Sentiment Analysis - Learn Python for Data Science #2
Siraj Raval
Recommendation Systems - Learn Python for Data Science #3
Siraj Raval
Predicting Stock Prices - Learn Python for Data Science #4
Siraj Raval
Pong Neural Network (LIVE)
Siraj Raval
Deep Dream in TensorFlow - Learn Python for Data Science #5
Siraj Raval
Visualizing Data with D3.js (LIVE)
Siraj Raval
Genetic Algorithms - Learn Python for Data Science #6
Siraj Raval
Enter Siraj [Music Video]
Siraj Raval
Build a Web Scraper (LIVE)
Siraj Raval
Why is P vs NP Important?
Siraj Raval
How to Make a Neural Network (LIVE)
Siraj Raval
How to Make an Amazing Tensorflow Chatbot Easily
Siraj Raval
How to Make an Amazing Video Game Bot Easily
Siraj Raval
How to Make a Tensorflow Neural Network (LIVE)
Siraj Raval
How to Make a Simple Tensorflow Speech Recognizer
Siraj Raval
Joel Shor - Really Quick Questions with an Awesome Google Engineer
Siraj Raval
How to Make a Path Planning Algorithm Easily (LIVE)
Siraj Raval
The Best Way to Prepare a Dataset Easily
Siraj Raval
Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Siraj Raval
How to Make a Tic Tac Toe Neural Network Easily (LIVE)
Siraj Raval
More on: ML Maths Basics
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Web Scraping with Python in 2026: Best Libraries and Anti-Bot Strategies
Dev.to · Etrit Neziri
Python for Data Science — Probability Basics for Data Science
Medium · Data Science
Python for Data Science — Probability Basics for Data Science
Medium · Python
The Survivorship Bias in Your Funnel Data: Why Drop-Off Analysis Misses the Point
Medium · Data Science
🎓
Tutor Explanation
DeepCamp AI