๐ฏ Goal:
-
Understand arrays in C.
-
Learn how to use loops with arrays.
-
Implement Linear Search algorithm.
-
Practice multiple array-based programs.
๐ง Theory: What is an Array?
-
An array is a collection of elements stored in contiguous memory.
-
All elements must be of the same type.
-
Indexing starts from 0 in C.
๐ง Declaration and Initialization
๐จ๐ป Basic Program: Input & Output in Arrays
๐ Linear Search in C
➕ Problem: Given an array and a number x
, find if x
exists in the array.
✅ Code:
๐ง Time Complexity:
-
Best case: O(1)
-
Worst case: O(n)
๐งช Practice Problems:
-
Find the maximum and minimum element in an array.
-
Count how many times a given number appears in the array.
-
Reverse an array.
๐ Homework for Day 2:
-
Write a program to copy one array to another.
-
Write a program to merge two arrays.
-
Try solving one problem from LeetCode Easy using arrays (optional but forward-thinking!).
๐ Day 2 Summary
-
✅ Learned arrays
-
✅ Implemented Linear Search
-
✅ Practiced I/O and traversal
๐งญ Tomorrow: Sorting (Bubble Sort) + Binary Search
Would you like me to create a GitHub repo or planner to track your DSA progress daily?
Comments
Post a Comment