Algorithmic and Data Structure Design Implementation

Ok so we know that algorithms are essentially a certain way to get something done (also explained as a recipe or set of instructions). We also know that data structures are how we mess with data. So there are different ways or "bins" to help store, copy, move, or alter data and there are various types of algorithms for different needs, such as searching, sorting, or calculating.

So, like any job, we apply the best tool in our knowledge that fits the given situation. Also like any job, we take into consideration what it will cost. In a Computer Science perspective this means Big O notation. We take into account the time and space (memory space) that an algorithm or data structure will take to operate. There are many sources that explain these topics in detail, some of which are linked below for your convenience, but Big O notation is basically a measure of the worst-case scenario for any given algorithm/data structure. We can compare algorithms/data structures based on their Big O notations and select the best one for our needs. Like the saying goes, prepare for the worst but hope for the best. 

https://misc-flexiple.s3.amazonaws.com/bon_cheat_sheet.jpg

This also means that for some situations, certain algorithms/data structures might be better than others. For example, if the size of the data you need to search is is unsorted and small, then you might implement a linear search, as this would check each and every element until a match is found.

If the size of the data is big and unsorted, then you might not opt for a linear type of search as this would take forever. You might instead sort the data first and then implement a binary search as this would keep splitting the data based on "greater than" and "less than" to narrow down the match. 

So while binary search is considered faster than linear search, it has a pre-requisite. Linear search does not, but it does take longer. 

https://www.hackerearth.com/practice/notes/sorting-and-searching-algorithms-time-complexities-cheat-sheet/




Sources

Geeks for Geeks. (Apr. 26, 2023) Understanding Time Complexity. https://www.geeksforgeeks.org/understanding-time-complexity-simple-examples/

Geeks for Geeks (Sept. 07, 2022) What does 'Space Complexity' mean? https://www.geeksforgeeks.org/g-fact-86/ 

F/exip/e (n.d.) Big O Notation Cheat Sheet. https://flexiple.com/algorithms/big-o-notation-cheat-sheet/

Hackerearth (n.d.) https://www.hackerearth.com/practice/notes/sorting-and-searching-algorithms-time-complexities-cheat-sheet/


Comments