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, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

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

What is an algorithm and why should you care?

Video transcript

what is an algorithm one definition might be a set of steps to accomplish a task you might have an algorithm for getting from home to school for making a grilled cheese sandwich or for finding what you're looking for in the grocery store in computer science an algorithm is a set of steps for a computer program to accomplish a task algorithms put the science in computer science and finding good algorithms and knowing when to apply them will allow you to write interesting and important programs let's talk about a few famous algorithms how does Google Hangouts transmit live video across the internet so quickly they use audio and video compression algorithms how does Google Maps figure out how to get from Dallas Texas to our land of Florida so that you can get to Disney World they use a route finding algorithm how does Pixar color a 3d model of a character based on the lighting in a virtual room they use a rendering algorithm how does NASA choose how to arrange the solar panels on the International Space Station and when to rearrange them they use an optimization and a scheduling algorithm those algorithms are more complex than our everyday algorithms like making a grilled cheese sandwich but they boil down to the same thing a set of steps to accomplish a task if you know something about existing algorithms you can save yourself some effort and make your programs faster by applying the right one for example let's say that you're writing a game and you want the user to be able to play against the computer well you could look at checkers games for inspiration computer scientists have figured out how to write checkers programs that never lose by using the minimax search algorithm to search through the huge tree of possible moves if your game is similar to checkers then you might be able to use algorithms based on these techniques if not then knowing the limitations of those algorithms might lead you to redesign your game if it requires having a skilled computer player it's also important to know how to design new algorithms as well as how to analyze their correctness and efficiency in the biological sciences new algorithms are continually being designed for purposes like designing the molecular structures that are the core of disease fighting drugs in physics algorithms simulate climate and weather patterns and other algorithm search and analyze the vast data about stars in the universe that's collected by automated space telescopes across all the sciences and even on websites like Khan Academy efficient algorithms are needed to analyze huge datasets or to select intelligently from a vast number of possible decisions in just about any area you might be interested new algorithms will allow massive computational power to be harnessed to do things that people really need and care about now not all algorithms are created equal so what makes a good algorithm the two most important criteria are that it solves the problem and that it does so efficiently most of the time we want an algorithm to give us an answer that we know is always correct sometimes we can live with an algorithm that doesn't give us a correct answer or the best answer because the only perfect algorithms that we know for those problems take a really really long time for example let's say we want a program that would determine the most efficient route for a truck that delivers packages starting and ending the day at a Depot it would take weeks to run going through all the possibilities but if we're ok with a program that would determine a route that's good but maybe not the best then it could run in seconds in some case good is good enough how do you measure the efficiency of an algorithm we could time how long it takes to run the code but that would only tell us about that particular implementation in a certain programming language on a particular computer and just for the input it was given instead computer scientists use a technique called asymptotic analysis which allows algorithms to be compared independently of the particular programming language or hardware so that we can conclude Lee say that yes some algorithms are more efficient than others now you can learn about algorithms and a synthetic analysis on Khan Academy thanks to the contribution of two dartmouth college professors Tom Corman is the first author of the most popular College algorithms textbook in the world plus the author of algorithms unlocked Devon Balcom designed Dartmouth's intro CS course and researches robotics he built the world's first origami folding robot Tom and Devon will teaching many of the algorithms that you'd learn in a pcs or CS 101 like searching algorithms sorting algorithms recursive algorithms and my personal favorite graph algorithms there will be tons of interactive visualizations quizzes and coding challenges to help you understand better along your learning journey