课程: Java Algorithms
What is an algorithm?
- [Instructor] An algorithm is a series of defined instructions that perform some task. For example, we can break apart the task of making a sandwich into an algorithm. The first instruction would be to retrieve the ingredients as well as any tools such as a knife. Then, you might slice the bread and spread mayo or mustard onto the sandwich. Next, you would place ham and cheese on the bread. Then, you'd combine the pieces of bread together, making your sandwich complete. Most of us have made many sandwiches in our lifetime, so we don't think about each individual step that has to happen in order to make a sandwich. However, a computer is different, every step must be laid out in order to complete a software-based task. Given this, in Java, almost everything you create is part of some algorithm. Every line of code you write is an instruction that's a step in achieving some task. It might be to find the even numbers in an array or to validate whether a string has certain components. There are many different sets of instructions that complete the same task. Some sets are more efficient than others, but they all have defined instructions that set out to complete a given task. That's what makes an algorithm an algorithm.
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。