What Are Algorithms and Why They're Important

A free video tutorial from Tim Short
Dev / Train / Recuit
Rating: 4.4 out of 5Instructor rating
4 courses
167,421 students
What Are Algorithms and Why You Need to Know Them

Learn more from the full course

Become a Junior Java Software Developer

Complete practical and conceptual Java programming course for beginners

07:45:34 of on-demand video • Updated August 2017

Be comfortable with writing and designing Java applications
Apply core concepts of object-oriented programming to a project
Build holistic, real-world practical applications from the ground up
Write common algorithms covered in computer science courses
Talk confidently about Java programming and object-oriented programming
Network with recruiters, hiring managers, and tech professionals
Walk into your first job interview and code review with confidence
Invitation to participate in internship through SDET University!
English [Auto]
Hi. Welcome back. And I want to talk about algorithms now. And this is actually something where a lot of Java courses actually fall short. They'll teach you some of the basics for object oriented programming. You'll write a couple of applications, you'll learn about the collections framework and some data structures. But again, where we go the extra mile is we want to teach you algorithms what I say an introduction to computer science and we'll talk about in just a second. But again, we want to teach you things that will let you that that will help you pass the interview, that will help you get the job. And so what will set you apart is your ability to work with algorithms and your ability to think critically and solve problems. And so this is much of what algorithms does. Again, our job is to help you get hired. So when we talk about algorithms, we talk about thinking like a computer, right? Or making your computer think like a human analyses, right? So how we think we're able to do things as humans, we're able to do things incredibly fast, intuitively, because of our because of our intelligence, because of the way we've been intelligently designed. And so we're able to make connections and come to conclusions very fast. Computers have high processing power, but we actually need to program them. We need to think. We need to tell them how to think. We need to provide them instructions. So we come to this term of algorithms. Algorithms are a systematic approach to methodically and efficiently solve problems using repetition and calculation within complex data structures. So this is my definition that helps us make through it. So it's methodical and it's efficient. And I say it's the job of computer scientists to handle complex algorithms and data structures efficiently. So if you've got a if you majored in computer science, you would have spent a lot of time working with algorithms, learning the basic ones, enhancing them. They can be very, very complex. But this is where computer scientists make their money from handling algorithms. Of course, this course is not designed to create computer scientists, but we should be familiar with the process and we should be comfortable with the the ideas of certain algorithms as as developers. Okay. So some common algorithms I'm going to cover. We'll see how much time I have to cover throughout the material. I'll be adding more videos as this course goes along. The linear search, the binary search, the bubble sort. Those are the three most common common algorithms. So we'll learn those pretty quickly. One hence the bubble sort with the insertion sort. We'll talk about the array list and linked list. So we learned about those when we did the collections framework. And so we'll actually generate our own data structure based on some algorithms. We'll talk about the stack and the queue. Again, those are very common ones that you learn in any computer science program. So I'll go through all of these what these mean, but if these kind of ring a bell or if they don't, no worries because I'm going to go through these and I'm going to demo them here in these slides. When we talk about algorithm efficiencies, there's three things. We look at the amount of time it takes for an algorithm to execute the amount of memory that's needed to execute, and then the complexity of the performance. And one of the ways we talk about efficiency is called big O notation. So we use 010N0 and squared. So again, I don't you don't necessarily need to maintain a lot of this knowledge, but this is more of an introduction or a survey of how people talk about algorithms. An example of O one and an N two would be something like this. So O one is the time it takes to execute one simple line. And so O one is one line of code one. One operation o n is like for example, a for loop that runs n times. It's going to, it's, it's big o notation is o n If you're going to iterate through a collection of arrays or a double array, it's going to be o n squared, right? You're going to go through a for loop within a for loop. So you're going to do n times n essentially. So again, you don't need to know too much of that. Just kind of be familiar with the idea of big o notation. And if you're really into computer science, you would learn much more about O log n and so forth. And o log or n factorial mean all kinds of there's just there's many, many it's obviously people major and get their PhD in this kind of stuff. So this is very very much of a survey in terms of the terms and then we'll see some of this when we get into our when I actually write some algorithms out, for example, I'm going to say here's the here's the linear search, very basic album, find the value of the position of the number four. So here is an array with a set of numbers. So our job then is going to find each value of four. And as a human, we can spot this immediately. But again, we need to write an algorithm that's going to have a computer think like a human, and we need to think that that kind of way. So what are we going to do? We're going to go through each position in the array. Say, does that item equal four and is the next item equal four? Does the next item equal four? And once it equals four, we're going to return either that index or it's going to say, yes, here's where that number was found. Now, that process is, again, humans do it very quickly and we need to write instructions on the computer. We need to actually go through this process and write an algorithm that will find that value. So the algorithm will look something like this. Right. We have to have a function with a with a set of data. And when our value we're going to go through a for loop, it's going to go through each of those arrays and going to find the value based on that index and see if it equals our target. So that's the very basic setup of an algorithm. And we're going to have here's an example of the Max runtime and the big O notation. So we're going to go through various algorithms and I have slides on them, but it will look something like this. And I'll just walk us through this process how to think, how to have a computer, essentially think, how do we how do we have these processes written out? So that's the very, very brief introduction to algorithms. We'll go through a number of these again in our course. Just going to give a sample of how this goes here. But but the big thing here is that we get comfortable with traversing arrays, double arrays and then thinking critically how to solve a problem. So algorithms are pretty critical. I'll probably do a whole separate course on data structures and algorithms, but I want to combine some into this course as if you're going to be a junior software developer. You should be familiar with some of these algorithms.