UTPA STEM/CBI Courses/Computer Science/Arrays

Course Title: Computer Science I

Lecture Topic: Arrays

Instructor: Christine Reilly

Institution: University of Texas - Pan American

Backwards Design
Course Objectives


 * Primary Objectives- By the next class period students will be able to:
 * Identify cases where arrays are useful
 * Write C++ code to create an array
 * Write C++ code to access an array element


 * Sub Objectives- The objectives will require that students be able to:
 * Understand how array elements are indexed
 * Have a good understanding of basic C++ programming


 * Difficulties- Students may have difficulty:
 * Understanding how one variable can hold multiple values
 * Remembering the correct syntax for accessing elements of an array


 * Real-World Contexts- There are many ways that students can use this material in the real-world, such as:
 * Games that use a series of data. Any game that uses a hand of cards or a series of dice. Board games such as checkers, chess, and Connect-Four can be represented using a two dimensional array.
 * Data management systems can be represented using arrays. Examples are the contents of a shopping cart and information about the employees of a company.

Model of Knowledge


 * Concept Map
 * Analysis of problem, requires
 * Critical thinking skills
 * Summarizing skills
 * Design of solution (algorithm design), requires
 * Problem decomposition skills
 * Understanding of underlying programming concepts
 * Data types
 * Sequence
 * Control structures
 * Modular programming
 * Arrays -- this lesson
 * Abstract data types
 * Pointers
 * Data structures and algorithms
 * Use of design tools - pseudo code writing skills
 * Implementation of solution - tools of the trade
 * Learned in lectures through
 * Slides
 * Analogies
 * Simple programs
 * Group exercises
 * Using C++ to implement underlying concepts
 * Applying underlying concepts, covered in lectures using
 * In-class exercises
 * Lab assignments
 * Homework assignments


 * Content Priorities
 * Enduring Understanding
 * Create an array
 * Initialize the array
 * Retrieve the value of a single element of the array
 * Important to Do and Know
 * How to iterate through an array
 * Change the value of an array element
 * Worth Being Familiar with
 * How to use a programming environment such as Visual C++

Assessment of Learning


 * Formative Assessment
 * In Class (groups)
 * Working in groups to brainstorm an algorithm and write short segments of code to solve a small problem
 * Working in groups to trace a code fragment and determine the output of that code fragment
 * Homework (individual)
 * Programming project where the students use arrays to solve a given problem
 * Worksheet on basic array creation, initialization, and element access
 * Summative Assessment
 * Exam
 * Code trace problems
 * Writing short fragments of code

Legacy Cycle
OBJECTIVE

By the next class period, students will be able to: The objectives will require that students be able to: THE CHALLENGE
 * Write C++ code to create and initialize arrays of any size
 * Write C++ code to access an element within an array
 * Write C++ code to iterate through an array
 * Understand basic C++ programming
 * Understand how arrays are indexed

 You are the programmer for MicroAir Airline. Every MicroAir airplane has 10 seats. You are given the task to write a program to manage the seat assignments on an airplane. The names of the passengers are stored in a file. The seats are numbered 1 through 10. Your program reads this file and assigns each passenger to a seat. The program needs to have a function to print the passenger list starting at seat 1 and going to seat 10, and another function to print the list starting at seat 10 and going to seat 1.

 You have changed jobs and now work for JumboAir Airlines. Every JumboAir airplane has 200 seats. JumboAir also wants you to write a program that manages the seat assignments on an airplane. Can you make some small modifications and reuse the program you built while you were working at MicroAir?

GENERATE IDEAS


 * Have the students work in groups on Part 1 of the challenge. Ask them to write an algorithm to solve the problem.
 * What is your approach to the problem?
 * What are the strengths and weaknesses of your approach?
 * Add Part 2 of the challenge. Have the students go back to their groups.
 * Can the Part 1 solution work for Part 2?
 * What are the strengths and weaknesses of Part 1 applied to Part 2?
 * Are there changes to the solution to Part 1 that might make the program work better for Part 2? You don't need to know how to write a program for these solutions, just outline your ideas.

MULTIPLE PERSPECTIVES


 * Discuss a sample of the students' solutions to Part 1 and Part 2.
 * Point out the strengths and weaknesses to the Part 1 solutions.
 * Discuss the ideas generated in Part 2.
 * Lecture on Arrays. Focus on how we could build a good solution for Part 2 of the challenge question.
 * How to store people's names and their airplane seat.
 * How to access an element of the array.
 * How to iterate through the array to print each element.

RESEARCH & REVISE


 * Students will work on exercises to practice simple problems using arrays.
 * Have the students outline a solution for Part 2 of the challenge, using arrays.

TEST YOUR METTLE


 * In-class exercises: students work individually or in small groups on code trace or short programming problems. We then discuss the solution, and try another similar problem.

GO PUBLIC


 * Students will complete a programming assignment that requires them to use arrays to solve a complex problem.
 * Students will take an exam where they have to answer questions about using arrays.

Pre-Lesson Quiz
{An array can store many types of values -TRUE +FALSE
 * type=""}

{An array index starts with 1 -TRUE +FALSE
 * type=""}

{The following is a proper declaration and initialization of an array

int arr[5] = {6, 9, 27, 76, 81}; +TRUE -FALSE
 * type=""}

Test Your Mettle Quiz
NOTE: The wiki code for this quiz has some errors

{The following code will compile and run without errors:

int arr[10] = { 0 }; for( int i = 0; i <= 10; i++ ) {    arr[i] = 1; } -TRUE +FALSE
 * type=""}

{The output of the following code is:

int arr[5] = { 5, 4, 3, 2, 1 } ; arr[1] = arr[4] + arr[1]; arr[3] = arr[3] + 1; for( int i = 0; i < 5; i++ ) {    cout << arr[i] << " "; } - 5 4 3 3 1 + 5 5 3 3 1 - 8 4 3 4 5 - 7 4 4 2 1
 * type=""}
 * Remember that the array index starts at 0