Tino APCS

Arrays and algorithms

In the following list, we introduce five important algorithms that are quite common in programs that analyze data in arrays. You will meet these again in later lessons and labs.

Insertion is a standard problem that must be solved for all data structures. Suppose an array had 10 values and an 11th value was to be added. We are assuming the array can store at least 11 values.

  1. If we could place the new value at the end, there would be no problem.

  2. But if the new value must be inserted at the beginning of the list in position 0, the other 10 values must be moved one cell over in the list.

Deletion of a value creates an empty cell that probably must be dealt with. The most likely solution, after deleting a value, is to move all values that are to the right of the empty spot one cell to the left.

A traversal of an array consists of visiting every cell location, probably in order. The visit could involve printing out the array, initializing the array, finding the largest or smallest value in the array, etc.

Sorting an array means to organize values in either ascending or descending order. These algorithms will be covered in depth in future lessons.

Searching an array means to find a specific value in the array. There are several standard algorithms for searching an array. These will be covered in future lessons.

Dark Mode

Outline