AI Horizon: Intelligence and Reason in Computers
Introduction Home Essays Resources Contact Info
Essays
  Basic CS
General AI
Chess AI
Go AI

Resources
  Source Code
AI Tips and Tricks
Books
Links

Other
  Code Journal
Site Updates

An Affiliate of Cprogramming.com
 

Lists and Arrays: Introduction
(Up to Basic Computer Science)

Lists and Array are the most basic types of data structures. They allow the programmer to organize data into more sophisticated patterns than the simple variables would allow. Almost all programming languages are built-in with at least a simple implementation of one or both of these, and the essays below deal with expanding on these basic forms.

A list is just a grouping of data. Think of a shopping list for groceries. It is simply a list of things to buy, but the list is ordered, which means that the list (Bread, Apples) is not the same list as (Apples, Bread).

An array is a kind of a list in which each object in an array is assigned a specific number, called its index number, and those numbers are used to locate and organize the objects. Thus, an array of some famous poets might look like this:

Index Poet's Name
0 W. H. Auden
1 T. S. Eliot
2 John Keats
3 e e cummings
4 Robert Frost

Note: The array here starts with 0 as the first index number. Theoretically, an array can start with any index number, but because of the structure of computer memory, it is customary, and preferable, to begin with 0 as the first index number.

Often, the elements of an array are sorted to speed up searches through an array. This topic has been studied very thouroughly over the years, and thus many algorithms to sort arrays have been created.

Although arrays are the most common lists, there are other types of lists as well. Two of the simplest and most useful are the stack and the queue, both of which are used heavily in operating systems and AI.

One very useful and versatile structure is the linked list. The linked list is, unlike the array, a dynamic structure, which means that it can resize itself when necessary.

All content is written and published by the people at or affiliated with AI Horizon <http://www.aihorizon.com/>.
Send any comments and suggestions to [email protected].

Please report any errors to [email protected].