What are Data Structures?🤔

What are Data Structures?🤔

Introduction

Everyone knows about Data but knowing how to organize, modify, navigate and access data is more important. Being a good programmer is not only dependent on if your code works but it depends greatly on the readability and scalability which is how fast and memory efficient your code is. The good study of Data Structures and Algorithm helps you to become a good programmer because you will be more concerned about writing good codes that is readable by everyone and is well optimized in terms of time and space(memory).

I believe that you will learn a lot from this article. Sit back, grab your jotting notes or notepad and continue reading🎉

Prerequisite

To get the best out of this series you should know at least the basics of one programming language but preferably JavaScript because this series will be based on Data Structures and Algorithm with JavaScript.

Another thing needed is an open heart to learn and explore Data Structures and Algorithm.

Goal of this article🎉

After reading this article to the end, every reader should be able to :

  • Understand what Data Structures is,
  • The different types of data structures, and
  • The reasons for studying Data Structures.

What are Data Structures?🤔

They are techniques for storing and organizing data that makes it easier to modify, navigate and access. They also determine how data is collected, the functions we can use to access it, and the relationship between it.

The main goal of data structures is to have a way of organizing data so that data can be used efficiently. There are also different kinds of data structures suitable for different kinds of applications, and some are highly specialized to specific tasks.

Different Types of Data Structures

We have two types of Data Structures which are Primitive and Non-primitive Data Structures and under the Non-primitive Data Structures we have Linear and Non-Linear Data Structures.

Linear Data Structures

Data structure where data elements are arranged sequentially or linearly where the elements are attached to its previous and next adjacent in what is called a linear data structure. In linear data structure, single level is involved. Therefore, we can traverse all the elements in single run only. Linear data structures are easy to implement because computer memory is arranged in a linear way. Examples are Array, Linked List, Stacks, Queues.

Non-Linear Data Structures

Data structures where data elements are not arranged sequentially or linearly are called non-linear data structures. In a non-linear data structure, single level is not involved. Therefore, we can’t traverse all the elements in single run only. Non-linear data structures are not easy to implement in comparison to linear data structure. It utilizes computer memory efficiently in comparison to a linear data structure. Its examples are trees and graphs.

dsatypes.png

Meaning of the types of Data Structures

In the previous section we saw that there are linear and non-linear data structures, so in this section we will be picking the data structures and checking the meaning of each of them.

Array

According to me, Array is the most popular and basic Data Structure and it is the most used Data Structure. An array stores data in memory for later use. Each array has a fixed number of cells decided on its creation, and each cell has a corresponding numeric index used to select its data. Whenever you’d like to use the array, all you need are the desired index, and you can access any of the data within.

HjKZtf6JKxcrH8t51iRrId-4lTqjOlGtICip.png

Linked List

Linked lists are a data structure which does not use physical placement of data in memory. This means that, rather than indexes or positions, linked lists use a referencing system: elements are stored in nodes that contain a pointer to the next node, repeating until all nodes are linked.

This system allows efficient insertion and removal of items without the need for reorganization.

trsu6uhv8j0x1fhzx53a.jpg

Stack

Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).

There are many real-life examples of a stack. Consider an example of plates stacked over one another in the canteen. The plate which is at the top is the first one to be removed, i.e. the plate which has been placed at the bottommost position remains in the stack for the longest period of time. So, it can be simply seen to follow LIFO(Last In First Out)/FILO(First In Last Out) order.

word-image.png

Queues

Queues are conceptually similar to stacks; both are sequential structures, but queues process elements in the order they were entered rather than the most recent element.

As a result, queues can be thought of as a FIFO (First In, First Out) version of stacks. These are helpful as a buffer for requests, storing each request in the order it was received until it can be processed.

download.png

Trees

Trees are another relation-based data structure, which specialize in representing hierarchical structures. Like a linked list, nodes contain both elements of data and pointers marking its relation to immediate nodes.

Each tree has a “root” node, off of which all other nodes branch. The root contains references to all elements directly below it, which are known as its “child nodes”. This continues, with each child node, branching off into more child nodes.

1_PWJiwTxRdQy8A_Y0hAv5Eg.png

Graphs

Graphs are a relation-based data structure which are helpful for storing web-like relationships. Each node, or vertex, as they’re called in graphs, has a title, a value contained within, and a list of links (called edges) it has with other vertices.

graphdsa.png

Various Operations that can be performed on Data Structures

  • Insertion: Add a new data item in the given collection of data items.
  • Deletion: Delete an existing data item from the given collection of data items.
  • Traversal: Access each data item exactly once so that it can be processed.
  • Searching: Find out the location of the data item if it exists in the given collection of data items.
  • Sorting: Arranging the data items in some order i.e. in ascending or descending order in case of numerical data and in dictionary order in case of alphanumeric data.

Why Data Structures?🤔

If you want to become a good programmer that writes good code, you must know Data Structures well and how to perform different operations on them😊.

Conclusion

Wow😍, I believe you have learnt a lot from this article. Watch out for more from The Code Lord in this awesome series of Getting Started with Data Structures and Algorithm. To ask more about any concept you can reach me on Twitter and you will get a response. Thanks for reading through😘

Enjoy🎉