Algorithms Explained for Beginners - How I Wish I Was Taught

Internet Made Coder
15 Oct 202217:38

Summary

TLDRThis video script emphasizes the significance of algorithms in the field of computer science and coding interviews. It explains that algorithms are a set of instructions to achieve a goal, and their efficiency is crucial when dealing with massive datasets as encountered by tech giants like Google and Facebook. The script introduces two search algorithms: linear search, which is straightforward but slow (O(n)), and binary search, which is faster (O(log n)) by narrowing down the search space significantly with each step. The importance of algorithm design is highlighted, as it can lead to substantial performance gains, even surpassing a decade's worth of hardware improvements. The video also touches on sorting algorithms, mentioning the inefficiency of basic algorithms compared to optimized ones like merge sort. It concludes with recommendations for learning more about algorithms through courses like CS50, online platforms like Zero to Mastery, and books like 'Cracking the Coding Interview', as well as the practical advice of solving problems on platforms like LeetCode.

Takeaways

  • 📘 Algorithms are a series of steps to perform an action or reach a goal, often involving data processing.
  • 🚀 The importance of algorithms is highlighted by their central role in coding interviews and the tech industry's focus on them.
  • 🧠 Designing efficient algorithms can allow us to solve much larger problems and achieve significant performance gains in technology.
  • 📈 The speed and memory usage of an algorithm are crucial factors, especially when dealing with large datasets as seen in companies like Google and Facebook.
  • 🔍 Linear search is a simple algorithm that checks each element in a list sequentially, but it's not efficient for large data sets.
  • 🔑 Big O notation is used to express the worst-case scenario of an algorithm's running time, which is essential for analyzing scalability.
  • ⏬ The binary search algorithm is more efficient than linear search as it reduces the problem size by half with each step, with a running time of O(log n).
  • 📚 Reading books or summaries like 'Algorithms to Live By' can provide insights into applying algorithmic thinking to everyday life.
  • 🎓 Taking courses like CS50, Zero to Mastery, Stanford's Algorithm Specialization, and Princeton's Algorithms Specializations can build a strong foundation in algorithms.
  • 📝 'Cracking the Coding Interview' is a valuable resource for reviewing key topics and practicing problems before interviews.
  • 💻 Regular practice on platforms like LeetCode is essential for mastering data structures and algorithms.

Q & A

  • What is the primary focus of the video?

    -The video focuses on explaining the importance of algorithms, why they are crucial in coding interviews, and how understanding them can help solve complex problems more efficiently.

  • Why do companies place a significant emphasis on algorithms during their recruitment process?

    -Companies emphasize algorithms because they are fundamental to solving large-scale problems that these companies face. The ability to design and understand efficient algorithms can lead to significant performance gains and is indicative of a candidate's problem-solving skills.

  • What is the basic definition of an algorithm?

    -An algorithm is a series of steps designed to perform a specific action or to reach a particular goal. It involves taking some input data and determining the logical steps a computer must take to produce the desired output.

  • Why is it important to study the speed of algorithms even when computers are very fast?

    -The speed of algorithms becomes critical when dealing with large datasets, as seen in companies like Google and Facebook. Even with fast computers, a poorly designed algorithm can lead to significantly longer processing times, which can affect the performance and efficiency of technology solutions.

  • What does the term 'Big O' refer to in the context of algorithms?

    -In computer science, 'Big O' refers to the worst-case scenario running time of an algorithm. It is a measure of how the runtime of an algorithm grows with the size of the input data, and it is used to predict the performance of an algorithm as the input size increases.

  • How does the linear search algorithm work?

    -The linear search algorithm works by sequentially checking each element in a list or book until the desired item is found. It is a straightforward but inefficient method, especially for large datasets, as it may require checking every single item in the worst-case scenario.

  • What is the main advantage of a binary search algorithm over a linear search?

    -The binary search algorithm has a significant advantage over linear search in terms of efficiency. It works by repeatedly dividing the search space in half, which reduces the problem size with each step. This approach results in a logarithmic running time (O(log n)), which is much faster than the linear time (O(n)) of a linear search for large datasets.

  • What are some resources recommended in the video for mastering algorithms and data structures?

    -The video recommends several resources, including CS50's third lecture, 'Zero to Mastery' coding courses, Stanford's Algorithm Specialization, Princeton's Algorithms I and II specializations, and the book 'Cracking the Coding Interview' for practice problems and interview preparation.

  • How does the video suggest one should approach learning algorithms and data structures?

    -The video suggests starting with a solid theoretical foundation through courses like CS50 or specialized algorithm courses. After gaining a theoretical understanding, one should then practice with resources like 'Cracking the Coding Interview' and engage in a lot of coding problems on platforms like LeetCode.

  • What is the role of Short Form in the video?

    -Short Form is mentioned as a sponsor of the video. They provide high-quality book summaries and study guides, which can be useful for quickly understanding the main ideas and concepts of a book before deciding to read it in full.

  • Why is it beneficial to understand the theory behind algorithms?

    -Understanding the theory behind algorithms is beneficial because it allows one to write efficient and effective code for solving complex problems. It also helps in performing well in coding interviews, which often focus on algorithmic thinking and problem-solving skills.

Outlines

00:00

📚 Introduction to Algorithms and Their Importance

The video begins by emphasizing the significance of algorithms in coding interviews and the tech industry. It mentions that understanding algorithms and data structures is crucial for anyone looking to succeed in these areas. The speaker aims to provide an intuitive understanding of algorithms, discussing why they are essential and how they are interconnected with data structures. The video also suggests a book titled 'Algorithms to Live By' for those interested in applying algorithmic thinking to everyday life, and highlights a sponsored service, Shortform, for book summaries.

05:02

🚀 The Relevance of Algorithm Efficiency

This paragraph delves into why algorithm efficiency matters, even with fast computers. It explains that for large-scale problems, such as those faced by companies like Google and Facebook, the design of an algorithm in terms of speed and memory consumption becomes critical. The video uses the analogy of searching for a page in a book to illustrate the concept of an algorithm and introduces the idea of Big O notation for expressing the worst-case scenario of an algorithm's running time.

10:03

🔍 Exploring Search Algorithms: Linear vs. Binary

The speaker explores two search algorithms: linear search and binary search. Linear search is described as a naive approach that checks each item sequentially, which is slow but guaranteed to find the target if it exists. On the other hand, binary search is introduced as a more efficient method that repeatedly divides the search space in half, significantly reducing the number of steps required to find the target. The video explains that binary search has a logarithmic running time, denoted as O(log n), which is much faster than linear search for large datasets.

15:03

📈 Sorting Algorithms and Their Performance

The video moves on to discuss sorting algorithms, noting that they are often the starting point for learning algorithms. It contrasts a slow sorting algorithm with O(N^2) complexity against a more efficient one like merge sort, which has a running time of O(N log n). The importance of using optimized algorithms is stressed, particularly for companies dealing with massive datasets. The video concludes with practical steps for mastering algorithms, including taking specific courses and practicing on platforms like LeetCode.

Mindmap

Keywords

💡Algorithms

Algorithms are a series of steps designed to perform a specific action or reach a particular goal. They are crucial in computer science for solving problems efficiently. In the video, the importance of algorithms is emphasized as they form a significant part of coding interviews and are essential for handling large data sets in companies like Google and Facebook.

💡Data Structures

Data structures are specialized formats for organizing, managing, and storing data. They are complementary to algorithms and often discussed together. The video mentions data structures as the first part of the equation in coding interviews, highlighting their interrelation with algorithms.

💡Big O Notation

Big O notation is a mathematical representation used to describe the performance or complexity of an algorithm. It expresses the upper bound of the time complexity in the worst-case scenario. In the video, Big O notation is used to illustrate the efficiency of different searching algorithms, such as linear search being O(n) and binary search being O(log n).

💡Linear Search

Linear search is a simple search algorithm that checks each element in a list sequentially until the desired item is found. It is characterized by its simplicity but inefficiency for large data sets. The video uses the example of finding a page in a book to explain how a linear search works.

💡Binary Search

Binary search is an efficient algorithm used for finding an item from a sorted list of items. It works by repeatedly dividing the list in half and then determining if the desired item is in the left or right half, thereby reducing the search space. The video demonstrates that binary search has a time complexity of O(log n), making it much faster than linear search for large data sets.

💡Sorting Algorithms

Sorting algorithms are used to rearrange a list of items into a particular order, typically ascending or descending. The video discusses the importance of sorting algorithms in computer science and how different algorithms can have vastly different efficiencies, with some scaling as O(N^2) and others as O(N log n).

💡Merge Sort

Merge sort is an efficient, general-purpose, comparison-based sorting algorithm. It works by dividing the list into smaller parts, sorting them, and then merging the sorted parts back together. The video mentions merge sort as an example of a more optimized sorting algorithm with a time complexity of O(N log n), which is more efficient than O(N^2) algorithms.

💡Computer Resources

Computer resources refer to the hardware and software capabilities available to perform computational tasks. The video discusses how the study of computer algorithms is about applying these resources to solve mathematical operations or problems more efficiently than the human brain can, especially when dealing with large data sets.

💡Coding Interviews

Coding interviews are a part of the recruitment process for software engineering roles where candidates are assessed on their problem-solving skills using data structures and algorithms. The video emphasizes the importance of algorithms and data structures in these interviews, as they are often the focus of the questions asked.

💡Short Form Summaries

Short Form Summaries, as mentioned in the video, provide condensed versions of books, including key insights and interactive exercises. They are used as a way to quickly understand the main ideas of a book before deciding to invest time in reading the full text. The video suggests using Short Form Summaries to grasp the concepts of books like 'Algorithms to Live By'.

💡Cracking the Coding Interview

Cracking the Coding Interview is a book that provides a review and overview of topics necessary for technical interviews, along with practice problems. The video recommends this book as a resource for practice after gaining a theoretical understanding from other courses or materials.

Highlights

Introduction to the importance of algorithms and their critical role in coding interviews and computer science.

Discussion on the necessity of understanding algorithms for technical interviews at major tech companies.

Explanation of what an algorithm is: a series of steps to reach a goal with given input data.

The historical context of algorithms, dating back a thousand years, and their evolution with computing.

Introduction to the book 'Algorithms to Live By' and its application to everyday life.

Importance of understanding the speed and efficiency of algorithms due to the computational limitations despite fast hardware.

Explanation of linear search and its inefficiency through the analogy of finding a page in a book.

Introduction to Big O notation to describe worst-case scenario running times of algorithms.

Generalization of running time analysis in terms of input size for scalability and practicality.

Discussion of binary search algorithm as a more efficient alternative to linear search.

Analysis of the binary search algorithm's logarithmic running time and its efficiency.

Comparison of sorting algorithms, specifically focusing on the inefficiency of bubble sort vs. the efficiency of merge sort.

Importance of designing efficient algorithms to handle large-scale problems like those encountered by Google and Facebook.

Recommended practical steps for mastering algorithms, including courses and resources like CS50's third lecture.

Tips for preparing for coding interviews using resources like 'Cracking the Coding Interview' and practicing on LeetCode.

Transcripts

play00:00

hello and welcome back today's video is

play00:02

a particularly important one because

play00:04

today's video is about algorithms maybe

play00:06

I don't need to convince you of the

play00:08

importance of algorithms if you are

play00:09

aware of how companies coding interviews

play00:12

are generally formatted you are probably

play00:15

aware that the sort of problems they ask

play00:17

in or the interviews are related to data

play00:20

structures and algorithms in my previous

play00:22

video in the series we went through the

play00:25

first part of this equation which is

play00:26

data structures and today by popular

play00:29

demand we will be covering the second

play00:31

part which is algorithms as in my

play00:34

previous video the goal of this video is

play00:36

to give you an intuitive understanding

play00:39

of what algorithms are why we need to

play00:42

study them why companies care so much

play00:45

about algorithms that literally their

play00:47

entire recruiting process is structured

play00:50

around testing these topics and of

play00:53

course as you know on this channel we

play00:55

always leave things off with practical

play00:57

steps that you can take and the things

play00:59

that you need to do Beyond this video to

play01:03

master these topics I think this could

play01:05

be one of the most important videos that

play01:07

you watch our algorithms because as I

play01:09

always say the most important aspect

play01:11

about learning anything to me is being

play01:13

excited about it and algorithms and data

play01:16

structures are the kind of thing that

play01:18

most people don't quite understand why

play01:20

they are so important and that is

play01:23

probably actually the thing that is

play01:25

holding you back the most in fact I

play01:26

think algorithms and data structures are

play01:28

some of the most beautiful things about

play01:30

coding and computer science and I hope

play01:32

that with this video I can give you a

play01:36

glimpse of this beauty and why I

play01:38

appreciate them so much so that you can

play01:40

actually start enjoying the process of

play01:43

learning them and therefore wanting to

play01:45

learn them more so what is an algorithm

play01:48

an algorithm is a series of steps to

play01:51

perform some action to reach some goal

play01:54

we have some input so some data that we

play01:56

want to do something to and we need to

play01:58

figure out what are the logical steps

play02:00

that we need to tell the computer to do

play02:02

to reach the output that we desire you

play02:06

can think of Designing a series of steps

play02:08

to complete really anything you think

play02:10

about a series of steps to get from your

play02:12

house to the gym for example I was

play02:14

reading about this the idea of

play02:15

algorithms is like a thousand years old

play02:18

so where do computers then come in well

play02:20

the study of computer algorithms is just

play02:23

about applying Computer Resources to

play02:26

solve mathematical operations or

play02:28

problems we want to solve instead of

play02:30

using the human brain to solve them and

play02:33

the advantage that computers have is a

play02:35

computer scan perform these operations

play02:37

blindly fast so that is really where

play02:39

computers come in but before we go

play02:41

deeper into specifically computer

play02:43

algorithms there's a great book about

play02:45

this idea of sort of applying

play02:47

algorithmic thinking to your everyday

play02:49

life it's called algorithms to live by

play02:52

at least I recommend reading a summary

play02:54

of it and an excellent way to get a

play02:56

really good summary is actually today's

play02:58

video sponsor short show form is the

play03:01

absolute best way I've found to get

play03:03

really high quality book summaries and

play03:05

the thing about short form their

play03:06

summaries are not just book summaries

play03:08

they're more like study guides with like

play03:11

in-depth analysis of the book they

play03:13

include a short version of the summary

play03:14

if you just want to get the main ideas

play03:16

plus chapter by chapter summaries

play03:18

including interactive exercises to

play03:21

actually apply the ideas of the book

play03:23

when you look at a book it can be

play03:24

difficult to tell whether that book is

play03:26

actually worth reading and so what I

play03:28

often do first before reading a book I

play03:30

will go read this short form guide of

play03:33

that book and then based on that I will

play03:35

decide whether the ideas of the book are

play03:37

actually something that I wanted to go

play03:38

deeper into by reading or listening to

play03:41

the entire book for example for me some

play03:42

of my favorite categories of books that

play03:44

they have are technology

play03:46

self-improvement business

play03:47

entrepreneurship productivity and in

play03:50

addition if you are a subscriber to

play03:51

short form you can actually vote on the

play03:54

next book that you would like them to

play03:56

make a summary of and because straw form

play03:58

are sponsoring this video you are in

play04:00

luck because you can go to the link in

play04:02

the description and get a 5 day

play04:04

unlimited access free trial as well as

play04:06

an additional 20 discount on the annual

play04:08

subscription and give a short form for

play04:10

sponsoring this video and now let's get

play04:12

into the meat of algorithms the big

play04:15

question I had in the beginning and I

play04:17

just couldn't really understand is if

play04:18

computers are so incredibly fast why

play04:21

does it even matter what kind of

play04:22

algorithms we design why do we care so

play04:25

much about the speed of algorithms on

play04:26

like studying the theory of like

play04:28

optimizing algorithms a lot because our

play04:30

computers are so fast right but when you

play04:32

think about sorting algorithms for

play04:34

example there's also a problem you might

play04:35

think about like sorting 100 numbers or

play04:37

something but when it comes to computer

play04:39

science and programming those are

play04:40

actually not the interesting problems

play04:42

any interesting problem in the domain of

play04:44

computer science and like in The Cutting

play04:46

Edge something that the input size is

play04:48

ridiculously big when you think about

play04:50

companies like Google and Facebook the

play04:52

data sizes that they run these

play04:53

algorithms with are not like a hundred

play04:55

or a thousand items they can be like

play04:57

billions and billions and billions in

play04:59

these scales even with the power of

play05:01

computers without we have today how your

play05:03

algorithm is designed as in how fast it

play05:06

is and how much memory it consumes

play05:09

really starts to matter a lot so

play05:11

simplify designing a faster algorithm

play05:13

weekend number one solve much bigger

play05:16

problems and number two we can literally

play05:19

like achieve the same performance gains

play05:21

in our technology as like a decade worth

play05:24

of computer process for Speed

play05:26

Improvement so in general about

play05:27

algorithms the things we care about or

play05:30

the speed at which it runs as well as

play05:33

the memory that it uses so the very very

play05:36

very low level we can think of the speed

play05:38

of an algorithm just ask how many

play05:41

instructions does it have to complete if

play05:43

we can design an algorithm to do the

play05:46

same thing using 10 instructions or

play05:49

doing 100 instructions the algorithm

play05:51

that we have designed that can run it

play05:53

using 10 instructions is going to be

play05:55

faster at the very very low level that

play05:58

is what we really mean but as you'll see

play06:00

in a moment there's actually a kind of

play06:02

in practical way of actually thinking

play06:04

about it okay so let's just think about

play06:06

a very basic algorithm let's say you

play06:08

have a book

play06:09

and you want to find a specific page in

play06:12

above let's say you want to tell someone

play06:13

to find page 100 in the book How might

play06:17

you go about doing that well one very

play06:19

naive approach might be to just start

play06:21

opening page one of the other and The

play06:23

Logical instructions will be open page

play06:25

see if the page is Page 100 if it is you

play06:29

found it and you've completed the other

play06:31

if it's not you open the next page it is

play06:33

Page 100 no more doesn't expect is this

play06:36

page 100 no move on to the next page and

play06:38

this might sound a bit ridiculous but

play06:40

actually if you do this 100 times

play06:43

eventually you will reach page 100 and

play06:46

you can say yes this is Page 100 yes it

play06:49

is Page 100 even though like intuitively

play06:51

to you as a human it seems like a very

play06:53

stupid idea it does actually work so

play06:56

what is actually wrong with this

play06:58

algorithm it's very slow right and

play07:00

there's probably a much better way to do

play07:02

this we can use our idea from before of

play07:04

thinking about the amount of

play07:06

instructions we need to complete to

play07:09

reach our goal so you might say that in

play07:12

this particular case the running time of

play07:14

our algorithm was a hundred iterations

play07:17

or 100 instructions but the thing here

play07:19

is that saying that this algorithm has a

play07:22

runtime of 100 instructions it's not

play07:25

very helpful because that depends on

play07:27

these very specific case of us wanting

play07:30

to find page 100 what if I had told you

play07:33

to find page two in that case you would

play07:36

open in page one and be like is this

play07:37

page two no more on the next page is

play07:40

this page two yes we have found the

play07:42

solution so in this case the running

play07:43

time would only be two but you might

play07:45

think of the worst case where I tell you

play07:47

to find the very last page of the book

play07:49

you have 696 pages in this cracking the

play07:52

coding in the new book it's a great book

play07:54

by the way but in this case we would

play07:56

have to complete

play07:58

696 iterations to find the number and so

play08:01

how can we just generalize this idea of

play08:04

the running time in this particular

play08:06

algorithm for computer scientists are

play08:08

actually quite pessimistic whenever we

play08:11

analyze algorithms we are always first

play08:13

of all thinking about the worst possible

play08:16

case we assume that we are the

play08:18

unluckiest people and we always get the

play08:20

absolute worst case possible so that is

play08:22

why in computer science when you analyze

play08:24

algorithms we would say that the Big O

play08:26

running time aka the worst case running

play08:29

time is 696 but what if we had a

play08:33

different book what if we had Instead

play08:35

This Book is the Leonardo da Vinci

play08:38

biography this one has 599 pages so in

play08:42

the case of this book the same algorithm

play08:44

would have a running time of Big O 597

play08:49

but this is also not very helpful

play08:51

because now even though we've sort of

play08:54

generalized in terms of thinking about

play08:55

the worst case our running time still

play08:57

depends on the actual book so how can we

play09:00

generalize the running time of this

play09:03

particular search algorithm which is

play09:05

called the linear search by the way into

play09:07

any problem so any book

play09:10

and the way we think about this in

play09:12

computer science is in terms of the

play09:15

input size so in this case we think

play09:17

about the running time of the algorithm

play09:18

in terms of how much it scales when we

play09:23

increase the size of the book so let's

play09:25

say we had a book that was a thousand

play09:27

pages long how does the running time of

play09:29

the algorithm scale relative to the size

play09:34

of the problem and in this case it

play09:36

actually scales to linearly for every

play09:38

page we add the book the running time of

play09:41

our algorithm increases by one because

play09:43

remember we're always thinking about the

play09:44

absolute worst case so in computer

play09:46

science lingo our algorithm has a linear

play09:49

running time or in other words a running

play09:52

time of O of n where n is the size of

play09:55

the problem and the reason again why we

play09:56

care about the input size so much is

play09:59

because Google's the Facebooks they have

play10:01

billions and billions and billions of

play10:02

data points so for this book page

play10:05

finding algorithm how could we find an

play10:07

algorithm that's perhaps much faster

play10:09

than

play10:10

just opening a page one at a time you

play10:13

might already intuitively think about

play10:14

surely it doesn't make sense to start

play10:17

even looking at the first Pages because

play10:18

you know that is not going to be on the

play10:20

first page right so you might just sort

play10:22

of estimate and open is somewhere over

play10:24

here actually landed on 149 which is a

play10:28

pretty good guess and then you know that

play10:29

because page 100 it's less than 149 we

play10:33

can just open it somewhere over here

play10:34

slightly behind it and then eventually

play10:36

we find page 100 and if I told you to do

play10:39

this that's probably how you would do it

play10:41

right and it turns out that we can

play10:42

actually instruct a computer to do it

play10:44

almost like this in general what we can

play10:46

tell the computer to do let's say just

play10:48

in the first iteration let's tell our

play10:50

computer to always try the middle page

play10:53

to open it from the very middle of the

play10:55

book so in this case it's going to open

play10:57

it on page 336. what can we then do

play11:01

afterwards well we can always check very

play11:03

quickly using one instruction is is the

play11:05

page we're looking for before the one we

play11:07

opened or is it after the one we open

play11:09

100 is less than 336 so in the next

play11:12

iteration but if we tell the computer to

play11:14

then open it on the middle of the left

play11:17

section of the book and this time we're

play11:19

opening on page 150 which is

play11:21

approximating and again if we know that

play11:23

is our page 100 less than 150 or more

play11:27

than 150. we can again just forget about

play11:29

the entirety rest of the book here and

play11:32

just focus on the left side of 150

play11:35

because we know that what we're looking

play11:36

for is going to be in here and again

play11:38

without the computer to open it again

play11:40

now on the middle of this portion of the

play11:43

book which will be on page 75 is 100

play11:45

more than 75 or is it less than 75 but

play11:47

it's more than 75 so at this point we

play11:49

can just open it in the middle of 75 150

play11:53

and just through this iterative process

play11:55

we are going to get to our solution much

play11:58

much much faster so essentially in every

play12:00

instruction we are actually reducing the

play12:03

problem size by half and sort of getting

play12:06

closer and closer to the solution and it

play12:08

turns out that the running time of this

play12:09

algorithm is something called log n and

play12:12

the log is something that can be a bit

play12:14

confusing probably but essentially

play12:16

although log N means as we double the

play12:19

size of the book The amount of

play12:20

instructions we have to do so the the

play12:23

running time of the algorithm would only

play12:25

go up by one instruction because if you

play12:28

think about it we have two books when we

play12:29

double the size of the input in our

play12:31

binary search algorithm where we're

play12:33

always opening the middle page it only

play12:35

adds one more step because in this case

play12:37

we would open it in the middle of these

play12:39

two so in here and then we're going to

play12:41

say well is it to the right or is it to

play12:43

the left that says to the left so then

play12:45

we can literally just forget about this

play12:47

other half of the problem entirely and

play12:49

now we're back in the same stage where

play12:52

we started out before with just this one

play12:54

or this half of the book and you can see

play12:56

that even in this very small case using

play12:59

this algorithm is much much faster you

play13:01

would never use the first one because

play13:04

it's so much slower and you can imagine

play13:05

a similar problem like this where we

play13:07

need to find a particular data point

play13:09

from a list of like billions and

play13:11

billions and billions of billions the

play13:13

difference that this better algorithm

play13:15

makes and literally shorten the running

play13:17

time by like weeks or if months I think

play13:21

I've seen so that is really why we care

play13:23

so much about designing fast algorithms

play13:25

and another very common problem that a

play13:28

lot of algorithms courses start with at

play13:30

first is sorting and I've actually coded

play13:32

up a visualization that really shows the

play13:34

difference between different kinds of

play13:36

algorithms I'm not going to show the

play13:37

implementation in this or anything but

play13:39

you can call the description and find it

play13:40

if you want in here we have a very slow

play13:43

algorithm that scales at o of N squared

play13:47

so as the input size doubles it's going

play13:50

to go up by 2 squared so it's actually

play13:52

even worse at the linear time thing that

play13:54

we tried before

play13:58

two thousand years later you can see

play14:01

that it's taking quite a while whereas

play14:03

if you use a more optimized algorithm

play14:05

called merge saw where again you'll end

play14:08

up studying the details of this later

play14:09

and in whatever course designed to

play14:11

follow this algorithm runs on N Times

play14:14

log n which is actually much much faster

play14:16

than N squared so I hope now you're sort

play14:19

of starting to see why companies

play14:21

actually put so much emphasis on hiring

play14:23

people who understand algorithms who

play14:25

understand how to write good algorithms

play14:29

for their very very big problems that

play14:32

they solve other companies in terms of

play14:34

practical next steps for you to do it

play14:36

you want to understand this topic if you

play14:37

enjoyed this video first of all leave a

play14:39

like because I actually find the

play14:40

interaction algorithms quite exciting

play14:42

and I really enjoy teaching them and

play14:44

talking about them but I will only doing

play14:46

if you guys really want me to do that so

play14:49

if you want to see that go leave a like

play14:51

down below and go leave a comment on the

play14:54

specific topic about algorithms and data

play14:56

structures that you would would like to

play14:58

see next but first of all if you haven't

play15:00

done cs50 yet specifically their third

play15:03

lecture I'm going to leave the third

play15:04

lecture of 650 in the description below

play15:07

its YouTube video that lecture is

play15:08

specifically on algorithms and it

play15:10

essentially teaches what I've taught you

play15:12

in this video except it's the two hour

play15:14

version and probably a much much better

play15:16

explained that that I ever explained but

play15:19

obviously even that is not going to be

play15:21

enough to pass interviews so what I

play15:22

would do is just pick any popular course

play15:25

on data structure and algorithms teaches

play15:27

you the theory of the most important

play15:30

algorithms and data structures that

play15:31

you'll need

play15:32

one that I did personally for myself was

play15:35

zero to masteries master the coding

play15:37

interview bootcamp zero to Mark 3 is a

play15:40

coding course platform that's

play15:41

essentially like a subscription model

play15:43

where instead of paying for a Netflix

play15:45

subscription you can pay for as an auto

play15:47

Master research and characters so that

play15:49

they're like 60 different coding courses

play15:51

on a lot of different areas so I've done

play15:52

a bunch of them those are really good uh

play15:55

the teaching style is really engaging if

play15:57

you are interested in sort of a more

play15:59

academic and probably a more rigorous

play16:02

approach there's two specific course

play16:04

Sarah specializations that you can look

play16:06

at I've actually done both of them the

play16:08

first one is the Stanford algorithm

play16:11

specialization that's really the most

play16:13

theoretical approach that you'll

play16:14

probably find online quite math heavy

play16:16

but it's going to give you a very very

play16:18

rigorous understanding the other one is

play16:20

the Princeton algorithms one and albums

play16:22

two specializations agents are also use

play16:24

the textbook style one is Java based the

play16:27

other specialization actually doesn't

play16:28

basically on any specific programming

play16:30

language because but they rather just go

play16:33

through things either conceptual and a

play16:35

mathematical level and of that something

play16:37

like cracking the coding interview is

play16:39

actually a very good book to get sort of

play16:41

a review slash an overview of the topics

play16:43

that you need for interviews plus a lot

play16:46

of practice problems but I would not

play16:49

choose this first I would choose one of

play16:51

the three other courses to give you the

play16:53

theory and the understanding and then

play16:55

after that I have to go for something

play16:56

like this because this is more like a

play16:58

practice book something that you want to

play16:59

use to prepare like right before your

play17:02

interviews and obviously beyond that

play17:03

lead code you don't need to pay for the

play17:05

premium I've never paid for the premium

play17:07

just keep doing a lot of lead code

play17:08

problems so that is that this is

play17:11

probably a very long video already if

play17:13

you haven't seen my first part to this

play17:15

series on data structures absolutely go

play17:17

watch it now other than that I have this

play17:20

other video where I talk about my

play17:22

step-by-step plan of how I personally

play17:25

learn all these topics so go watch one

play17:27

of these videos next and I'll see you in

play17:29

the next one

play17:34

foreign

Rate This

5.0 / 5 (0 votes)

Related Tags
AlgorithmsCoding InterviewData StructuresComputer ScienceOptimizationBig O NotationLinear SearchBinary SearchSorting AlgorithmsTech IndustryEducational ContentInterview PrepBook SummariesProductivitySelf-Improvement