Algorithmic Design and Data Structure Techniques
Applying Algorithmic Design and Data Structure Techniques
When creating applications, there are complexities of time and space that must both be considered. Simply speaking, time complexity is the amount of time a computer algorithm takes to run. This time is measured in milliseconds, but when applied to a larger application with a large amount of data, this time becomes much more important. Space complexity considers how much space or memory an algorithm uses to solve a problem. As the algorithm uses more data, space may be freed up with each computer cycle or keep growing. If the space necessary continues to grow, there is a possibility of running out of memory.
Using algebraic calculations, more commonly known as “Big O” notation, a software designer can determine if time grows by a number equal to the input or if there is an exponential growth in time as input increases. “Big O” notation can also be used to determine if memory usage remains constant or continues to grow with data input.
Are some algorithms and data structure designs better than others?
Algorithms need to be selected based on the type of input that you will be receiving. It makes a difference in which algorithm is used. An example of this could be a binary search algorithm. A binary search should only be performed on data that is, or can be, sorted. For example, if you have a sorted list of numbers and are looking for a specific number, a binary search will be faster than a linear one. A binary search will take the list, divide it in half and see if the middle number is the number you are searching for. If it’s not found, the algorithm will know it should reside in the upper or lower half of the halved list. It will then ignore 50% of the original list and search in the remaining 50%, again dividing the list in half. The process of dividing and checking the middle number repeats until the number is found or not found.
In comparison, a linear search would check every single number in the list. If you originally had a list of 100 items and you were looking for 50, the first search would find it with a binary search. It would take about 50 comparisons to find with a linear search.
Developing Your Application
When developing a structured program, it is important to scope your project. Clearly define the problem and your constraints, such as input size, output format, and limitations. Choose an algorithm that seems to be the best match for the type of problem you are working on. Test your choice with various inputs to ensure it works correctly and efficiently. This should help you to determine if your choice was valid or if you need to try another algorithm. It is important to continuously learn and practice techniques to improve your skills.