Day 1 – Crack DSA with a New Spark
๐ Introduction to DSA
Welcome to my very first blog post!
I’ve decided to begin my journey into the world of Data Structures and Algorithms (DSA) — and I’m excited to share it with you all.
This blog will not only track my daily learning progress but also help beginners like me who want to crack DSA step by step with clarity and consistency.
๐ What I Learned Today
๐ What is DSA? (My Understanding)
"Data Structure and Algorithm represents the logical relationship between individual elements of data, and Data Structures are a way of organizing all data efficiently."
"Data Structure and Algorithm represents the logical relationship between individual elements of data, and Data Structures are a way of organizing all data efficiently."
This is the definition I came across in a textbook, and it made a lot of sense to me.
To break it down:
-
Data Structures (DS) are the way we store and organize data (like arrays, linked lists, etc.)
-
Algorithms (A) are the step-by-step procedures that process the data efficiently
๐ Verified from GeeksforGeeks
According to GeeksforGeeks:
Data Structures are ways to store data for different purposes.
The choice of a data structure depends on the type of operations (like searching, inserting, or deleting) and performance needs.
For example, we may use different data structures for linear traversal, sorted traversal, or quick search.
Algorithms are step-by-step procedures that can be turned into programs to solve specific tasks.
These tasks include things like sorting and searching.
Algorithms use data structures to store and manage data efficiently.
๐ง Why I Shared This?
This detailed explanation helped me understand the real-world importance of choosing the right data structure and algorithm. It’s not just about writing code — it's about writing smart and efficient code.
๐งฉ Classification of Data Structures
Data Structures can be classified into two broad types: Primitive and Non-Primitive. Let's understand each with examples.
๐งฑ 1. Primitive Data Structures
These are the basic building blocks that are directly supported by most programming languages. They are simple and store a single value.
๐น Examples:
-
Integer – used to store whole numbers (e.g.,
int age = 21;
) -
Float / Double – used to store decimal numbers (e.g.,
float price = 99.99;
) -
Character – stores single characters (e.g.,
char grade = 'A';
) -
Boolean – stores truth values (
true
orfalse
)
➡️ Use case: Best for storing small, individual values in memory.
๐งฉ 2. Non-Primitive Data Structures
These are more complex and used to store multiple values. They are built using primitive types and are designed for specific tasks and performance needs.
Non-Primitive DS are further divided into two types:
➤ A. Linear Data Structures
In these structures, data is stored in a sequential manner. Traversing from one element to another follows a straight path.
๐งถ Examples:
-
Array – Fixed-size container for elements of the same type
-
Linked List – Elements (nodes) connected using pointers
-
Stack – Follows LIFO (Last In, First Out)
-
Queue – Follows FIFO (First In, First Out)
➡️ Use case: Ideal when order matters (e.g., task scheduling, browser history, etc.)
➤ B. Non-Linear Data Structures
Here, data elements are not stored in a sequential manner. These structures are used to represent hierarchical relationships or networks.
๐ฒ Examples:
-
Tree – A hierarchy where one item branches to multiple items (like file directories)
-
Graph – Items (nodes) are connected in a network (like Google Maps or social media)
➡️ Use case: Perfect for complex relationships and decision-making structures.
๐ Visual Representation
⚙️ Operations on Data Structures
Every data structure supports a variety of operations that allow us to manage and manipulate data. These operations help us insert, remove, search, and access data efficiently depending on the structure used.
Here’s a list of common operations performed on most data structures:
✅ 1. ➕Insertion
๐ธ Definition: Adding a new element to the data structure.
๐ Example: Inserting an element into an array or pushing a value onto a stack.
✅ 2. ➖Deletion
๐ธ Definition: Removing an existing element from the data structure.
๐ Example: Removing an item from a queue or deleting a node from a linked list.
✅ 3. ๐Traversal
๐ธ Definition: Visiting each element in the data structure, one by one.
๐ Example: Printing all elements in an array or traversing a tree.
✅ 4. ๐Searching
๐ธ Definition: Finding the location of an element in the data structure.
๐ Example: Searching for a number in a sorted array using Binary Search.
✅ 5. ๐Sorting
๐ธ Definition: Arranging data elements in a particular order (ascending or descending).
๐ Example: Sorting student marks using Bubble Sort or Quick Sort.
✅ 6. ✏️ Update
๐ธ Definition: Modifying the value of an existing element.
๐ Example: Updating the value of a node in a linked list.
Keep it up ๐ฏ
ReplyDelete