1 00:00:00,000 --> 00:00:09,167 [MUSIC] 2 00:00:09,167 --> 00:00:10,844 Hi, my name is Pasan. 3 00:00:10,844 --> 00:00:14,971 I'm an instructor here at Treehouse and welcome to introduction to algorithms. 4 00:00:14,971 --> 00:00:19,643 Whether you're a high school or college student, a developer in the industry, or 5 00:00:19,643 --> 00:00:24,534 someone who is learning to code, you have undoubtedly running to the term algorithm. 6 00:00:24,534 --> 00:00:27,383 For many people, this word is kind of scary. 7 00:00:27,383 --> 00:00:31,471 It represents this body of knowledge that seems just out of reach. 8 00:00:31,471 --> 00:00:34,960 Only people with computer science degrees know about algorithms. 9 00:00:34,960 --> 00:00:38,391 Now to others, this brings up feelings of impostor syndrome. 10 00:00:38,391 --> 00:00:40,493 You might already know how to code but 11 00:00:40,493 --> 00:00:45,030 you're not a real developer because you don't know anything about algorithms. 12 00:00:45,030 --> 00:00:49,445 Personally, it made me frame certain jobs as above my skill level, 13 00:00:49,445 --> 00:00:53,186 because the interview contained algorithm questions. 14 00:00:53,186 --> 00:00:57,782 Well, whatever your reasons are, in this course, our goal is to dispel 15 00:00:57,782 --> 00:01:02,404 all those feelings and get you comfortable with the basics of algorithms. 16 00:01:02,404 --> 00:01:04,231 Like any other subject, 17 00:01:04,231 --> 00:01:08,591 I like to start my courses with what the course is and is not. 18 00:01:08,591 --> 00:01:13,145 In this course, we're going to cover the very basic set of knowledge that you need 19 00:01:13,145 --> 00:01:15,860 as a foundation for learning about algorithms. 20 00:01:15,860 --> 00:01:19,127 This course is less about specific algorithms and 21 00:01:19,127 --> 00:01:22,849 more about the tools you will need to evaluate algorithms, 22 00:01:22,849 --> 00:01:26,493 understand how they perform, compare them to each other, and 23 00:01:26,493 --> 00:01:30,720 make a statement about the utility of an algorithm in a given context. 24 00:01:30,720 --> 00:01:33,742 Now don't worry, none of this will be theoretical and 25 00:01:33,742 --> 00:01:37,301 we will learn these concepts by using well-known algorithms. 26 00:01:37,301 --> 00:01:40,029 In this course, we'll also be writing code. 27 00:01:40,029 --> 00:01:42,967 So I do expect you to have some programming experience if 28 00:01:42,967 --> 00:01:45,102 you intend to continue with this topic. 29 00:01:45,102 --> 00:01:48,950 You can definitely stick around even if you don't know how to code but 30 00:01:48,950 --> 00:01:52,560 you might want to learn the basics of programming in the meantime. 31 00:01:52,560 --> 00:01:56,523 In this course, we will be using the Python programming language. 32 00:01:56,523 --> 00:02:01,123 Python reads a lot like regular English and is the language you will most likely 33 00:02:01,123 --> 00:02:04,343 encounter when learning about algorithms these days. 34 00:02:04,343 --> 00:02:09,236 If you don't know how to code or if you know how to code in a different language, 35 00:02:09,236 --> 00:02:11,906 check out the note section of this video for 36 00:02:11,906 --> 00:02:15,120 links to other content that might be useful to you. 37 00:02:15,120 --> 00:02:18,666 As long as you understand the fundamentals of programming, 38 00:02:18,666 --> 00:02:21,454 you should be able to follow along pretty well. 39 00:02:21,454 --> 00:02:25,300 If you're a JavaScript developer or a student who's learning JavaScript, 40 00:02:25,300 --> 00:02:26,009 for example, 41 00:02:26,009 --> 00:02:30,107 chances are good that you'll still be able to understand the code we write later. 42 00:02:30,107 --> 00:02:35,276 I'll be sure to provide links along the way if you need anything to follow up on. 43 00:02:35,276 --> 00:02:37,296 Let's start with something simple. 44 00:02:37,296 --> 00:02:39,305 What is an algorithm? 45 00:02:39,305 --> 00:02:43,995 An algorithm is a set of steps or instructions for completing a task. 46 00:02:43,995 --> 00:02:47,384 This might sound like an oversimplification but 47 00:02:47,384 --> 00:02:50,700 really that's precisely what an algorithm is. 48 00:02:50,700 --> 00:02:55,642 A recipe is an algorithm, your morning routine when you wake up is an algorithm, 49 00:02:55,642 --> 00:03:00,968 and the driving directions you follow to get to a destination is also an algorithm. 50 00:03:00,968 --> 00:03:05,673 In computer science, the term algorithm more specifically means the set of 51 00:03:05,673 --> 00:03:08,110 steps a program takes to finish a task. 52 00:03:08,110 --> 00:03:12,250 If you've written code before, any code really, generally speaking, 53 00:03:12,250 --> 00:03:14,121 you have written an algorithm. 54 00:03:14,121 --> 00:03:18,292 Given that much of the code we write can be considered an algorithm, 55 00:03:18,292 --> 00:03:22,627 what do people mean when they say, you should know about algorithms? 56 00:03:22,627 --> 00:03:24,002 Now, consider this. 57 00:03:24,002 --> 00:03:26,168 Let's say, I'm a teacher in a classroom and 58 00:03:26,168 --> 00:03:28,395 I tell everyone I have an assignment for them. 59 00:03:28,395 --> 00:03:31,337 On their desks, they have a picture of a maze and 60 00:03:31,337 --> 00:03:36,074 their task is to come up with a way to find the quickest way out of the maze. 61 00:03:36,074 --> 00:03:39,216 Everyone does their thing and comes up with a solution. 62 00:03:39,216 --> 00:03:42,988 Every single one of these solutions is a viable solution and 63 00:03:42,988 --> 00:03:45,256 is a valid example of an algorithm. 64 00:03:45,256 --> 00:03:48,612 The steps one needs to take to get out of the maze. 65 00:03:48,612 --> 00:03:51,885 But from being in classrooms or any group of any sort, 66 00:03:51,885 --> 00:03:55,692 you know that some people will have better ideas than others. 67 00:03:55,692 --> 00:03:58,077 We all have a diverse array of skillsets. 68 00:03:58,077 --> 00:04:01,538 Over time, our class picks the best of these solutions. 69 00:04:01,538 --> 00:04:05,816 And anytime we want to solve a maze, we go with one of these solutions. 70 00:04:05,816 --> 00:04:08,954 This is what the field of algorithms is about. 71 00:04:08,954 --> 00:04:11,802 There are many problems in computer science but 72 00:04:11,802 --> 00:04:16,655 some of them are pretty common, regardless of what project you're working on. 73 00:04:16,655 --> 00:04:19,536 Different people have come up with different solutions to these 74 00:04:19,536 --> 00:04:20,397 common problems. 75 00:04:20,397 --> 00:04:24,555 And over time, the field of computer science has identified 76 00:04:24,555 --> 00:04:27,662 several that do the job well for a given task. 77 00:04:27,662 --> 00:04:31,686 When we talk of algorithms, we're referring to two points. 78 00:04:31,686 --> 00:04:36,265 We're primarily saying there's an established body of knowledge on how to 79 00:04:36,265 --> 00:04:38,350 solve particular problems well. 80 00:04:38,350 --> 00:04:41,389 And it's important to know what these solutions are. 81 00:04:41,389 --> 00:04:43,361 Now why is it important? 82 00:04:43,361 --> 00:04:45,746 If you're unaware that a solution exists, 83 00:04:45,746 --> 00:04:48,071 you might try to come up with one yourself. 84 00:04:48,071 --> 00:04:52,526 And there's a likelihood that your solution won't be as good or efficient, 85 00:04:52,526 --> 00:04:57,062 whatever that means, compared to those that have been thoroughly reviewed. 86 00:04:57,062 --> 00:05:00,071 But there is a second component to it as well. 87 00:05:00,071 --> 00:05:05,453 Part of understanding algorithms is not just knowing that an algorithm exists but 88 00:05:05,453 --> 00:05:07,639 understanding when to apply it. 89 00:05:07,639 --> 00:05:11,126 Understanding when to apply an algorithm requires properly 90 00:05:11,126 --> 00:05:13,253 understanding the problem at hand. 91 00:05:13,253 --> 00:05:18,026 And this, arguably, is the most important part of learning about algorithms and 92 00:05:18,026 --> 00:05:19,143 data structures. 93 00:05:19,143 --> 00:05:24,005 As you progress through this content, you should be able to look at a problem and 94 00:05:24,005 --> 00:05:26,195 break it down into distinct steps. 95 00:05:26,195 --> 00:05:31,002 When you have a set of steps, you should then be able identify which algorithm or 96 00:05:31,002 --> 00:05:33,672 data structure is best for the task at hand. 97 00:05:33,672 --> 00:05:37,258 This concept is called algorithmic thinking and it's something we're 98 00:05:37,258 --> 00:05:40,620 going to try and cultivate together as we work through our content. 99 00:05:40,620 --> 00:05:45,549 Lastly, learning about algorithms gives you a deeper understanding about 100 00:05:45,549 --> 00:05:48,482 complexity and efficiency in programming. 101 00:05:48,482 --> 00:05:53,047 Having a better sense of how your code will perform in different situations is 102 00:05:53,047 --> 00:05:56,534 something that you'll always want to develop and hone. 103 00:05:56,534 --> 00:06:01,616 Algorithmic thinking is why algorithms also come up in big tech interviews. 104 00:06:01,616 --> 00:06:06,498 Interviewers don't care as much that you're able to write a specific algorithm 105 00:06:06,498 --> 00:06:09,510 in code but more about the fact that you can break 106 00:06:09,510 --> 00:06:13,676 a seemingly insurmountable problem into distinct components and 107 00:06:13,676 --> 00:06:17,363 identify the right tools to solve each distinct component. 108 00:06:17,363 --> 00:06:19,618 And that is what we plan on doing. 109 00:06:19,618 --> 00:06:24,103 In this course, though, we're going to focus on some of the tools and concepts 110 00:06:24,103 --> 00:06:28,457 you will need to be aware of before we can dive into the topic of algorithms. 111 00:06:28,457 --> 00:06:30,740 If you're ready, let's get started.