Data Structure and Types
What is data Structure?
Data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer to make it easily accessible and up to date.
Note: Data types and data structures differ slightly. The collection of data types arranged in a particular order is known as a data structure.
Types of Data Structure
Data structure is divided into two categories:
- Linear data structure
- Non-linear data structure
Linear Data Structure
A linear data structure is one in which the elements of the data are arranged sequentially or linearly, with each member being connected to its immediate neighbor and the neighbor after it. It is possible to traverse the entire linear data structure in a single run.
Types of Linear Data Structure
- Array Data Structure
- Queue Data Structure
- Stack Data Structure
- Linked List Data Structure
Array Data Structure
An array is a linear data structure that collects elements of the same data type and stores them in contiguous and adjacent memory locations. Arrays work on an index system starting from 0 to (n-1), where n is the size of the array.
Stack Data Structure
The data structure follows to the Last In-First Out (LIFO) principle, where the element that was most recently added is removed first. Data elements are added to a stack using the push operation, and data elements are removed using the pop operation. The example of stacked books can be used to explain this. All books stacked on top of the last book must be carefully removed in order to access the last book.
Queue Data Structure
A queue is a useful data structure in programming. It is similar to the ticket queue outside a cinema hall, where the first person entering the queue is the first person who gets the ticket.
Linked List Data Structure
In linked list data structure, data element are connected through a series of nodes. And, each node contains the data items and address to the next nodes.
Non-Linear Data Structure
Data structures where data elements are not arranged sequentially or linearly are called non-linear data structures. A non-linear data structure does not use a single level. As a result, we are unable to traverse all the elements in a single run. In contrast to linear data structures, non-linear data structures are more difficult to construct. Unlike a linear data structure, it efficiently uses computer memory. Trees and graphs are two examples.
Types of Non-linear data structure
- Trees
- Graph