Data Structures

Data structure is a storage that is used to store and organize data

Linear data structures

  • Array Data Structure: elements are arranged in sequence
  • Stack Data Structure: elements are stored in the LIFO principle
  • Queue Data Structure: queue data structure works in the FIFO principle
  • Linked List Data Structure: elements are connected through a series of nodes, each node contains the data items and address to the next node

Non linear data structures

Arranged in a hierarchical manner

  • Graph Data Structure: each vertex is connected to other vertices through edges
  • Trees Data Structure: there can only be one edge between two vertices
Linear Data Structures Non Linear Data Structures
The data items are arranged in sequential order, one after the other. The data items are arranged in non-sequential order (hierarchical manner).
All the items are present on the single layer. The data items are present at different layers.
It can be traversed on a single run. It requires multiple runs.
The memory utilization is not efficient. Different structures utilize memory in different efficient ways depending on the need.
The time complexity increase with the data size. Time complexity remains the same.
Example: Arrays, Stack, Queue Example: Tree, Graph, Map

Big-O Notation

Efficiency of an algorithm depends on the amount of time, storage and other resources that it requires to execute.