DEV Community

spkibe
spkibe

Posted on

Introduction to Data Structures and Algorithms.

A carpenter has several tools, yet each one has a specific purpose in completing a task. Similar to a programmer, depending on the task at hand, programmers will require the appropriate tool to handle a certain challenge.
Data structures are programmers' tools, and each one serves a specific purpose. Many companies uses data structures challenges in their interviews to see if a programmer is a strong problem solver.
Data structures are classified into two major sections:
1. Linear Data structures → stores data in a sequential manner.
2. Non-linear Data Structure → stores data in a non- sequential manner.

Types of Linear data structures:

1) Arrays → stores values in arranged continuous memory. Elements stored in the arrays are determined by the programming language.
2) Stack →  It stores its elements according to the LIFO (last in, first out) principle, which means that the last element added is the first one withdrawn.
3) Queues → It stores its elements using the FIFO (first in, first out) principle, which means that the first element inserted will be the first one withdrawn
4) LinkedList → It organizes its data as a connected network of nodes, with each element containing the address of the next node.
Enter fullscreen mode Exit fullscreen mode

Types of Non-Linear data structures:

1) Graphs → it’s made up of nodes or vertices and edges. Edges connects two nodes.
2) Trees → stores data in a hierarchical manner which is tree-like structures arranged in multiple levels. It has the root node(top most part) which is the central node. 
Enter fullscreen mode Exit fullscreen mode

Algorithms
Is a set of instructions or procedure for solving a specific problem, you can think of it as a recipe to solve a problem or as a blueprint for solving a problem to make it easier to grasp.
Types of Algorithms:
1) Sort algorithms
2) Search algorithms
3) Hashing

Each written algorithm uses some memory to complete. This is where algorithm complexity comes into play; it calculates the amount of time and space required to execute an algorithm.
Space complexity → The overall amount of space taken up by the algorithm in relation to the input size.
Time complexity → is the amount of time algorithms takes to run. It is mostly expressed using the big O notation(asymptotic notation to represent time complexity). For example,a problem of size n:
1. O(1) is a constant-time function
2. O(n) is a linear-time function
3. O(n^2) is a quadratic-time function

Top comments (0)