Chapter 7 Arrays 237 Outline 7.1 Introduction 7.2 (Professional web hosting)
Chapter 7 Arrays 237 Outline 7.1 Introduction 7.2 Arrays 7.3 Declaring and Allocating Arrays 7.4 Examples Using Arrays 7.4.1 Allocating an Array and Initializing Its Elements 7.4.2 Totaling the Elements of an Array 7.4.5 Using Arrays to Analyze Survey Results 7.4.3 Using Histograms to Display Array Data Graphically 7.4.4 Using the Elements of an Array as Counters 7.4.5 Using Arrays to Analyze Survey Results 7.5 Passing Arrays to Methods 7.6 Passing Arrays by Value and by Reference 7.7 Sorting Arrays 7.8 Searching Arrays: Linear Search and Binary Search 7.8.1 Searching an Array with Linear Search 7.8.2 Searching a Sorted Array with Binary Search 7.9 Multiple-Subscripted Arrays 7.10 foreach Repetition Structure Summary Terminology Self-Review Exercises Answers to Self-Review Exercises Exercises 7.1 Introduction This chapter serves as an introduction to data structures. Arrays are data structures consisting of data items of the same type. Arrays are static entities, in that they remain the same size once they are created. We begin by learning about creating and accessing arrays, then use this knowledge to begin more complex manipulations of arrays, including powerful searching and sorting techniques. We then demonstrate creating more sophisticated arrays that have multiple dimensions. Chapter 24, Data Structures, introduces dynamic data structures such as lists, queues, stacks and trees that can grow and shrink as programs execute. We also introduce C# s predefined data structures that enable the programmer to use existing data structures for lists, queues, stacks and trees, rather than having to reinvent the wheel. 7.2 Arrays An array is a group of contiguous memory locations that all have the same name and type. To refer to a particular location or element in the array, we specify the name of the array and the position number (a value that indicates a specific location within the array) of the element to which we refer. Figure 7.1 shows an integer array called c. This array contains 12 elements. A program can refer to any element of an array by giving the name of the array followed by the position
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.