Skip navigation.

CS 135 Programming Logic

Urn World Tutorial

Chapter 8: Arrays

At some point you will realize that we will run out of names for urns and stacks and queues if you are limited to names like U and V and S and T and Q and so on. There are only so many letters. You could start giving them names like Bob and Sue, but that gets tedious after a while. You could start numbering them, U1, U2, U3, ..., S1, S2, and so on. This is ok for a while, but suppose we have 1000 urns to name. If you are not convinced, then try declaring 1000 urns.

An array is a data structure that solves the naming/referencing problem. You will find arrays used just about everywhere in computer science and everywhere in computing in general.

  1. Creating an Array
  2. Array Example
  3. For-Loop
  4. For-loops and Arrays
  5. Searching an Array
  6. Searching: How Long?
  7. Sorting an Array
  8. Problems