Dsa.cpp
Dsa.cpp
on
DSA with C++
Arrays Strings
Arrays provide efficient access to elements based on their Strings are sequences of characters, often implemented
index. They are commonly used in various algorithms and using arrays. They are fundamental for text manipulation
data structures. and data processing.
Linked Lists
Linked lists are dynamic data structures that allow for efficient insertion and deletion of
elements. Each node contains data and a pointer to the next node in the list. Linked
lists are valuable when dealing with data that needs frequent modifications.
Singly Linked
1 Lists
Each node points to the next node, allowing traversal in one direction.
They are simple and efficient for basic operations.
Doubly Linked
2 Lists
Each node points to both the next and previous nodes, enabling
bidirectional traversal. This facilitates efficient operations like insertion at
any position.
Circular Linked
3 Lists
The last node points back to the first node, creating a circular structure.
This is useful for implementing queues and other cyclic data structures.
Stacks and
Queues
Stacks and queues are abstract data types that follow specific rules
for data access. Stacks operate on a Last-In, First-Out (LIFO) principle,
while queues follow a First-In, First-Out (FIFO) principle.
Stacks Queues
Stacks are used for tasks like Queues are used for tasks like
function call management managing tasks in a system
and expression evaluation. or simulating real-world
They are implemented using queues. They are
arrays or linked lists. implemented using arrays or
linked lists.
Trees and Binary
Trees
Trees are hierarchical data structures that represent relationships
between nodes. Binary trees are a special type of tree where each
node has at most two children. They are commonly used for efficient
data searching and sorting.
3 B-Trees
Multi-way trees used for efficient storage and retrieval of data
on disk, commonly used in database systems.
Sorting
Algorithms
Sorting algorithms arrange data in a specific order, such as ascending or descending. Choosing
the right sorting algorithm depends on the size of the dataset, the type of data, and the desired
efficiency.
Bubble Sort
Simple algorithm that repeatedly compares adjacent elements and swaps them if
they are in the wrong order.
Insertion Sort
Efficient algorithm that builds the sorted list by inserting elements one at a time
into their correct position.
Merge Sort
Divide-and-conquer algorithm that recursively divides the list into smaller
sublists, sorts them, and then merges the sorted sublists.
Quick Sort
Divide-and-conquer algorithm that partitions the list around a pivot element, sorts
the sublists, and then combines them.
Huffman Coding
Huffman coding is a lossless data compression algorithm.