Classroom Notes: 1.3 Searching Algorithms
1) What is a searching algorithm?
A searching algorithm is a series of methodical steps or instructions followed by a computer to locate a specific data value within an extensive data set.
2) Why are searching algorithms fundamentally needed in computer software?
They are required because computers handle large amounts of stored data, which is frequently stored in an unordered or chaotic fashion. A methodical approach is necessary to locate information quickly.
3) What are three real-world examples of computer programs using searching algorithms?
The three real-world examples of computer programs using searching algorithms are:
- Logging into a website where the system searches a file to match a username and password.
- Searching for a lost file on a computer using a filename or a keyword.
- Using a search engine to find web pages on the internet based on key words.
4) Do computers always use the same searching algorithm for every task?
No, there are many different searching algorithms, and the best one depends on the specific situation and the data. For example, some algorithms work better for very large numbers of items, while others require the data to be sorted in alphabetical or numerical order first.
5) What is a "random search" and why isn't it the best method?
A random search is an algorithm that just picks one item in a set of data at random until it finds the correct one. This method is not always the fastest way of searching.
6) What does the term "target" mean in computer searching?
The target is the specific data value, number, or text character that a searching algorithm is instructed to locate.
7) What does the word "linear" mean?
Linear means moving in a single, direct, straight line or progressing from one point to the next in a sequential order.
8) How does a linear search work?
A linear search starts at the absolute beginning of the list and checks each item one by one, in a strict sequential order, until it either finds the target item or reaches the end of the list.
9) How must data be organized before performing a simple linear search?
The items or data first need to be arranged in a line.
10) What are the exact methodical steps a linear search follows?
Below are the steps of linear search, listed in order:
- Look at the first item.
- Compare it to the value you are looking for.
- If it is the target value, stop the search because you found it.
- If it is not the target value, look at the next consecutive item and repeat the comparison.
- Repeat this process until you find the target or there are no items left to check.
11) What happens if a linear search cannot find the item at all?
If there are no items left to check in the data set, the algorithm concludes that the value is not there and terminates the search.
12) How is a computer's method of searching fundamentally different from a human's?
A human can look at a complete list of numbers or words simultaneously on paper. However, a computer cannot see all the data at once; it must evaluate data isolated into memory locations, accessing and looking at exactly one single item at a time before moving on to the next space.