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