Preview

It 210

Powerful Essays
Open Document
Open Document
2960 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
It 210
Arrays: Lists and Tables
Although the value of a variable may change during execution of a program, in all our programs so far, a single value has been associated with each variable name at any given time. In this chapter, we will discuss the concept of an array—a collection of variables of the same type and referenced by the same name. We will discuss one-dimensional arrays (lists) at length and focus briefly on twodimensional arrays (tables). You will learn how to set up and use arrays to accomplish various tasks.
After reading this chapter, you will be able to do the following: Declare and use one-dimensional arrays [Section 6.1] Manipulate parallel arrays [Section 6.1] Use the serial search technique to search an array for a specified element [Section 6.2] Use the bubble sort technique to sort an array into a specified order [Section 6.2] Use the binary search procedure for locating an item in an array [Section 6.3] Use the selection sort procedure for sorting an array [Section 6.3] Represent character strings as arrays [Section 6.4] Declare and use two-dimensional arrays [Section 6.5]

6

ISBN 1-256-14455-X

285
Prelude to Programming: Concepts and Design, Fifth Edition, by Stewart Venit and Elizabeth Drake. Published by Addison-Wesley. Copyright © 2011 by Pearson Education, Inc.

286

Chapter 6

Arrays: Lists and Tables

In the Everyday World

Arrays
Chances are that you frequently use lists in your daily life. The following is a common example:

Shopping List
1. 2. 3. 4.

Milk Bread Eggs Butter

Or if you’ve ever done a home improvement project, you might have developed a list such as the following:

Tools Required List
1. Hammer 2. Saw 3. Screwdriver

If you write individual items on separate random pieces of paper, you might get them confused, and end up going to the grocery store for a saw. By presenting a convenient method of organizing and separating your data, a list prevents this from happening. Sometimes a single list

You May Also Find These Documents Helpful

  • Satisfactory Essays

    6. This type of list is displayed with “bullets” in front of each item: unordered…

    • 335 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Arrays store items that have the same type of data type like a group of employees’ names and social security numbers for a team of 2000 personal. Pointer is a variable that greatly extends the power and flexibility of a program, each memory location that is used to store data value has an address. The address provides the means for a PC hardware to reference a particular data item.…

    • 485 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Venit, S., & Drake, E. (2011). Prelude to Programming Concepts and Design (5th ed.). Boston, MA: Addison-Wesley.…

    • 1800 Words
    • 6 Pages
    Better Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    To build an array for Berry’s Bug Blasters the variable must be decided in this case this author knows that the company wants the name from the cuostuomer and the telephone where they are requesting service. Now that the variables are decided the process of building the array can begin. An array must have an Upper Bound. This simply means a limit for the number of times that the loop will run before the program ends. Without this set limit the program would become an infinite loop. Having an infinite loop could likely cause the program to crash in some cases, but it is the opinion of this writer that all that would happen in the case of this program would just mean that the user would be continuously entering data in the way of names and phone numbers with no end to the program. This also…

    • 833 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26 Chapter 27 An Introduction to Hardware, Software, and the Internet An Introduction to Software Development Objects and Classes Algorithms Java Syntax and Style Data Types, Variables, and Arithmetic Boolean Expressions and if-else Statements Iterative Statements: while, for, do–while Implementing Classes and Using Objects Strings Class Hierarchies and Interfaces Arrays…

    • 3908 Words
    • 16 Pages
    Powerful Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    C++ programming: editing, compiling, user I/O, variables (ints, doubles, char, strings, booleans), loops, decisions, functions, pointers, arrays, tables, databases, sorting.…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Chapter 8 Quiz

    • 469 Words
    • 2 Pages

    6. ________________ arrays are two or more arrays that hold related data, and the elements are accessed using a common subscript. (Points : 7)…

    • 469 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    cmis 102 HW 2

    • 748 Words
    • 6 Pages

    In this program, I will be using various variables with different definitions. The table below will list and identify the variables:…

    • 748 Words
    • 6 Pages
    Satisfactory Essays
  • Satisfactory Essays

    it 210

    • 385 Words
    • 2 Pages

    Explain some of the graphical user interfaces (GUIs) and communications messages that occur during the operation of a microwave.…

    • 385 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    7 and Array

    • 500 Words
    • 2 Pages

    7. When a single array element, such as myArray[2], is passed to a method, the method receives _____.…

    • 500 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Lab 3 Student

    • 1264 Words
    • 7 Pages

    This lab accompanies Chapter 2 (pp. 56-68) of Starting Out with Programming Logic & Design.…

    • 1264 Words
    • 7 Pages
    Satisfactory Essays
  • Satisfactory Essays

    IT 236

    • 2926 Words
    • 12 Pages

    The Final Project is a Web Site analysis. You will select an e-business or e-commerce Web site to respond to the Capstone Discussion Question, The Final Project consists of your recommendations on how to improve the site.…

    • 2926 Words
    • 12 Pages
    Satisfactory Essays
  • Good Essays

    Arrays “provide the programmer with a way of organising a collection of homogeneous data items (that is, items that have the same type and the same length) into a single data structure. An array, then, is a data structure that is made up of a number of variables all of which have the same data type” (Robertson, 2007). For example, there are 40 students in the first grade. A single variable name such as ‘first’ can be used with all 40 first grade students. “The individual data items that make up the array are referred to as the elements of the array. Elements in the array are distinguished from one another by the use of an index or subscript, enclosed in parentheses, following the array name” (Robertson, 2007), such as ‘first (8)’. This subscript refers to the eighth student in the first grade. The smallest element of an array must also be the size of the largest element, so in using the months of the year as an example, the names of the shorter months must be padded with blank spaces. The month of May must be as long as the month of September.…

    • 748 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    mr shravan

    • 881 Words
    • 4 Pages

    parallel arrays (or arrayLists). If there are any uses of an array of records or structures/objects,…

    • 881 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Columnar Transportation

    • 252 Words
    • 2 Pages

    * The columnar transposition technique of encryption is easy to understand and implement but still complex to break by brutal force attack or cryptanalysis.…

    • 252 Words
    • 2 Pages
    Satisfactory Essays