What is the perfect use of algorithms

If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, make sure the domains *. kastatic.org and *. kasandbox.org are not blocked.

Current time: 0:00 Total duration: 5:28

Introduction to algorithms

Video transcript

What is an algorithm? A definition could be a set of steps to get a task done. You could have an algorithm for getting home from school, or making a toasted cheese sandwich, or finding something in a supermarket. In computer science, an algorithm is a set of steps that a computer program needs to complete a task. Algorithms are an essential part of computer science. If you can find a good algorithm and apply it appropriately, then you will be able to write interesting and important programs. Let's look at some well-known algorithms. How does Google Hangout broadcast live video over the internet so quickly? It uses audio and video compression algorithms. How does Google Maps figure out how to get from Dallas, Texas to Orlando, Florida to visit Disney World? A route finding algorithm is used for this. How does Pixar color the 3D model of a character depending on the lighting of a virtual room? Pixar uses a rendering algorithm. How does NASA determine the orientation of the solar cells on the international space station and determine when they should be rotated? Nasa uses optimization and scheduling algorithms. These algorithms are more complex than the algorithms used in our daily life, such as making a toasted cheese sandwich. But basically they have in common that they are a set of steps that accomplish a task. If you know something about existing algorithms, then you can save yourself work and make your program faster by using the right algorithm. Suppose you are writing a game and you want the player to be able to play against the computer. So you could check out other games for inspiration. Computer scientists have learned how to write a lady program that never loses. To do this, they use the MiniMax search algorithm, which searches through a huge tree of possible moves. If your game is something like checkers, then it is possible that you can use an algorithm that is based on this technique. If not, then knowing the limitations of these algorithms can lead you to a different design of your game if it requires a good computer gamer. It is also important to know how to design a new algorithm, as well as how to analyze its correctness and efficiency. In biology, new algorithms are constantly being designed, e.g. to design the molecular structure of drugs in order to treat diseases. In physics, algorithms simulate climate and weather processes. Still other algorithms search for and analyze the data from stars in the universe, which are recorded by automatic space telescopes. In all sciences and even on websites like the Khan Academy, efficient algorithms are needed to analyze large amounts of data or to intelligently select from a large number of possible decisions. In almost all areas, algorithms will provide massive computing power to do things that are important to people. Well, not all algorithms are created equal. So what makes a good algorithm? The two most important criteria are that he solves a problem and that he is efficient at doing so. Most of the time we want an algorithm to always give us a correct answer. Sometimes it can be enough if the answer is not 100% correct or not the best, because the only perfect algorithm we know for these problems has to calculate far too long. Let us assume that we want a program that calculates the best way for a truck to deliver packages, starting and ending at the depot. It would take weeks to calculate all the possibilities. But if it is enough for us to have a program that calculates a way that is good enough, but perhaps not perfect, then it might only take a few seconds. In some cases that's enough. How do you measure the efficiency of an algorithm? We could measure the running time. But with that we would only learn something about the concrete implementation in a certain programming language on a certain computer with the predefined input. Instead, computer scientists use a technique called asymptotic analysis. This allows us to compare algorithms with one another, regardless of the programming language or hardware used, so that we can conclusively determine that some algorithms are more efficient than others. You can learn about algorithms and asymptotic analysis at Khan Academy, thanks to the input of two professors from Dartmouth College. Tom Cormen is the first author of a world famous book on algorithms, and the author of Algorithms Unlocked. Devin Balkcom designed Dartmouth's introductory computer science course and does research in robotics. He built the world's first robot that can fold origami. Tom and Devin will teach you many of the algorithms that you would normally learn in APCS or CS 101, such as search or sort algorithms, recursive algorithms, and my personal favorite, graph algorithms. Lots of interactive visualizations, puzzles and coding challenges will help you on your learning journey.