Data structures are specialized methods of storing and organizing data in computers so that operations on stored data can be performed more efficiently. This 'layout' enables a data structure to be efficient in some functions while being inefficient in others.
Data must be stored in a specific format depending on the scenario. The following is a list of eight common data structures that cover our need to store data in various forms.
1. Arrays
An array is a straightforward and widely used data structure. It is a fixed-size structure that can hold items of the same data type. It can be an array of integers, a floating-point number array, a string array, or even an array of arrays (known as multidimensional arrays)
2. Stacks
A stack is a LIFO (last in, first out) structure that is common in many programming languages. This structure is called Stack because it looks like a stack of plates in real life.
3. Queues
A Queue is a FIFO (First in, First Out-the element placed first can be accessed first) structure found in many programming languages. The structure is called 'queue' because it looks like a real-world queue.
4. Linked Lists
A linked list is a sequential structure composed of a series of items connected in linear order. As a result, you must access data sequentially; random access is not possible. Linked lists are a simple and flexible way to represent dynamic sets.
5. Hash Tables
A hash table is a data structure that stores values and the keys that go with them. Furthermore, if we know the key is related to the value, it supports efficient lookup. As a result, regardless of data size, it is very efficient in inserting and searching.
6. Trees
A tree is a hierarchical structure in which data is organized and linked together. This structure differs from the linked list in that items are linked in the linear order of the linked list. Examples of binary search trees include the red-black tree, the splay tree, the B tree, the red-black tree, the AVL tree, and the n-ary tree.
7. Heaps
A heap is a type of binary tree in which parent nodes are compared to their children and their values are arranged accordingly. It can be represented using both trees and arrays.
8. Graphs
A graph is made up of a finite number of nodes or vertices and a set of edges that connect these vertices. The number of vertices in the graph determines the graph's order. The number of edges in a graph determines its size.
