Pages

Wednesday, April 13, 2022

Data Structures and Algorithmic Design Techniques for Beginners

 


Data Structures are simply implementations of other data types that allow programmers to store and arrange data on computers.  Data structures can be linear (LinkedList, Array, Stack, Queue, etc...) or non-linear (Trees, Graphs, etc...).  Which data structure to use largely depends on what data you want to store and how you want to interact or access its elements.

For example, if a requirement of a program is to access the data using FIFO or LIFO, then a Stack or Queue data will be the most appropriate data structure for this application.  Conversely, if you want to store data that is hierarchical in nature, then a Tree will provide the best structure for this application.

There isn't really a best or worst data structure out there without knowing the context in which it will be used; however, after knowing the context, some data structures will prove to be more efficient than others given their specific interfaces and the time it takes to iterate through the data to perform a given task.

An important component in selecting the appropriate data structure is determining the algorithm that will be used to interact with the data.  An algorithm is a procedure to solve a particular problem that requires n number of steps to finalize its task given an input.

There are three main categories of algorithms.  Recursion, Exact or Approximate, and Serial, Parallel, or Distributed algorithms.  A recursive algorithm is one that calls itself in a loop until a specific condition is met.  An Exact algorithm includes most sorting algorithms.  A Serial algorithm is one that executes one instruction at a time, whereas a Parallel algorithm divides the problem into subproblems and executes each of them in a different process or thread.

With all this taken into consideration, if I had a problem to solve on a large dataset that required multiple problems to be solved independently in the most expeditious manner, I would use a Parallel algorithm such that I could take advantage of a multithreaded processor to increase overall processing speed.  The data structure to be used in this case will depend on what the data is, but say it was employee data sorted hierarchically to reflect reporting lines, a Tree would be used along with that parallel algorithm.

Cheers!

Hugo

No comments:

Post a Comment