Basics of Data structure
Data structure :
It is a particular way of organizing, processing, retrieving and storing the data.
Data Structures are the main part of many computer science algorithms as they enable the programmers to handle the data in an efficient way.
It plays a vital role in enhancing the performance of a software or a program as the main function of the software is to store and retrieve the user’s data as fast as possible.
It is the building blocks of any program or the software.
Scope :
Data Structures are widely used in almost every aspect of Computer Science i.e. Operating System, Compiler Design, Artificial intelligence, Graphics and many more.
Why we need DS :
As applications are getting complexed and amount of data is increasing day by day, there may arise the following problems:
Processor speed: To handle very large amount of data, high speed processing is required, but as the data is growing day by day to the billions of files per entity, processor may fail to deal with that much amount of data.
Data Search: Consider an inventory size of 106 items in a store, If our application needs to search for a particular item, it needs to traverse 106 items every time, results in slowing down the search process.
Multiple requests: If thousands of users are searching the data simultaneously on a web server, then there are the chances that a very large server can be failed during that process.
In order to solve the above problems, data structures are used.
Data is organized to form a data structure in such a way that all items are not required to be searched and required data can be searched instantly.
Advantages of Data Structures :
Efficiency: Efficiency of a program depends upon the choice of data structures.
Reusability: Data structures are reusable, i.e. once we have implemented a particular data structure, we can use it at any other place. Implementation of data structures can be compiled into libraries which can be used by different clients.
Abstraction: Data structure is specified by the ADT which provides a level of abstraction. The client program uses the data structure through interface only, without getting into the implementation details.
Data Structure Classification :
Primitive data structure:
It is a data structure that can hold a single value in a specific location.
Ex: float, character, integer and pointer.
Non-primitive data structures:
The non-linear data structure can hold multiple values either in a contiguous location or random locations.
Ex: Array, Stack , Queue etc.
Further Classification:
Linear data structures :
In LDS, data elements are arranged sequentially or linearly where each and every element is attached to its previous and next adjacent.
Ex: Array , Linked List, Stack and Queue
Array :
The array is a type of data structure that stores elements of the same type.
Linked List :
In Linked lists the data is stored in the form of nodes which consist of an element of data and a pointer. The use of the pointer is that it points or directs to the node which is next to the element in the sequence. The data stored in a linked list might be of any form, strings, numbers, or characters. Both sorted and unsorted data can be stored in a linked list along with unique or duplicate elements.
Stack :
It follows the rule of LIFO (Last In-First Out) where the data last added element is removed first. Push operation is used for adding an element of data on a stack and the pop operation is used for deleting the data from the stack.
Queue :
This structure is almost similar to the stack as the data is stored sequentially. The difference is that the queue data structure follows FIFO which is the rule of First In-First Out where the first added element is to exit the queue first. Front and rear are the two terms to be used in a queue.
Enqueue is the insertion operation and dequeue is the deletion operation.
Non-linear data structures :
This data structure does not form a sequence i.e. each item or element is connected with two or more other items in a non-linear arrangement. The data elements are not arranged in sequential structure.
Ex: Trees and Graphs
Trees :
A tree data structure consists of various nodes linked together. The structure of a tree is hierarchical that forms a relationship like that of the parent and a child. The bottommost nodes in the hierarchy are called leaf node while the topmost node is called root node. Each node contains pointers to point adjacent nodes.
Ex: AVL tree, binary tree, binary search tree, etc.
Graphs :
Graphs are those types of non-linear data structures which consist of a definite quantity of vertices and edges. The vertices or the nodes are involved in storing data and the edges show the vertices relationship.
The difference between a graph to a tree is that in a graph there are no specific rules for the connection of nodes.
Real-life problems like social networks, telephone networks, etc. can be represented through the graphs.
Hash Tables ::
These types can be implemented as linear or non-linear data structures. The data structures consist of key-value pairs.
Operations on data structure :
Traversing, Insertion, Deletion, Searching, Sorting, Merging
Happy to connect you !!