Array
An Array is an ordered collection of elements
What is an Array? π₯ π₯ π₯
An Array is an ordered collection of elements.
A Row of Mailboxesπͺπͺπͺ
To access, obtain, add, or remove mail (an item) from the row of mailboxes (array), the only information needed is the number to the mailbox.
1 dimensional π , 2 dimensional π , 3 dimensional π
An array can be 1D, 2D, 3D, and beyond.
1D Array
a row of mailboxes (left/right)
πͺπͺπͺ
2D Array
Multiple rows of mailboxes (left/right & up/down)
πͺπͺπͺ
πͺπͺπͺ
πͺπͺπͺ
3D Array
multiple columns of multiple rows of multiple mailboxes (left/right & up/down & forward/backward)
πͺπͺ πͺπͺ πͺπͺ
πͺπͺ πͺπͺ πͺπͺ
Stacks and Queuesπ π
Stacks and queues are examples of 1D arrays.
Stacks π₯π‘π
The stack is exactly as it sounds, items stacked on top of each other. Adding and removing items always occur with top of the stack.
The vertical array utilizes the L.I.F.O. (Last In First Out) principal, which is the last item to go in the stack is the first item to get out of the stack.
Removal -> top of the stack
Adding -> top of the stack
Example: pringles, dishes, zen rock stacking
Queues π πΆ πΆββοΈ πΆββοΈ
The Queue is the same as a line. Adding items occurs at the beginning of the queue and removing items occurs at the end of the queue.
The horizontal array uses the F.I.F.O. principal (First In First Out) which is the first person to get in line is the first person to get out of the line, F.I.F.O.
Removal -> The end of an array
Adding -> the beginning of the array
Example: a line for fast food, a line for a new Iphone, a line at Disneyland
Last updated