How Do You Store All This Data?
How does data get stored?Copyright 2004 Microsoft Corporation, One Microsoft Way, Redmond, WA 98052-6399 USA. All rights reserved.
During this lesson, students start to see the data structure they will use to store their images, towards finding a solution to this unit's Grand Challenge. Students are introduced to two-dimensional arrays and vector classes. Then they are guided to see that a vector class is the most efficient way of storing the data for their images. Grand Challenge: To write a program to simulate peripheral vision by merging two images.
Data of all kinds is often stored in arrays to make it easier to work with on a large scale. Arrays are often used in computer programming as a way to store and manipulate data. An example of this data could be the pixels in a two-dimensional image, which is the focus of this lesson. Computer science engineers also know that arrays also make it easier to retrieve stored data.
After this lesson, students should be able to:
- Initialize a two-dimensional array.
- Initialize a new instance of a vector class.
- Store RGB values in a vector.
- Read data from vector and write to a new image.
- Apply new knowledge to the unit's Grand Challenge question.
Tennessee State Standards for C++ Programming Applications (2005)
- Standard 5.0 - The student will write and document an executable program in C++ Programming Language.
Use computers and calculators to access, retrieve, organize, process, maintain, interpret, and evaluate data and information in order to communicate.
Grades 9-12
Do you agree with this alignment?STEL-8N Use various approaches to communicate processes and procedures for using, maintaining, and assessing technological products and systems.
Grades 9-12
Do you agree with this alignment?
HS-ETS1-4 Use a computer simulation to model the impact of proposed solutions to a complex real-world problem with numerous criteria and constraints on interactions within and between systems relevant to the problem.
Grades 9-12
This resource focuses on the following Three Dimensional Learning aspects of NGSS:
Science & Engineering Practices- Use mathematical models and/or computer simulations to predict the effects of a design solution on systems and/or the interactions between systems.Do you agree with this alignment?
Disciplinary Core Ideas- Both physical models and computers can be used in various ways to aid in the engineering design process. Computers are useful for a variety of purposes, such as running simulations to test different ways of solving a problem or to see which one is most efficient or economical; and in making a persuasive presentation to a client about how a given design will meet his or her needs.Do you agree with this alignment?
Crosscutting Concepts- Models (e.g., physical, mathematical, computer models) can be used to simulate systems and interactions—including energy, matter, and information flows—within and between systems at different scales.Do you agree with this alignment?
Do you agree with this alignment?- Use mathematical models and/or computer simulations to predict the effects of a design solution on systems and/or the interactions between systems.
Lecture Information
- Two-dimensional arrays are used to store data. Each data point is identified by its horizontal and vertical position in the array. Think of the data as being stored in a grid.
- This address system is similar to the way points on a graph are addressed on an x-y plane, that is, the coordinate points (1, 2) would be one unit from the origin along the x-axis, and 2 units from the origin along the y-axis.
Figure 1. Example 4 x 3 array.
- Similarly, in an array, two subscripts are given, the first standing for the row number, the second representing the column number. By convention, rows and columns are both numbered from 0. Figure 1 shows an example 4 x 3 array and the subscripts representing each point within the array. (Note, the [a][b] notation is unique to C, most other languages refer to the same address as [a,b]).
- The following website explains the use of arrays in computer programming in more detail and gives example coding: https://www.tutorialspoint.com/computer_programming/computer_programming_arrays.htm
Summary
- Two ways to pass a pointer to a two dimensional array: subscript notation and typecasting.
- Subscript notation requires that data type of the second subscript needs to match based on the function.
- Typecasting in the function call uses a pointer with offsets inside the function so that information in arrays of differing dimensions can be processed using the same function.
- A vector template class allows for a dynamic array, which can be expanded to account for input of different amounts of information.
In this lesson, you will learn how a computer image is composed. You will need to understand that a digital image is nothing more than a grid of colors. The grid can easily be stored and manipulated by using nested loops. Following the lesson, students can complete the associated activity Putting It All Together: Programming Robotics Peripheral Vision.
- array
- A block of related data elements, each of which is identified by one or more subscripts.
- subscript
- Coordinate giving location in a single dimension in an array. Two subscripts together create an address of an element in a two-dimensional array.
As homework, have students complete the Data Storage Assignment Handout (PDF), which asks them to read data from a 16 x 16 image grid and store the data in an array. Then they are challenged to see if they can flip the image around by using nested loops. Assess their learning by their completion of the 16 x16 grid manipulation code and answers to the handout questions. Then proceed to conduct the associated activity, Putting It All Together: Programming Robotics Peripheral Vision.
"Array." Dictonary.com. Unabridged. Random House, Inc. Accessed 22 Jun. 2010. http://dictionary.reference.com/browse/Array
Contributors
Mark Gonyea; Anna Goncharova; Rachelle Klinger
Supporting Program
VU Bioengineering RET Program, School of Engineering, Vanderbilt University
Acknowledgements
The contents of this digital library curriculum were developed under National Science Foundation RET grant nos. 0338092 and 0742871. However, these contents do not necessarily represent the policies of the NSF, and you should not assume endorsement by the federal government.
Copyright
2013 by Regents of the University of Colorado; original © 2010 Vanderbilt University
