Why Algorithms and Data Structures? A Newb explains...
Hello again! Let's take another step on our learning journey and find out why algorithms and data structures techniques are important to programs overall. What do they do to streamline the structure of a program? Are some algorithms and data structures better than others? The different algorithms and structures exist for a reason, so they each have their reasons to be used.
Most programs don't want to waste unnecessary time or resources, so EFFICIENCY is a big factor when choosing which algorithms to use. To measure efficiency, there are two functions used: Time Complexity and Space Complexity. Time Complexity should not be confused with our normal understanding of time, but it should be used more as a measurement of calls, loops, executions, or other events in relation to the data set. Space Complexity helps us understand the space or storage required for an algorithm to function. A classification used to generalize time complexity is called Big O notation, or "O(n)". This classification can describe whether an algorithm is slow or if it's constant time.
Speaking of efficiency, or lack thereof, we can look at recursive algorithms. Recursion calls itself again and again until the base case is finally reached. This algorithm can take up a lot of time and space depending on how big the data set is. So, it's only considered efficient when the data set is small.
If someone was creating a log of names in a data set, and they wanted names to be indexed for easy access, then a hash function would be great to use. a hash function takes input data(names) and stores the index key/number so that it knows exactly where the item was placed. When a certain key/number is requested, the program knows exactly where to find the requested name rather than searching through each index slot, one at a time.
This is why the use of specific algorithms and data structure techniques are important when building programs. If a program is expected to perform multiple tasks, it needs to run efficiently and leave resources available for other programs or processes to run as well. I hope this helped you understand why a streamlined structure is important to a program's design. Good luck, and we'll see you in the next post!

Comments
Post a Comment