Data structures are fundamental concepts in computer science and programming that define how data is organized, stored, and manipulated in a computer's memory or storage. They provide a way to efficiently store and access data, enabling various operations and algorithms to be performed effectively. Data structures can be categorized into two main types:
These are basic data types provided by programming languages, such as integers, floating-point numbers, characters, and booleans. They represent individual pieces of data and are used as building blocks for more complex data structures.
Abstract data structures are higher-level data structures that are not directly implemented in most programming languages but are created using primitive data types. They define a set of operations and rules for manipulating data but do not specify how the data is actually stored or implemented. Common abstract data structures include:
Data structures are ways to organize and store data efficiently, enabling easy access, modification, and management.
Fixed-size sequential collections of elements of the same type.
A sequence of elements where each element points to the next one.
Nodes point to the next node.
Nodes point to both next and previous nodes.
Follows the Last In, First Out (LIFO) principle. Operations include push, pop, and peek.
Follows the First In, First Out (FIFO) principle. Operations include enqueue and dequeue.
Elements are dequeued based on priority.
Double-ended queue, allows insertion and removal from both ends.
Stores key-value pairs and allows for fast access using a hash function.
Hierarchical data structures with a root node, branches, and leaves.
Each node has up to two children.
A binary tree where the left child is smaller and the right child is greater than the parent node.
A self-balancing BST.
A special tree-based data structure that satisfies the heap property (min-heap or max-heap).
A collection of nodes (vertices) connected by edges. Graphs can be directed or undirected, weighted or unweighted. Adjacency Matrix and Adjacency List are common ways to represent graphs.
Algorithms are step-by-step procedures for solving problems or performing tasks efficiently.
Repeatedly swaps adjacent elements if they are in the wrong order.
Finds the minimum element from the unsorted portion and swaps it with the first unsorted element.
Builds the sorted array by inserting elements into their correct position.
A divide-and-conquer algorithm that divides the array, sorts each part, and then merges them.
Another divide-and-conquer algorithm that picks a pivot and partitions the array into two sub-arrays around the pivot.
Sequentially checks each element until the target is found.
Efficient search algorithm for sorted arrays that divides the array in half to find the target.
Explores as far as possible along each branch before backtracking.
Explores all neighbors at the current depth before moving to nodes at the next depth level.
Finds the shortest path between nodes in a weighted graph.
Used to find the Minimum Spanning Tree (MST) in a graph.
Solves complex problems by breaking them down into overlapping subproblems and solving each just once, storing the results.
Makes the locally optimal choice at each step with the hope of finding the global optimum.
Breaks a problem into smaller subproblems, solves each subproblem recursively, and combines the results.
Tries all possible solutions and backtracks when a solution doesn't work.
A function that calls itself to solve a smaller instance of the problem.
Storing the results of expensive function calls to avoid redundant calculations.
Operations that manipulate individual bits to solve problems efficiently.
Techniques to visit all nodes in a tree (Inorder, Preorder, Postorder).
DFS and BFS for exploring graphs.