Data Structures and Algorithms - Quick Guide

 

Hey everyone!  When you start designing a program, you need to choose the appropriate algorithm and design techniqueUltimately, the best technique will depend upon the program you are designing and the goals.  If you are designing a program on the simpler side that wants to take user inputs, store them, and then display a list you would want a simple approach with lower time complexity.  Time complexity meaning the number of times a function is recalled, or comparisons are run.   

However, let’s say you are designing a program that needs to take user inputs, make calculations, then create an output that has both the originals and the calculations in it.  Then a better approach would be to use a method like divide and conquerSplitting the program up into different functions to perform different duties and then having them speak to each other.  Then it can be expanded upon into dynamic programmingThis method takes the data from the inputs or the functions and stores it places so you can use it again later in the programThese methods are great for sorting problems that need to quickly process the same datasets using the same functions.   

If the goal of your program though has singular solutions though would use different methods like backtrackingThis is where solutions are searched for at each step and if they are not found the program backtracks and explores the next step.  This can be used in any number of programs that have branches of code or functions to explore. 

 

The other thing to consider in program design is the data structures you need.  Choosing a data structure is less flexible than choosing algorithms.  The writers over at web3 wrote an article breaking down the basics of data structures and algorithms, check it out!  If you are using numeric values like integers or floats that but, you will need to find specific values later in the program you cannot use a stack, you would need an array or a linked listA stack is like a silo, data can only enter and exit through one hole so, you cannot index a stack for a specific value, but an array you can.   

Algorithms and data structures are fundamental when designing any type of program, so I hope this gives you a quick idea of what to expect and how to make those decisions! 

Comments