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
Copy file name to clipboardExpand all lines: README.md
+15-42Lines changed: 15 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,13 @@ Also consult [Visualgo] for visualizing data structures and algorithms through a
76
76
77
77
[^2]: 25 problems / year, but it runs from 2015 up to now. The goal is to solve all the problems.
78
78
79
+
If you're into reading very technical documents —hardcore mode— you can check out the [Python docs], [C C23] Language Standard, and [CUDA] Programming Guide, or [CUDA Best Practices]. These resources are more advanced, but they're excellent for learning about the languages in depth, reimplementing some of the functions, and becoming very familiar with the core concepts from the very source.
@@ -112,57 +119,23 @@ Also consult [Visualgo] for visualizing data structures and algorithms through a
112
119
113
120
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.
[Grokking Data Structures]: https://annas-archive.org/md5/8116130f95c8cfc0c010a5be29c75cf2
124
+
115
125
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
126
117
127
### Arrays
118
128
119
129
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
130
121
-
**Static Array in C:**
131
+
[DynamicArray class (lines 10-17)](/data_structures/arrays/dynamic.py#L10-L17)
122
132
123
-
```c
124
-
#include<stdio.h>
133
+
Use Case: Static arrays are ideal when memory is constrained and the maximum size is known in advance, such as embedded systems or when implementing fixed-size buffers. The size limitation provides safety against buffer overflows.
125
134
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.
139
-
140
-
**Dynamic Array in Python:**
141
-
142
-
```python
143
-
arr = [1, 2, 3, 4, 5]
144
-
print(arr)
145
-
arr.append(6)
146
-
print(arr)
147
-
```
135
+
Use Case: Dynamic arrays are ideal when the size of the data is unknown or changes frequently. This implementation shows how Python lists work under the hood, automatically resizing when capacity is reached.
Binary search is a divide-and-conquer algorithm with O(log n) complexity that finds elements in sorted arrays by repeatedly halving the search interval. It's a fast and efficient way to search for elements in large datasets, first or last occurrence, or even the closest element to a target value.
0 commit comments