Programming has a set of complex algorithms that help a programmer complete several tasks, some of these tasks require searching or sorting for information within a system. In this blog post, we will be discussing which algorithms might be best suited for seeking and searching information for a program and how they can be used differently in different programs. Bare in mind, with these algorithms we want to understand what worst, best, and average case would be used in the development of your program. We can review a chart that helps provide some insight on these different cases later in this post.
What type of algorithm should someone use depends entirely on what they want their program to do, so in the event you are unsure, let's go through some of the basic searching algorithms first. Two searching algorithms that I will be talking about today are linear and binary searching. A linear search algorithm checks each element found in a list and will stop once it has found the desired element. The binary search algorithm is a search function that first searches the middle element of a list, if the search value is found the search can stop, if the search is higher than the value that we are searching for, repeating the search process with the portion of the list before the middle element, and if the value is lower, we search the process with the portion of the list that is after the middle element. However for a binary search to work the lists being searched, needs to be sorted, therefore another algorithm must be implemented to sort the list of elements beforehand.
There are a variety of algorithms that can be used to sort a list of elements within a program, but what exactly is a sorting algorithm? Sorting algorithms are used to organize either an array or list of elements in a simplified manner, generally alphabetical order, ascending or descending numerical values, to help search for an element in the array or list through organizational means. Following this link Here will help describe some of the different sorting methods and which might be best suited for sorting your listed elements.
One really important factor to bare in mind when developing a program is to understand how much memory will be/wanted to be allocated for this program to run. This is an important factor because of efficiencies. When a program needs to be sorted/searched we would want a program to be optimal, this using a searching/sorting algorithm combination to lower the amount of memory needed and time between each task taken.
Now that we have established sorting and searching algorithms, let's take a look over at data structures. Data structures are organized ways to implement a type of list to store information. These data structures are typically; arrays, Linked Lists, Stacks, Queues, and Trees. These all share similar reasonings to be used, however, they have differences amongst each other that define how a program will store information and how that information can be accessed. Arrays allow for easier access to insert or remove elements in this data structure without having to follow any order. Whereas, we can look at stacks or queues where they utilize the order of first-in-first-out(queues) or last-in-first-out (stacks). Then we can look at Linked Lists and Trees, these types of data structures utilize nodes to store information. Linked Lists allow for information to be inserted or removed without any order, which makes these easy to work with. The data tree structures are a more complex data structure as they use a root node then use sub-nodes.
After learning and understanding more about the data structures and algorithm concepts throughout this course, I will utilize these newly obtained skills to try and apply it towards my programs to help create a better organized program. Where searching through my program to make improvements will be much more easily accessible.