Algorithmic Design and Data Structures For Newbies

 Hello, fellow loons!

If you're here, it's because you have a hunger for more knowledge like me, so just know you're in a welcoming space! For this week's blog post, we're going to get into some of the basic ideas and ways to approach algorithmic design to build programs you can be proud of! Planning your approach to algorithmic design is no different than planning anything else. It involves organizing the tools you have at your disposal in a way that provides the easiest path forward to what you're trying to achieve.

Algorithmic Design: The Plan for the Plan

While that header may seem a bit redundant, it's also appropriate. An algorithm itself is a list of step-by-step instructions meant to solve a problem. The type of problems it can solve is only limited by your ability and imagination. Think of it as a recipe. With that said, think of algorithmic design as gathering the ingredients you have to figure out what kind of recipe you can make and plan for it. This process can be broken into simple steps. Below, I've listed the steps I will usually take to get started with something like this.

  • Figure out the Problem: In order to have any chance at having good organization to solve a problem, we first must know what the actual problem is. We need to know what we want our output to consist of, what parameters it needs to follow, and what the expected input to get there would be.
  • Break Down the Problem: As with most problems that are complex, it can be overwhelming to tackle all at once. Generally, the best practice is to break it down into smaller problems that will each have their own algorithm to serve them.
  • Pick a Strategy: There is usually more than one way to solve most problems, so at this stage, we need to decide how we're going to approach things. If it's something simple, we want our approach to be direct and simple as well. This ensures we're efficiently using our resources.
  • Write the Code: Now that you've decided on your strategy, it's time to write down the steps or path your program needs to take to come to your solution. This must be precise, which is the reason for our next step.
  • Test, and Test Again: Once you've completed your algorithm, you need to begin testing it with all the possible inputs you can think of to ensure it behaves properly. The last thing you want is someone asking your program a question in a way it isn't prepared to answer properly. If you find that something can be done more efficiently, or something that needs to be corrected, now will be the time to adjust and refine to ensure a working and worthwhile final product.

More Organization: Data Structures

Within your process of solving problems through algorithms, you will use data structures. Data structures are different ways of storing and organizing data so that we can use resources efficiently. An easy way to think of them would be like Tupperware. You wouldn't put a sandwich in a container meant for a pot roast. It would be a huge waste of space in your fridge for such a small item. Choosing the right data structure for the job is crucial to efficient management of resources. While we won't dive too deep into different data structures, here are a few examples to give you a basic idea.

  • Dictionaries/Hash Maps: Think of this as a normal dictionary. You look up a specific word in order to find its definition or the associated information. 
  • Linked Lists: A change of items where each item holds a set of data and a link to the next item in the chain. These are good for situations where something needs to be added or removed easily.
  • Arrays: Think of a row of labeled boxes at a garage sale. If you know what you're looking for, it's easy to access it as long as you are familiar with the labels on the boxes.
Choosing The Right Tool:

When choosing the right tool for the job, we have to look at what we are trying to accomplish. If the overall aim is speed without regard for resources, then we might approach a problem differently than if the overall aim is to be as efficient as possible with memory usage. To put it another way, if we want to chop a tree down, a chainsaw is likely going to be our best bet to fell the tree the fastest, but if we need the tree to fall a certain way so it doesn't destroy our house, we're going to need to be a bit more careful and take some other things into consideration.

  • Prioritize: Time Efficiency- Some algorithms simply take less time to complete the same task. If you were searching for an item in a sorted list, you would want to use a binary search rather than a linear search because it's much faster. 
  • Prioritize: Space Efficiency- There are data structures that use less memory despite being the same or even a larger amount of data. Choosing the right data structure or "container" for data is can be incredibly important in systems with limited resources. If you had a fixed amount of something you were searching for, an array might be more efficient than a linked list when it comes to space due to the need for extra memory in a linked list.
  • Prioritize: Ease of Use- An algorithm or data structure might be the best choice based on ease of use rather than efficiency or speed. If the algorithm is more complex, it may not be worth the time and effort to implement if the end goal is much simpler and easy to execute with a simpler program.
What does it all mean?
So, as I mentioned before, the best way to approach a problem that seems overwhelming is to break it into smaller problems, which is essentially the spirit of algorithms, data structures, and coding in general. By taking care to make a conscious decision to plan things out beforehand, you can ensure that your journey into algorithms and data structures goes smoothly. This method is your best bet for creating code that not only works but is something you can be proud of and present to someone without fear. I know that even absorbing information like this can feel overwhelming, so do the same thing, take it a bit at a time, and just try to have fun with it. I hope you've learned something new today!





Helpful Resources

Best Data Structure and Algorithms Courses (Geeks For Geeks)
  • https://www.geeksforgeeks.org/best-data-structures-and-algorithms-courses/
Best Free Resources for Data Structures and Algorithms (Dev.t0)
  • https://dev.to/ayabouchiha/free-resources-to-master-algorithms-data-structure-2nfj




Comments

Popular posts from this blog

Java and Object Oriented Programing (OOP)

Operating Systems Concepts