You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Personally, what I did was to start brushing up on the basics of data structures and algorithms through easy reading [Grokking Algorithms] and [Grokking Data Structures]. Both are pretty updated books from last year, and I just wanted to get a bit more familiar with the ideas.
114
+
115
+
Arrays seems like the most fundamental data structure, so the first thing you should be able to do it's to work with that.
116
+
117
+
### Arrays
118
+
119
+
There are two types of arrays: static and dynamic. Static arrays have a fixed size, which means the size must be defined at compile time and cannot be changed during runtime. Dynamic arrays, on the other hand, can grow and shrink in size as needed during program execution. Understanding the difference between these two types is crucial for efficient memory management and performance optimization.
120
+
121
+
**Static Array in C:**
122
+
123
+
```c
124
+
#include<stdio.h>
125
+
126
+
intmain() {
127
+
int arr[5] = {1, 2, 3, 4, 5};
128
+
int i = 0;
129
+
while (i < 5) {
130
+
printf("%d ", arr[i]);
131
+
i++;
132
+
}
133
+
printf("\n");
134
+
return 0;
135
+
}
136
+
```
137
+
138
+
Use Case: Static arrays are suitable when the number of elements is known in advance and does not change, such as storing the days of the week.
0 commit comments