📖 Chapters
- 1. Introduction to DSA and Its Importance
- 2. Time and Space Complexity (Big O, Θ, Ω)
- 3. Recursion and Stack Memory
- 4. Mathematics for DSA (GCD, LCM, Modulo Arithmetic)
- 5. Arrays: Basics and Operations
- 6. Strings: Manipulation & Inbuilt Functions
- 7. Structures and Unions with Arrays
- 8. Linked Lists (Singly, Circular, Doubly)
- 9. Stack (Using Array & Linked List)
- 10. Queue (Simple, Circular, Deque)
- 11. Linear Search & Binary Search
- 12. Sorting Basics: Bubble, Selection, Insertion
- 13. Merge Sort
- 14. Quick Sort
- 15. Counting Sort, Radix Sort, Bucket Sort
- 16. Heap Sort
- 17. Binary Trees & Representations
- 18. Binary Tree Traversals (Pre, In, Post)
- 19. Binary Search Tree (BST)
- 20. AVL Trees (Self-balancing BST)
- 21. Trie (Prefix Tree)
- 22. Segment Tree (Range Queries)
- 23. Fenwick Tree / Binary Indexed Tree (BIT)
- 24. Heap & Priority Queues (Min-Heap, Max-Heap)
- 25. Hashing and Hash Tables
- 26. Disjoint Set Union (Union-Find, Path Compression)
- 27. Sparse Tables
- 28. Sliding Window Technique
- 29. Two Pointers Technique
- 30. Graph Representations (Adjacency Matrix & List)
- 31. BFS and DFS (Traversal & Search)
- 32. Topological Sort (Kahn’s & DFS)
- 33. Shortest Path Algorithms (Dijkstra, Bellman-Ford)
- 34. Minimum Spanning Tree (Kruskal, Prim)
- 35. Cycle Detection in Graphs
- 36. Bridges and Articulation Points
- 37. Greedy Algorithms (Activity Selection, Huffman Coding)
- 38. Backtracking (N-Queens, Sudoku Solver)
- 39. Dynamic Programming (Intro, Memoization, Tabulation)
- 40. Advanced DP (LIS, Knapsack, DP on Trees/Grids)
- 41. Bit Manipulation and XOR Tricks
- 42. Interview Problems from FAANG Companies
- 43. Competitive Coding Patterns
- 44. Building Mini Projects Using DSA (Menu-driven)
- 45. Final Quiz + Problem Sheet (100+ questions)
- 46. Next Steps: Competitive Programming or System Design?
Data Structures and Algorithms in C (DSA)
Category: IT Fundamentals & Programming
This course is designed to help learners master the core concepts of Data Structures and Algorithms (DSA) using the C programming language. Starting from the basics and advancing to complex topics like graphs, dynamic programming, and memory optimization, this course …
Strings: Manipulation & Inbuilt Functions
📘 Strings – Manipulation & Inbuilt Functions
A string in C is a sequence of characters stored in an array of type char
, and it is terminated by a special character '\0'
(null character). Unlike other languages, strings in C are not a built-in data type — they are handled as arrays.
🔤 Declaring and Initializing Strings
char name[10]; // Declaration char greet[6] = {'H','e','l','l','o','\0'}; // Manual initialization char str[] = "Hello"; // Automatic null-termination
📥 Input and Output for Strings
// Using scanf and gets char name[50]; scanf("%s", name); // Stops at space // gets(name); // (Unsafe: use fgets instead) // Using fgets fgets(name, sizeof(name), stdin); // Safe input
📌 Common String Functions (string.h)
strlen(str)
– Returns the length of the stringstrcpy(dest, src)
– Copies one string into anotherstrcat(dest, src)
– Concatenates two stringsstrcmp(str1, str2)
– Compares two strings (returns 0 if equal)strchr(str, ch)
– Returns pointer to first occurrence ofch
strstr(haystack, needle)
– Returns pointer to substring
🧪 Example Program
#include <stdio.h> #include <string.h> int main() { char str1[20] = "Udaan"; char str2[20] = "Path"; strcat(str1, str2); // str1 becomes "UdaanPath" printf("Combined: %s\n", str1); return 0; }
📊 Real-Life Use Case – UdaanPath
Suppose you're storing user names in an educational app like UdaanPath. Each user’s name and email can be stored using strings and validated using strlen
, strcmp
, etc.
⚙️ Operations on Strings
- Traversing using loops
- Reversing a string
- Counting vowels, consonants, digits
- Palindrome check
- Character frequency
🧠 String vs Character Array
- A string always ends with '\0'
- Character arrays may not necessarily be null-terminated
- Use string.h functions only with null-terminated strings
📚 Practice Tasks
- Write a program to reverse a string
- Count the number of vowels and consonants
- Check if a string is a palindrome
- Compare two strings entered by user
✅ Summary
- Strings are arrays of characters ending with '\0'
- Use
string.h
for common operations like copy, compare, and length - Be cautious of buffer overflow and always allocate extra space for '\0'
📤 Coming Next
In the next chapter, we’ll explore Structures and Unions — composite data types used for storing grouped and flexible data in C.