Alice chap 8 - 8 Chapter C5777 36525 1/9/06 5:16 PM Page...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
After finishing this chapter, you should be able to: o Provide brief definitions of the following terms: array, Array Visualization Object, binary tree, data structure, index value, iterate a list, list, matrix, node, queue, root node, and vector o Describe what a data structure is, and give several examples of data structures o Generally describe why there are so many different data structures, and how program- mers decide what data structures to use for different programs o Describe the simple data structure known as a list, and how it is implemented in Alice o Describe the data structure known as an array, how it differs from a list, and how it is implemented in Alice o Create a list of objects in an Alice world and methods that perform operations on the list items one at a time and all at once o Create methods in Alice that can manipulate the parts of objects contained in a list o Describe the purpose of the Array Visualization Object in Alice LISTS AND ARRAYS IN ALICE 211 8 8 Chapter C5777 36525 1/9/06 5:16 PM Page 211
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
212 Chapter 8 • Lists and Arrays in Alice DATA STRUCTURES IN ALICE A data structure is a scheme for organizing data in the memory of a computer. A set of names, addresses, and phone numbers stored as a table of data is an example of a data structure. Some of the more commonly used data structures include lists, arrays, stacks, queues, heaps, trees, and graphs. They can be simple, or they can become quite complex. THE NEED FOR DIFFERENT DATA STRUCTURES Computer programmers decide which data structures to use based on the nature of the data and the operations that need to be performed on that data because the way in which the data is organized affects the performance of a program for different tasks. As an example of this, let’s take a look at two data structures, a queue and a binary tree, and see how the dif- ferences between the two affect how computer programmers use them. A queue is a set of data items with a beginning and end, called the front and back of the queue. Data enters the queue at one end and leaves at the other. Because of this, data exits the queue in the same order in which it entered the queue, like people in a checkout line at a supermarket. A queue has many uses in the world of computers—it would, for example, be a good data structure to use in a program for keeping track of documents waiting to be printed on a network printer, as shown in Figure 8-1. A binary tree is a data structure that looks like an upside down tree. Each spot on the tree, called a node , holds an item of data, along with a left pointer and a right pointer, as shown in Figure 8-2. The pointers are lined up so that the structure forms the upside down tree, with a single node at the top, called the root node , and branches increasing on the left and right as you go down the tree. The nodes at the bottom of each branch, with two empty pointers, are called the leaf nodes .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/17/2011 for the course CIS 106 taught by Professor Alice during the Spring '11 term at Community College of Philadelphia.

Page1 / 34

Alice chap 8 - 8 Chapter C5777 36525 1/9/06 5:16 PM Page...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online