I feel the need, the need for efficient Algorithmic Design and Data Structures

We all want the most powerful computer we can afford.  We want our information and we want it yesterday.  The problem is that advances in technology don't often keep up with our desires. There must be another way.  A lot of what eats up programmers' time and energy is creating programs that take less time and energy.  What this really means is that they spend their time designing and implementing the most efficient "Data Structure" they can for the task at hand.

"A data structure is a particular way of organizing a computer so that it can run more efficiently." (Geeks for Geeks. 2022).

Data structures are used to address a wide variety of scenarios.  Not every problem benefits equally from each data structure type.  There is a wide array of data structure types, the first of which is an array.  There are also linked lists, queues, stacks, trees, and several other types.  The previous examples could be argued to be the most commonly used, so does that make them the "best"?  Perhaps.  Maybe for your scenario, they could be the best.  If not those, then which data structure is the best?  Thankfully, the simple answer is "yes".

The best I can do for you is give an example of common data structure types and explain why they may be beneficial for your scenario (with some help from Vijini Mallawaarachchi over at Towards Science).

Array

An array is a structure of a fixed size holding data of the same type (integers, strings, etc.).  Arrays are indexed, meaning you can easily access information at any point within the array if you know the index point.  Because of this, arrays are excellent for basic lists of like data.

Linked Lists

Like arrays, linked lists contain data, but they do so in a linear order based on the other items in the list.  Because of this, the order matters and pulling things out or adding them is not flexible like an array.  Each element in a linked list is a "node" (other than the first the "head" and last the "tail").  Each node has a key providing what the next node is.

Stacks

As the name implies, this means the last item that we place in the structure would be the first to leave.  Last in first-out (LIFO).

Queues

Akin to Stacks, queues are useful for being able to store data and then easily access/use it in an order that it was placed into the structure.  Unlike stacks, queues work with a first in first out ordering.  Meaning what was placed in the queue first, will be the first item that the queue defaults to using.

Hash Tables

Each value will also have a key.  These tables will contain more data and therefore be larger, but they support more efficient searching and manipulation.   Because of their excellent search abilities, has tables come in handy for database functions.

Trees

Trees are excellent at converting carbon dioxide created by computers into usable oxygen for the user.  That, or they are a hierarchal structure where data is linked together, but in a fashion where data branches out from another item higher in the list.  Very similar to a linked list, but in a linked list it is completely linear without the branches.  Trees can be useful for search functions where data is changing and needs to remain adaptable.

Heaps

Very similar to trees (a binary tree), but the parent nodes are compared to the children nodes and are arranged up and down the branch by value.  This data structure type can help with queuing functions that need to help set priority orders.

 

Graphs

Graphs are like trees in that they contain branches to other data and graphs contain nodes, but the structure of graphs is very rigid in that it has a set number of data items that will contain in their vertices and edges (think columns and rows). In graphs, elements can be connected to each other in various directions and to multiple elements.

(Mallawaarachchi. 2020)

"An algorithm is a procedure to solve a particular problem in a finite number of steps for a finite-sized input.". (Simranjenny84. 2020).

So using data structures, we can create solutions to problems we need to address in a scalable manner.  We implement an algorithmic design in much the same way, but rather than creating a structure capable of handling various different possibilities. Algorithmic design tackles a specific problem.  They work in primarily three different ways:

Recursion or Iteration

These algorithms essentially break down larger problems into smaller ones by calling on themselves over and over until the problem is solved.  Essentially each aspect of the problem is delegated out to a lower tier to be solved until all that can be returned is the answer.

Exact or Approximate

These algorithms are capable of finding the average outcomes or the most optimal outcome.

Serial or Parallel Algorithms

These algorithms break the problems into smaller problems in which individual algorithms work their independent issue, then combine the results for the complete answer.

(Simranjenny84. 2020).

Like finding the best data structure, algorithmic design can vary from need to need.  There will be scenarios where working in parallel is best.  In other cases, that may not be possible (for example if you need exact data but are using floating-point integers). In other cases, you will want a design that is very regimented to create the most optimal output.  In my limited experience as a newbie, I tend to favor an algorithmic design that leans towards divide and conquer.  Creating smaller problems from bigger ones.  This may take extra steps in the programming, but can provide a more efficient and less taxing process overall.

Like you, as I grow and learn, I will find new and different ways of thinking that will help guide me in my programming.  For now, I suggest we use different data structures and algorithmic types to see what works and doesn't work for us.  Best of luck.

Geeks for Geeks. (2022, January 31). Data Structures. Geeks for Geeks. https://www.geeksforgeeks.org/data-structures/

Mallawaarachchi, V. (2020, February 28). 8 Data Structures Every Programmer Must Know. Towards Science.  https://towardsdatascience.com/8-common-data-structures-every-programmer-must-know-171acf6a1a42

Simranjenny84. (2020,  September 30). Algorithms Design Techniques. Geeks for Geeks. https://www.geeksforgeeks.org/algorithms-design-techniques/


Comments