๐ Roadmap to Master C++ in 50 Days! ๐ป๐ง
๐ Week 1โ2: Basics Syntax
๐น Day 1โ5: C++ setup, input/output, variables, data types
๐น Day 6โ10: Operators, conditionals (if/else), loops (for, while)
๐ Week 3โ4: Functions Arrays
๐น Day 11โ15: Functions, scope, pass by value/reference
๐น Day 16โ20: Arrays, strings, 2D arrays, basic problems
๐ Week 5โ6: OOP STL
๐น Day 21โ25: Classes, objects, constructors, inheritance
๐น Day 26โ30: Polymorphism, encapsulation, abstraction
๐น Day 31โ35: Standard Template Library (vector, stack, queue, map)
๐ Week 7โ8: Advanced Concepts
๐น Day 36โ40: Pointers, dynamic memory, references
๐น Day 41โ45: File handling, exception handling
๐ฏ Final Stretch: DSA Projects
๐น Day 46โ48: Sorting, searching, recursion, linked lists
๐น Day 49โ50: Mini projects like calculator, student DB, or simple game
๐ฌ Tap โค๏ธ for more!
๐ Week 1โ2: Basics Syntax
๐น Day 1โ5: C++ setup, input/output, variables, data types
๐น Day 6โ10: Operators, conditionals (if/else), loops (for, while)
๐ Week 3โ4: Functions Arrays
๐น Day 11โ15: Functions, scope, pass by value/reference
๐น Day 16โ20: Arrays, strings, 2D arrays, basic problems
๐ Week 5โ6: OOP STL
๐น Day 21โ25: Classes, objects, constructors, inheritance
๐น Day 26โ30: Polymorphism, encapsulation, abstraction
๐น Day 31โ35: Standard Template Library (vector, stack, queue, map)
๐ Week 7โ8: Advanced Concepts
๐น Day 36โ40: Pointers, dynamic memory, references
๐น Day 41โ45: File handling, exception handling
๐ฏ Final Stretch: DSA Projects
๐น Day 46โ48: Sorting, searching, recursion, linked lists
๐น Day 49โ50: Mini projects like calculator, student DB, or simple game
๐ฌ Tap โค๏ธ for more!
โค9๐2
๐๐ฅ๐๐ ๐ข๐ป๐น๐ถ๐ป๐ฒ ๐ ๐ฎ๐๐๐ฒ๐ฟ๐ฐ๐น๐ฎ๐๐ ๐๐ ๐๐ป๐ฑ๐๐๐๐ฟ๐ ๐๐
๐ฝ๐ฒ๐ฟ๐๐ ๐
Roadmap to land your dream job in top product-based companies
๐๐ถ๐ด๐ต๐น๐ถ๐ด๐ต๐๐ฒ๐:-
- 90-Day Placement Plan
- Tech & Non-Tech Career Path
- Interview Preparation Tips
- Live Q&A
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/3Ltb3CE
Date & Time:- 06th January 2026 , 7PM
Roadmap to land your dream job in top product-based companies
๐๐ถ๐ด๐ต๐น๐ถ๐ด๐ต๐๐ฒ๐:-
- 90-Day Placement Plan
- Tech & Non-Tech Career Path
- Interview Preparation Tips
- Live Q&A
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/3Ltb3CE
Date & Time:- 06th January 2026 , 7PM
โค1
๐ 40 NumPy methods that cover 95% of tasks
A convenient cheat sheet for those who work with data analysis and ML.
Here are collected the main functions for:
Save it for yourself โ it will come in handy when working with NumPy.
A convenient cheat sheet for those who work with data analysis and ML.
Here are collected the main functions for:
โถ๏ธ Creating and modifying arrays;
โถ๏ธ Mathematical operations;
โถ๏ธ Working with matrices and vectors;
โถ๏ธ Sorting and searching for values.
Save it for yourself โ it will come in handy when working with NumPy.
โค3
๐ง๐ผ๐ฝ ๐ฑ ๐๐ป-๐๐ฒ๐บ๐ฎ๐ป๐ฑ ๐ฆ๐ธ๐ถ๐น๐น๐ ๐๐ผ ๐๐ผ๐ฐ๐๐ ๐ผ๐ป ๐ถ๐ป ๐ฎ๐ฌ๐ฎ๐ฒ๐
Start learning industry-relevant data skills today at zero cost!
๐๐ฎ๐๐ฎ ๐๐ป๐ฎ๐น๐๐๐ถ๐ฐ๐:- https://pdlink.in/497MMLw
๐๐ & ๐ ๐ :- https://pdlink.in/4bhetTu
๐๐น๐ผ๐๐ฑ ๐๐ผ๐บ๐ฝ๐๐๐ถ๐ป๐ด:- https://pdlink.in/3LoutZd
๐๐๐ฏ๐ฒ๐ฟ ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐:- https://pdlink.in/3N9VOyW
๐ข๐๐ต๐ฒ๐ฟ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐๐ฟ๐๐ฒ๐:- https://pdlink.in/4qgtrxU
๐ Enroll Now & Get Certified
Start learning industry-relevant data skills today at zero cost!
๐๐ฎ๐๐ฎ ๐๐ป๐ฎ๐น๐๐๐ถ๐ฐ๐:- https://pdlink.in/497MMLw
๐๐ & ๐ ๐ :- https://pdlink.in/4bhetTu
๐๐น๐ผ๐๐ฑ ๐๐ผ๐บ๐ฝ๐๐๐ถ๐ป๐ด:- https://pdlink.in/3LoutZd
๐๐๐ฏ๐ฒ๐ฟ ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐:- https://pdlink.in/3N9VOyW
๐ข๐๐ต๐ฒ๐ฟ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐๐ฟ๐๐ฒ๐:- https://pdlink.in/4qgtrxU
๐ Enroll Now & Get Certified
โ
DSA Roadmap: Part 1 โ Time & Space Complexity โฑ๏ธ๐
Understanding time and space complexity is crucial for writing efficient code. It helps you estimate how your algorithm will perform as input size grows.
1๏ธโฃ What is Time Complexity?
Time complexity tells us how fast an algorithm runs based on input size (n). It doesn't measure time in seconds โ it measures growth rate.
Example (Python):
Example (Java):
O(1) โ Constant (e.g., array access)
O(log n) โ Logarithmic (e.g., binary search)
O(n) โ Linear (e.g., single loop)
O(n log n) โ Efficient sorting (e.g., merge sort)
O(nยฒ) โ Quadratic (e.g., nested loops)
O(2โฟ), O(n!) โ Very slow (e.g., recursive brute force)
3๏ธโฃ What is Space Complexity?
It tells us how much extra memory your code uses depending on input size.
Example:
4๏ธโฃ Why It Matters
โข Handles large inputs without crashing
โข Crucial in coding interviews
โข Essential for scalable systems
5๏ธโฃ Practice Task โ Guess the Complexity
a) Nested loop
b) Binary search
c) Recursive Fibonacci
Takeaway:
Always analyze two things before solving any problem:
โ How many steps will this take? (Time)
โ How much memory does it use? (Space)
๐ฌ Tap โค๏ธ for more
Understanding time and space complexity is crucial for writing efficient code. It helps you estimate how your algorithm will perform as input size grows.
1๏ธโฃ What is Time Complexity?
Time complexity tells us how fast an algorithm runs based on input size (n). It doesn't measure time in seconds โ it measures growth rate.
Example (Python):
for i in range(n):Runs
print(i)
n times โ O(n) timeExample (Java):
for (int i = 0; i < n; i++) {
System.out.println(i);
}
Example (C++):for (int i = 0; i < n; i++) {
cout << i << endl;
}
2๏ธโฃ Common Time Complexities (Best to Worst): O(1) โ Constant (e.g., array access)
O(log n) โ Logarithmic (e.g., binary search)
O(n) โ Linear (e.g., single loop)
O(n log n) โ Efficient sorting (e.g., merge sort)
O(nยฒ) โ Quadratic (e.g., nested loops)
O(2โฟ), O(n!) โ Very slow (e.g., recursive brute force)
3๏ธโฃ What is Space Complexity?
It tells us how much extra memory your code uses depending on input size.
Example:
arr = [0] * n # O(n) spaceIf no extra structures are used โ O(1) space
4๏ธโฃ Why It Matters
โข Handles large inputs without crashing
โข Crucial in coding interviews
โข Essential for scalable systems
5๏ธโฃ Practice Task โ Guess the Complexity
a) Nested loop
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
System.out.println(i + ", " + j);
}
}
// O(nยฒ)b) Binary search
while (low <= high) {
int mid = (low + high) / 2;
if (arr[mid] == target) break;
}
// O(log n)c) Recursive Fibonacci
def fib(n):// O(2^n)
if n <= 1:
return n
return fib(n-1) + fib(n-2)
Takeaway:
Always analyze two things before solving any problem:
โ How many steps will this take? (Time)
โ How much memory does it use? (Space)
๐ฌ Tap โค๏ธ for more
โค6๐4
๐๐ฎ๐๐ฎ ๐ฆ๐ฐ๐ถ๐ฒ๐ป๐ฐ๐ฒ ๐ฎ๐ป๐ฑ ๐๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ถ๐ฎ๐น ๐๐ป๐๐ฒ๐น๐น๐ถ๐ด๐ฒ๐ป๐ฐ๐ฒ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ ๐ฏ๐ ๐๐๐ง ๐ฅ๐ผ๐ผ๐ฟ๐ธ๐ฒ๐ฒ๐
Deadline: 11th January 2026
Eligibility: Open to everyone
Duration: 6 Months
Program Mode: Online
Taught By: IIT Roorkee Professors
Companies majorly hire candidates having Data Science and Artificial Intelligence knowledge these days.
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐๐ถ๐ป๐ธ๐:
https://pdlink.in/4qNGMO6
Only Limited Seats Available!
Deadline: 11th January 2026
Eligibility: Open to everyone
Duration: 6 Months
Program Mode: Online
Taught By: IIT Roorkee Professors
Companies majorly hire candidates having Data Science and Artificial Intelligence knowledge these days.
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐๐ถ๐ป๐ธ๐:
https://pdlink.in/4qNGMO6
Only Limited Seats Available!
โ
DSA Part 2 โ Recursion ๐๐ง
Recursion is when a function calls itself to solve smaller subproblems. It's powerful but needs a base case to avoid infinite loops.
1๏ธโฃ What is Recursion?
A recursive function solves a part of the problem and calls itself on the remaining part.
Basic Python Example:
โถ๏ธ Counts down from n to 0
2๏ธโฃ Key Parts of Recursion:
โข Base case โ Stops recursion
โข Recursive case โ Function calls itself
Java Example โ Factorial:
C++ Example โ Sum of Array:
3๏ธโฃ Why Use Recursion?
โข Breaks complex problems into simpler ones
โข Great for trees, graphs, backtracking, divide conquer
4๏ธโฃ When Not to Use It?
โข Large inputs can cause stack overflow
โข Use loops if recursion is too deep or inefficient
5๏ธโฃ Practice Task:
โ Write a recursive function to calculate power (a^b)
โ Write a function to reverse a string recursively
โ Try basic Fibonacci using recursion
๐ Solution for Practice Task
โ 1. Recursive Power Function (a^b)
Python:
C++:
Java:
โ 2. Reverse String Recursively
Python:
C++:
Java:
โ 3. Fibonacci Using Recursion
Python:
C++:
Java:
*Double Tap โฅ๏ธ For More*
Recursion is when a function calls itself to solve smaller subproblems. It's powerful but needs a base case to avoid infinite loops.
1๏ธโฃ What is Recursion?
A recursive function solves a part of the problem and calls itself on the remaining part.
Basic Python Example:
def countdown(n):
if n == 0:
print("Done!")
return
print(n)
countdown(n - 1)
โถ๏ธ Counts down from n to 0
2๏ธโฃ Key Parts of Recursion:
โข Base case โ Stops recursion
โข Recursive case โ Function calls itself
Java Example โ Factorial:
int factorial(int n) {
if (n == 0) return 1;
return n * factorial(n - 1);
}
C++ Example โ Sum of Array:
int sum(int arr[], int n) {
if (n == 0) return 0;
return arr[n - 1] + sum(arr, n - 1);
}
3๏ธโฃ Why Use Recursion?
โข Breaks complex problems into simpler ones
โข Great for trees, graphs, backtracking, divide conquer
4๏ธโฃ When Not to Use It?
โข Large inputs can cause stack overflow
โข Use loops if recursion is too deep or inefficient
5๏ธโฃ Practice Task:
โ Write a recursive function to calculate power (a^b)
โ Write a function to reverse a string recursively
โ Try basic Fibonacci using recursion
๐ Solution for Practice Task
โ 1. Recursive Power Function (a^b)
Python:
def power(a, b):
if b == 0:
return 1
return a * power(a, b - 1)
print(power(2, 3)) # Output: 8
C++:
int power(int a, int b) {
if (b == 0) return 1;
return a * power(a, b - 1);
}
// Example: cout << power(2, 3); // Output: 8
Java:
int power(int a, int b) {
if (b == 0) return 1;
return a * power(a, b - 1);
}
// Example: System.out.println(power(2, 3)); // Output: 8
โ 2. Reverse String Recursively
Python:
def reverse(s):
if len(s) == 0:
return ""
return reverse(s[1:]) + s[0]
print(reverse("hello")) # Output: "olleh"
C++:
string reverse(string s) {
if (s.length() == 0) return "";
return reverse(s.substr(1)) + s[0];
}
// Example: cout << reverse("hello"); // Output: "olleh"
Java:
String reverse(String s) {
if (s.isEmpty()) return "";
return reverse(s.substring(1)) + s.charAt(0);
}
// Example: System.out.println(reverse("hello")); // Output: "olleh"
โ 3. Fibonacci Using Recursion
Python:
def fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
print(fib(6)) # Output: 8
C++:
int fib(int n) {
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}
// Example: cout << fib(6); // Output: 8
Java:
int fib(int n) {
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}
// Example: System.out.println(fib(6)); // Output: 8
*Double Tap โฅ๏ธ For More*
โค6๐1
โ
DSA Part 3 โ Arrays & Sliding Window ๐๐ง
Arrays are the foundation of data structures. Mastering them unlocks many advanced topics like sorting, searching, and dynamic programming.
1๏ธโฃ What is an Array?
An array is a collection of elements stored at contiguous memory locations. All elements are of the same data type.
Python Example:
โข Insert
โข Delete
โข Traverse
โข Search
โข Update
Python โ Traversal:
Used to reduce time complexity in problems involving subarrays or substrings.
โถ๏ธ Fixed-size window:
Find max sum of subarray of size k
โถ๏ธ Variable-size window:
Find longest substring with unique characters
4๏ธโฃ Sliding Window โ Max Sum Subarray (Size k)
Python:
โ Find the second largest element in an array
โ Implement sliding window to find max sum subarray
โ Try variable-size window: longest substring without repeating characters
๐ Solution for Practice Tasks
โ 1. Find the Second Largest Element in an Array
Python:
Python:
Python:
Arrays are the foundation of data structures. Mastering them unlocks many advanced topics like sorting, searching, and dynamic programming.
1๏ธโฃ What is an Array?
An array is a collection of elements stored at contiguous memory locations. All elements are of the same data type.
Python Example:
arr = [10, 20, 30, 40]C++ Example:
print(arr[2]) # Output: 30
int arr[] = {10, 20, 30, 40};
cout << arr[2]; // Output: 30
Java Example:int[] arr = {10, 20, 30, 40};
System.out.println(arr[2]); // Output: 30
2๏ธโฃ Basic Array Operations:โข Insert
โข Delete
โข Traverse
โข Search
โข Update
Python โ Traversal:
for i in arr:C++ โ Search:
print(i)
for (int i = 0; i < n; i++) {
if (arr[i] == key) {
// Found
}
}
Java โ Update:arr[1] = 99; // Updates second element3๏ธโฃ Sliding Window Technique ๐ช
Used to reduce time complexity in problems involving subarrays or substrings.
โถ๏ธ Fixed-size window:
Find max sum of subarray of size k
โถ๏ธ Variable-size window:
Find longest substring with unique characters
4๏ธโฃ Sliding Window โ Max Sum Subarray (Size k)
Python:
def max_sum(arr, k):5๏ธโฃ Practice Tasks:
window_sum = sum(arr[:k])
max_sum = window_sum
for i in range(k, len(arr)):
window_sum += arr[i] - arr[i - k]
max_sum = max(max_sum, window_sum)
return max_sum
print(max_sum([1, 4, 2, 10, 2, 3], 3)) # Output: 16
โ Find the second largest element in an array
โ Implement sliding window to find max sum subarray
โ Try variable-size window: longest substring without repeating characters
๐ Solution for Practice Tasks
โ 1. Find the Second Largest Element in an Array
Python:
def second_largest(arr):โ 2. Max Sum Subarray (Fixed-size Sliding Window)
first = second = float('-inf')
for num in arr:
if num > first:
second = first
first = num
elif first > num > second:
second = num
return second if second != float('-inf') else None
print(second_largest([10, 20, 4, 45, 99])) # Output: 45
Python:
def max_sum(arr, k):โ 3. Longest Substring Without Repeating Characters (Variable-size Sliding Window)
window_sum = sum(arr[:k])
max_sum = window_sum
for i in range(k, len(arr)):
window_sum += arr[i] - arr[i - k]
max_sum = max(max_sum, window_sum)
return max_sum
print(max_sum([1, 4, 2, 10, 2, 3, 1, 0, 20], 4)) # Output: 24
Python:
def longest_unique_substring(s):Double Tap โฅ๏ธ For Part-4
seen = {}
left = max_len = 0
for right in range(len(s)):
if s[right] in seen and seen[s[right]] >= left:
left = seen[s[right]] + 1
seen[s[right]] = right
max_len = max(max_len, right - left + 1)
return max_len
print(longest_unique_substring("abcabcbb")) # Output: 3 ("abc")
โค8
๐๐ฅ๐๐ ๐ข๐ป๐น๐ถ๐ป๐ฒ ๐ ๐ฎ๐๐๐ฒ๐ฟ๐ฐ๐น๐ฎ๐๐ ๐ข๐ป ๐๐ฎ๐๐ฒ๐๐ ๐ง๐ฒ๐ฐ๐ต๐ป๐ผ๐น๐ผ๐ด๐ถ๐ฒ๐๐
- Data Science
- AI/ML
- Data Analytics
- UI/UX
- Full-stack Development
Get Job-Ready Guidance in Your Tech Journey
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4sw5Ev8
Date :- 11th January 2026
- Data Science
- AI/ML
- Data Analytics
- UI/UX
- Full-stack Development
Get Job-Ready Guidance in Your Tech Journey
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4sw5Ev8
Date :- 11th January 2026
โ
DSA Part 4 โ Strings: Patterns, Hashing & Two Pointers ๐ค๐งฉโก
Strings are everywhereโfrom passwords to DNA sequences. Mastering string manipulation unlocks powerful algorithms in pattern matching, text processing, and optimization.
1๏ธโฃ What is a String?
A string is a sequence of characters. In most languages, strings are immutable and indexed like arrays.
Python Example:
โข Concatenation
โข Substring
โข Comparison
โข Reversal
โข Search
โข Replace
Python โ Reversal:
Naive Approach: Check every substring
Efficient: Use hashing or KMP (Knuth-Morris-Pratt)
Python โ Naive Pattern Search:
Use hash maps to store character counts, frequencies, or indices.
Python โ First Unique Character:
Used for problems like palindromes, anagrams, or substring windows.
Python โ Valid Palindrome:
โ Implement pattern search (naive)
โ Find first non-repeating character
โ Check if a string is a palindrome
โ Use two pointers to reverse vowels in a string
โ Try Rabin-Karp or KMP for pattern matching
๐ฌ Double Tap โค๏ธ for Part-5
Strings are everywhereโfrom passwords to DNA sequences. Mastering string manipulation unlocks powerful algorithms in pattern matching, text processing, and optimization.
1๏ธโฃ What is a String?
A string is a sequence of characters. In most languages, strings are immutable and indexed like arrays.
Python Example:
s = "hello"C++ Example:
print(s[1]) # Output: 'e'
string s = "hello";Java Example:
cout << s[1]; // Output: 'e'
String s = "hello";2๏ธโฃ Common String Operations:
System.out.println(s.charAt(1)); // Output: 'e'
โข Concatenation
โข Substring
โข Comparison
โข Reversal
โข Search
โข Replace
Python โ Reversal:
s = "hello"C++ โ Substring:
print(s[::-1]) # Output: 'olleh'
string s = "hello";Java โ Replace:
cout << s.substr(1, 3); // Output: 'ell'
String s = "hello";3๏ธโฃ Pattern Matching โ Naive vs Efficient
System.out.println(s.replace("l", "x")); // Output: 'hexxo'
Naive Approach: Check every substring
Efficient: Use hashing or KMP (Knuth-Morris-Pratt)
Python โ Naive Pattern Search:
def search(text, pattern):4๏ธโฃ Hashing for Fast Lookup
for i in range(len(text) - len(pattern) + 1):
if text[i:i+len(pattern)] == pattern:
print(f"Found at index {i}")
search("abracadabra", "abra") # Output: Found at index 0, 7
Use hash maps to store character counts, frequencies, or indices.
Python โ First Unique Character:
from collections import Counter5๏ธโฃ Two Pointers Technique
def first_unique_char(s):
count = Counter(s)
for i, ch in enumerate(s):
if count[ch] == 1:
return i
return -1
print(first_unique_char("leetcode")) # Output: 0
Used for problems like palindromes, anagrams, or substring windows.
Python โ Valid Palindrome:
def is_palindrome(s):6๏ธโฃ Practice Tasks:
s = ''.join(filter(str.isalnum, s)).lower()
left, right = 0, len(s) - 1
while left < right:
if s[left] != s[right]:
return False
left += 1
right -= 1
return True
print(is_palindrome("A man, a plan, a canal: Panama")) # Output: True
โ Implement pattern search (naive)
โ Find first non-repeating character
โ Check if a string is a palindrome
โ Use two pointers to reverse vowels in a string
โ Try Rabin-Karp or KMP for pattern matching
๐ฌ Double Tap โค๏ธ for Part-5
โค5
๐๐ถ๐ด๐ต ๐๐ฒ๐บ๐ฎ๐ป๐ฑ๐ถ๐ป๐ด ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐ช๐ถ๐๐ต ๐ฃ๐น๐ฎ๐ฐ๐ฒ๐บ๐ฒ๐ป๐ ๐๐๐๐ถ๐๐๐ฎ๐ป๐ฐ๐ฒ๐
Learn from IIT faculty and industry experts.
IIT Roorkee DS & AI Program :- https://pdlink.in/4qHVFkI
IIT Patna AI & ML :- https://pdlink.in/4pBNxkV
IIM Mumbai DM & Analytics :- https://pdlink.in/4jvuHdE
IIM Rohtak Product Management:- https://pdlink.in/4aMtk8i
IIT Roorkee Agentic Systems:- https://pdlink.in/4aTKgdc
Upskill in todayโs most in-demand tech domains and boost your career ๐
Learn from IIT faculty and industry experts.
IIT Roorkee DS & AI Program :- https://pdlink.in/4qHVFkI
IIT Patna AI & ML :- https://pdlink.in/4pBNxkV
IIM Mumbai DM & Analytics :- https://pdlink.in/4jvuHdE
IIM Rohtak Product Management:- https://pdlink.in/4aMtk8i
IIT Roorkee Agentic Systems:- https://pdlink.in/4aTKgdc
Upskill in todayโs most in-demand tech domains and boost your career ๐
โค1
โ
DSA Part 5 โ Linked Lists: Single, Double & Reverse ๐๐๐
Linked Lists are dynamic data structures ideal for scenarios requiring frequent insertions and deletions. Unlike arrays, they donโt need contiguous memory and offer flexible memory usage.
1๏ธโฃ What is a Linked List?
A Linked List is a linear data structure where each element (node) contains:
- Data
- Pointer to the next node (and optionally the previous node)
Types:
- Singly Linked List: Each node points to the next
- Doubly Linked List: Nodes point to both next and previous
- Circular Linked List: Last node points back to the head
2๏ธโฃ Singly Linked List โ Basic Structure
Python
Java
C++
3๏ธโฃ Insert at Head (Singly)
Python
Java
C++
4๏ธโฃ Doubly Linked List โ Bi-directional Pointers
Python
Java
C++
5๏ธโฃ Insert at Head (Doubly)
Python
Java
C++
6๏ธโฃ Reversing a Singly Linked List
Python
Java
C++
7๏ธโฃ Why Use Linked Lists?
โ Dynamic memory allocation
โ Efficient insert/delete (O(1) at head/tail)
โ Slower access (O(n) for random access)
โ Great for implementing stacks, queues, hash maps, etc.
8๏ธโฃ Practice Tasks
โ Implement singly linked list with insert/delete
โ Implement doubly linked list with insert at tail
โ Reverse a singly linked list
Linked Lists are dynamic data structures ideal for scenarios requiring frequent insertions and deletions. Unlike arrays, they donโt need contiguous memory and offer flexible memory usage.
1๏ธโฃ What is a Linked List?
A Linked List is a linear data structure where each element (node) contains:
- Data
- Pointer to the next node (and optionally the previous node)
Types:
- Singly Linked List: Each node points to the next
- Doubly Linked List: Nodes point to both next and previous
- Circular Linked List: Last node points back to the head
2๏ธโฃ Singly Linked List โ Basic Structure
Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
Java
class Node {
int data;
Node next;
Node(int data) {
this.data = data;
this.next = null;
}
}
C++
struct Node {
int data;
Node* next;
Node(int data): data(data), next(nullptr) {}
};
3๏ธโฃ Insert at Head (Singly)
Python
def insert_head(head, data):
new_node = Node(data)
new_node.next = head
return new_node
Java
Node insertHead(Node head, int data) {
Node newNode = new Node(data);
newNode.next = head;
return newNode;
}
C++
Node* insertHead(Node* head, int data) {
Node* newNode = new Node(data);
newNode->next = head;
return newNode;
}
4๏ธโฃ Doubly Linked List โ Bi-directional Pointers
Python
class DNode:
def __init__(self, data):
self.data = data
self.prev = None
self.next = None
Java
class DNode {
int data;
DNode prev, next;
DNode(int data) {
this.data = data;
}
}
C++
struct DNode {
int data;
DNode* prev;
DNode* next;
DNode(int data): data(data), prev(nullptr), next(nullptr) {}
};
5๏ธโฃ Insert at Head (Doubly)
Python
def insert_head(head, data):
new_node = DNode(data)
new_node.next = head
if head:
head.prev = new_node
return new_node
Java
DNode insertHead(DNode head, int data) {
DNode newNode = new DNode(data);
newNode.next = head;
if (head != null) head.prev = newNode;
return newNode;
}
C++
DNode* insertHead(DNode* head, int data) {
DNode* newNode = new DNode(data);
newNode->next = head;
if (head) head->prev = newNode;
return newNode;
}
6๏ธโฃ Reversing a Singly Linked List
Python
def reverse_list(head):
prev = None
current = head
while current:
next_node = current.next
current.next = prev
prev = current
current = next_node
return prev
Java
Node reverseList(Node head) {
Node prev = null, current = head;
while (current != null) {
Node next = current.next;
current.next = prev;
prev = current;
current = next;
}
return prev;
}
C++
Node* reverseList(Node* head) {
Node* prev = nullptr;
Node* current = head;
while (current) {
Node* next = current->next;
current->next = prev;
prev = current;
current = next;
}
return prev;
}
7๏ธโฃ Why Use Linked Lists?
โ Dynamic memory allocation
โ Efficient insert/delete (O(1) at head/tail)
โ Slower access (O(n) for random access)
โ Great for implementing stacks, queues, hash maps, etc.
8๏ธโฃ Practice Tasks
โ Implement singly linked list with insert/delete
โ Implement doubly linked list with insert at tail
โ Reverse a singly linked list
โค2