Multidimensional Array Sample Projects. Grading Program Objective: write a program that grades multiple-choice test.

Slides:



Advertisements
Similar presentations
Arrays.
Advertisements

Chapter 9: Advanced Array Manipulation
Maths for Computer Graphics
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Slides prepared by Rose Williams, Binghamton University Chapter 6 Arrays.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
CMPUT 101 Lab #6 October 29, :00 – 17:00. Array in C/C++ Array is a structure type variable. One dimension of array int: int num[3]; There are.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 8 Multidimensional.
Chapter 9 Introduction to Arrays
Programming Logic and Design Fourth Edition, Comprehensive
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 7 Multidimensional.
CS 106 Introduction to Computer Science I 02 / 19 / 2007 Instructor: Michael Eckmann.
© The McGraw-Hill Companies, 2006 Chapter 16 Two-dimensional arrays.
Multi-Dimensional Arrays in Java "If debugging is the process of removing software bugs, then programming must be the process of putting them in." -- Edsger.
Arrays Multi-dimensional initialize & display Sample programs Sorting Searching Part II.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Programming Fundamentals I (COSC-1336), Lecture 8 (prepared after Chapter 7 of Liang’s 2011 textbook) Stefan Andrei 4/23/2017 COSC-1336, Lecture 8.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 8 Multidimensional Arrays.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
CHAPTER: 12. Array is a collection of variables of the same data type that are referenced by a common name. An Array of 10 Elements of type double.
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 8 Multidimensional Arrays.
ITI 1120 Lab #9 Slides by: Diana Inkpen and Alan Williams.
Data Structure CS 322. What is an array? Initializing arrays Accessing the values of an array Multidimensional arrays LAB#1 : Arrays.
Chapter 8: Arrays Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 8 Arrays.
Arrays Dr. Jose Annunziato. Arrays Up to this point we have been working with individual primitive data types Arrays allow working with multiple instances.
1 Chapter 12 Arrays. 2 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
Excel-Introduction Business –E.g., Creating budget Chemistry –E.g., Analyzing chemical’s temperature vs. time Psychology –E.g., Test scores English –E.g.,
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
UNIT 10 Multidimensional Arrays.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
6 th Grade Unit 3 Vocabulary By Drew Levine. Algebraic expression An algebraic expression is when you can use any numbers for that problem and you replace.
Multidimensional Arrays Computer and Programming.
Chapter 8 Slides from GaddisText Arrays of more than 1 dimension.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 11 Lists for Multi-dimensional Data.
© 2006 Pearson Addison-Wesley. All rights reserved Arrays of Greater Dimension One-dimensional arrays are linear containers. Multi-dimensional Arrays.
Arrays Chapter 12. One-Dimensional Arrays If you wanted to read in 1000 ints and print them in reverse order, it would take a program that’s over 3000.
 2005 Pearson Education, Inc. All rights reserved Arrays.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Two-Dimensional Data Class of 5 students Each student has 3 test scores Store this information in a two- dimensional array First dimension: which student.
Python Fundamentals: Complex Data Structures Eric Shook Department of Geography Kent State University.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 7 Multidimensional Arrays.
1 Multidimensional Arrays Chapter 13 2 The plural of mongoose starts with a "p" Initializing a multidimensional array Processing by.
Beginning C for Engineers Fall 2005 Arrays, 2-D arrays, character strings Bettina Schimanski Lecture 5: Section 2 (9/28/05) Section 4 (9/29/05)
Optimization. How to Optimize Code Conventional Wisdom: 1.Don't do it 2.(For experts only) Don't do it yet.
Arrays 4/4 By Pius Nyaanga. Outline Multidimensional Arrays Two-Dimensional Array as an Array of Arrays Using the length Instance Variable Multidimensional.
1 Chapter 7 Multidimensional Arrays. 2 Motivations You can use a two-dimensional array to represent a matrix or a table.
CS1020 – Data Structures And Algorithms 1 AY Semester 2
Chapter 8 Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Sit-In Lab 1 Ob-CHESS-ion
Chapter 8 Multidimensional Arrays
Arrays … The Sequel Applications and Extensions
Chapter 8 Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Magic Squares   10   X.
Starting Out with Programming Logic & Design
Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Multidimensional Arrays
Multidimensional Arrays
Building Java Programs
Chapter 8 Multidimensional Arrays
Multidimensional Arrays Section 6.4
Chapter 7 Multidimensional Arrays
Chapter 8 Multidimensional Arrays
Presentation transcript:

Multidimensional Array Sample Projects

Grading Program Objective: write a program that grades multiple-choice test

Grading Program Patterns: – Iterate 2D array – Sum up rows Modifications: – Break into functions – Record student scores in arrays – Get rid of i/j?

Nearest Points Rows : Points Cols : x, y

Nearest Points Patterns: – Not all array dimensions going to be looped over – Iterate through one array twice Compare item i to item i+1…end – Find smallest pattern

Nearest Points Modification: – Clean up indices – Constants for x and y instead of magic numbers: VS:

Sudoku Each number must be unique in Row/Col/Square

Sudoku Each number must be unique in Row/Col/Square

Sudoku Each number must be unique in Row/Col/Square

Map column to square 0 / 3 = 0 1 / 3 = 0 2 / 3 = 0 3 / 3 = 1 4 / 3 = 1 5 / 3 = 1 6 / 3 = 2 7 / 3 = 2 8 / 3 = 2 Sudoku

Sudoku Squares start at 0, 3, 6 0 / 3 * 3 = 0 1 / 3 * 3 = 0 2 / 3 * 3 = 0 3 / 3 * 3 = 3 4 / 3 * 3 = 3 5 / 3 * 3 = 3 6 / 3 * 3 = 6 7 / 3 * 3 = 6 8 / 3 * 3 =

Sudoku Patterns – Flag… look for reason to say false – Avoid self check

Sudoku Critique – row vs currentRow – i as parameter name

Temperature/Humidity File has day / hour / temperature / humidity Find daily averages Uses 3-D array: data[DAY][HOUR][TEMP/HUMIDITY]

Temp Patterns: – Change human numbers to array index:

Temperature/Humidity Critiques: – Don't need array for job as stated – Would two 2D arrays be better? – No

Find Local Maxima Objective : print all cells that are strictly greater than 4 direct neighbors Something is missing!!

Find Local Maxima Sanity check indices when appropriate: