What is a data structure?
A data structure is a specialized format for organizing, processing, retrieving, and storing data in computer memory. It defines the relationships between data items and the operations that can be performed on them, ensuring efficient CPU and memory utilization.
1. Linear Data Structures
Definition
A linear data structure arranges elements sequentially in a single line, where each element is connected directly to its previous and next adjacent elements.
Types
Arrays: Fixed-size sequential collections of elements stored in contiguous memory locations.
Linked Lists: Collections of nodes linked via pointers, stored non-contiguously in memory.
Stacks: Last-In, First-Out (LIFO) structures where insertion and deletion occur at a single end (top).
Queues: First-In, First-Out (FIFO) structures where elements enter at the rear and exit from the front.
Detailed Breakdown
In linear structures, data traversal is straight and predictable—elements are processed in a single run. Accessing an element in a static array takes O(1) constant time using an index formula:
In dynamic lists like linked lists, elements contain data along with memory addresses pointing to the next node, allowing dynamic resizing at the cost of O(n) access time.

Code Examples (Linear Structures)
C++ (Array Implementation)
C++
#include <iostream>
int main() {
int numbers[5] = {10, 20, 30, 40, 50};
// Direct O(1) index access
std::cout << "Element at index 2: " << numbers[2] << std::endl;
return 0;
}
Python (Linked List Node Definition)
Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
# Creating linked nodes
head = Node(10)
head.next = Node(20)
print(f"Head: {head.data}, Next: {head.next.data}")
Java (Stack Implementation)
Java
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Stack<Integer> stack = new Stack<>();
stack.push(100);
stack.push(200);
System.out.println("Popped element (LIFO): " + stack.pop()); // 200
}
}
2. Non-Linear Data Structures
Definition
A non-linear data structure connects elements hierarchically or in interconnected networks, where a single element can link to multiple other elements without a direct sequential order.
Types
Trees: Hierarchical, acyclic structures with a root node, parent nodes, and child nodes (e.g., Binary Search Trees, Heaps).
Graphs: Networks composed of vertices (nodes) connected by edges (relationships), which can be directed, undirected, weighted, or unweighted.
Detailed Breakdown
Non-linear structures reflect complex relationships such as file systems, network routing tables, and social graphs. Elements cannot be traversed in a single pass; instead, traversal algorithms like Depth-First Search (DFS) or Breadth-First Search (BFS) are required. Searching in a balanced Binary Search Tree (BST) achieves logarithmic time complexity:
Code Examples (Non-Linear Structures)
C++ (Binary Tree Node)
C++
#include <iostream>
struct TreeNode {
int data;
TreeNode* left;
TreeNode* right;
TreeNode(int val) : data(val), left(nullptr), right(nullptr) {}
};
int main() {
TreeNode* root = new TreeNode(1);
root->left = new TreeNode(2);
root->right = new TreeNode(3);
std::cout << "Root: " << root->data << ", Left: " << root->left->data << std::endl;
return 0;
}
Python (Graph via Adjacency List)
Python
# Representing a graph network
graph = {
'A': ['B', 'C'],
'B': ['A', 'D'],
'C': ['A'],
'D': ['B']
}
print("Nodes connected to A:", graph['A'])
Java (Binary Search Tree Node)
Java
class BSTNode {
int value;
BSTNode left, right;
public BSTNode(int item) {
value = item;
left = right = null;
}
}
public class Main {
public static void main(String[] args) {
BSTNode root = new BSTNode(50);
root.left = new BSTNode(30);
System.out.println("Root Value: " + root.value);
}
}
3. Abstract Data Types (ADTs)
Definition
An Abstract Data Type (ADT) is a theoretical model for data structures that defines what operations can be performed on the data without specifying how those operations are implemented in code.
Types
List ADT: Defines operations like
add(),get(),remove().Map / Dictionary ADT: Defines key-value association operations like
put(key, value),get(key).Priority Queue ADT: Defines queueing where elements are removed based on priority order using
insert()anddeleteMin().
Detailed Breakdown
ADTs act as contracts between the programmer and the underlying implementation. For instance, the Map ADT guarantees that keys map to unique values. Internally, a Map can be implemented using a Hash Table (O(1) average access time) or a Red-Black Tree (O(log n) guaranteed access time).
| Data Structure / ADT | Access Time (Avg) | Search Time (Avg) | Space Complexity |
| Array | O(1) | O(n) | O(n) |
| Linked List | O(n) | O(n) | O(n) |
| Binary Search Tree | O(log n) | O(log n) | O(n) |
| Hash Table | N/A | O(1) | O(n) |
Explore More IT Terms
#
A
- A Guide to SQL Query Formatting
- A/B testing
- AES Encryption Algorithm: How It Works and Where It's Used
- Agile
- Algorithm
- Algorithm Complexity
- Algorithm vs. Program
- Algorithms and Data Structures in C#
- An overview of the C # programming language
- An overview of the Python programming language
- Anaconda Python
- Android
- Android App Bundle
- Android SDK
- Angular
- Ansible
- Apache
- Apache Airflow
- Apache Kafka
- Apache Tomcat
- App Store
- AppCode
- Applications of microcontrollers: From simple circuits in electronics to complex systems
- Applications of the derivative
- Arduino: How to Program It: Basics for Beginners
- Array-based stack
- ArrayList
- ASCII
- ASP.NET
- Assembly Language Lessons
B
C
D
- Data Analytics: applications of data analysis in companies
- Data Engineer - Who is it, what does a data engineer do, and an overview of the profession
- Data modeling: what it is, types, and process steps.
- Data preprocessing: a complete guide for beginners and professionals.
- Data structure
- Data Structures and Algorithms (DSA)
- Database Tests with Answers
- Deep Learning
- Defining Aliases
- Defining Arrays
- Deque
- Developing a Website from Scratch
- Differential Equations
- Differentiation of functions
- Digital data: understand the importance of this asset for businesses.
- Double integrals
- Doubly linked lists
- DSA Tutorial
E
F
H
- Handling errors and exceptions
- Heads or Tails? How Probability Theory Is Used in IT
- History of the development of computer science
- Homogeneous equations
- How to effectively organize your workflow
- How to Learn Java: Tips for Beginner Developers
- How to Learn PHP: A Beginner's Guide
- How to Use S3 Storage in Kubernetes with CSI
- HTML
- HTML and CSS: Definition, Application, and Operating Principles
- HTML and CSS. Layout from Scratch: What to Learn, Where to Learn, and How Long Will It Take?
- HTML Frame Structure
- HTML Link Formatting
I
- if..else construction
- Infinite sequences and series
- Information properties
- Inheritance in Java: A Complete Guide to Principles and Implementation
- Inserting an Image
- Integration of functions
- Interactive Python Tutorial – Learn Programming from Scratch
- Interpreter
- Interview Problem: Finding a Deleted Element in O(N)
- Interview Scare: The FizzBuzz Challenge
- Introduction to C++
- Introduction to Machine Learning
- Introduction to Networking | Network Fundamentals Part 1
- Introduction to Number Systems (Binary, Octal, Hexadecimal) | Math for CS Foundations #1
- IT Specialist Resume (CV)
J
K
L
M
- Machine Learning
- Machine Learning Basic Tool: NumPy
- Machine Learning Basic Tool: Pandas
- Machine Learning Mathematics
- Mathematics for programmers: what is really needed?
- MD5 encryption algorithm: What is it and why is it needed?
- Microcontroller and Microprocessor - what's the difference?
- ML Engineer: Who They Are, What They Do, How Much They Earn, and How to Become a Neural Network Specialist
- Monte Carlo Simulation: How It Works and What It's For
O
P
- PHP lessons
- Private DNS server and its configuration
- Program code
- Programmer's Dictionary
- Programming
- Programming with pseudocode
- Python Code Formatting Guide: PEP8
- Python for data analysis: how to do it and main libraries
- Python Lessons
- Python Superstar: 5 Ways to Use the * Operator
- Python vs. Julia: Should You Replace Python with Julia?
R
S
- SFML Graphics Library Tutorials
- Sorting Algorithms in Programming: Types, Descriptions, and Comparisons
- SQL commands: see what they are, what the main ones are + examples
- SQL Interview Questions and Tasks
- SQL Lessons
- SQL Stored Procedures
- SQL Syntactic Sugar: The COALESCE Function
- Stack
- Start in analytics: Python or R
- Statistical analysis: importance for decision making.
- String formatting in Python
- Structure of computer science
- Swift Lessons
- switch/match construct
- Syntax
T
- Terms in programming
- Text and paragraph formatting tags
- The concept of information and its transmission
- The Future of Python: Key Trends and Insights from Global Researc
- The Infrastructure of Code: A Complete Guide to Repositories for Languages, Frameworks, and Compilers
- The pip package manager in Python
- The role of informatization in the development of society
- Transfers
- Tutorials / Articles
- TypeScript: What It Is and Why Developers Need It
W
- What are databases, and why do they need DBMS and SQL?
- What do Linux distributions consist of?
- What is .NET and what is it used for?
- What is a data structure?
- What is a GPU in a computer, in simple terms?
- What is a quantum computer: 100,500 problems in one second
- What Is an Algorithm?
- What is Arduino: How it Works and the Platform's Capabilities
- What is Big Data? Introduction, Types, Characteristics, and Examples
- What is Golang and what is it used for?
- What is Haskell and what is it used for?
- What is Kotlin and what is it used for?
- What is Linux? The History of Linux
- What is machine learning, and how does it work?
- What is Power BI: everything about the data analytics software
- What is the C++ programming language?
- What is the OSI Model: A Complete Explanation of the Seven Layers and Their Role in Networking
- What's the difference between x86 and ARM processors?
- Where to start learning the C programming language?
- Which Linux distribution should you choose? A Linux distribution overview




