Array Operations
We're not just repeating definitions here. You'll see, visually, how an array is traversed, how a value is searched for, and how a new element is inserted by moving positions. The idea is for you to understand WHAT the program does and WHY it does it.
It's always the same array. What changes is the operation we perform on it.
The index variable tells us which position we are working with.
Almost all operations start by traversing from the beginning toward the end.
1. Traversing an Array
Traversing means visiting all elements one by one. It is the base operation: without traversal you cannot display, sum, compare, or search.
2. Searching for a Value in the Array
Searching means comparing the searched value with each element of the array until a match is found or until the traversal ends.
3. Inserting a Value in the Middle
Inserting is not simply "putting a value". If the position is already occupied, elements must first be shifted to the right to make room.
4. Key Takeaways
It's going through each position using an index. Without that, there's no real array processing.
It's comparing one by one until you find the data or finish the traversal.
It's making room and only then saving the new value.