Python for Absolute Beginners Transcripts
Chapter: The big ideas of software development
Lecture: Formal algorithms

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We could have easily come up
0:01 with this algorithm on our own
0:03 but it turns out that many of these techniques
0:06 appear over and over
0:07 and they get applied to all sorts of different problems
0:11 and these I will call formal algorithms.
0:14 For example, the thing that we just did
0:16 is a Binary Search algorithm
0:19 where you start with somewhere
0:20 and then you start breaking it into halves
0:23 and say, Can we exclude half of the data?
0:25 Yes, or can we, make sure we only focus on half of the data
0:29 and start partitioning down.
0:30 And you can go learn all sorts of things about this
0:33 given some amount of data in an unoptimistic case
0:36 we'd have to make as many guesses as possible
0:39 or until there is no other sort of path
0:42 that doesn't allow for another guess.
0:44 It would be this complexity called O(log n)
0:47 which means as you add more data
0:48 10 versus a hundred versus a thousand
0:50 the time it takes to find the answer
0:52 is the log of 10 or a hundred or a thousand
0:55 as a ratio not exactly as a number.
0:58 And the best part is
0:59 maybe you just guess the number straight up
1:00 and that's just, doesn't matter how much data there is
1:02 if you guessed right.
1:03 The point is not to look at this complexity and stuff
1:06 but once you identify one of these formal algorithms
1:09 all of a sudden you can see all the stuff
1:11 that people have studied about it
1:13 you can see, oh, it actually applies in this other case.
1:16 I first thought it was just about guessing
1:18 the number of M&M's in that jar
1:20 but it turns out it also helps me
1:23 optimize this pathfinding algorithm
1:25 or pathfinding program that I am trying to write.
1:27 I don't even know if that's actually true
1:29 but once you know the algorithm
1:31 you then know that it can be applied
1:33 to all these different things.
1:34 So we're not going to go deep into a bunch of algorithms
1:36 because this is not a Computer Science course
1:38 but that's the idea.
1:39 You're going to run into these things
1:41 you're like, Oh, I thought I just made this up.
1:42 But no, it's actually this sort of formal thing
1:44 that was studied
1:45 or somebody might tell you
1:46 Oh, it's this kind of algorithm.
1:49 And then you can go and look it up
1:50 see how to do it in Python
1:51 usually there is a resource for that.
1:53 To these algorithms
1:55 sometimes it's just thinking
1:56 about how my users are logging into my site
1:59 other times they're much more formalized
2:01 like this search algorithm here.