Summary
In this chapter, we applied C# to selection sort, linear search, and binary search algorithms, but these are only some of many solutions and can be rewritten to be even better. Selection sort relies on visiting every value to compare them against each other and swap them to organize an array in ascending order. Linear search also requires visiting every value in an array until the value being searched for is found. These two algorithms use loops to iterate through arrays to find and compare values. The binary search algorithm does not need to visit every value within an array when it’s sorted and can narrow down the values with calculations and some iterations. While these algorithms are quite popular, there are many built-in features and methods within C# for searching for and sorting values rather quickly and with less code. There are also even more sorting and searching algorithms to explore.
Computer programs are algorithms that solve specific problems based on...