DOC PREVIEW
TRINITY CSCI 1320 - Multidimensional Arrays

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Multidimensional Arrays10/17/20072Opening Discussion■Let's look at some solutions to the interclass problem.■Do you have any questions about the assignment?■ACM's “Make the Most of Your Major” event is this evening.■Fun things in planetary science.Lots of Cassini data on rings and moons.Nice model of planetary formation.3Searching■Far more common than sorting is the act of searching.■If I give you an array of ints and ask you to tell me where the number 33 is, what would you do?■How fast is this procedure? How many checks do you need to do?4Binary Search■The real benefit of sorting is that we can search faster. If data is sorted we can do a binary search.■Start in the middle and determine if what you are looking for is on the right or the left.■This only works for sorted data, but it is MUCH faster for big data sets. It is O(log2 n) instead of O(n).5Array Types■When we declare int a[] you can think of it as a being of type int[]. (That is actually the accepted syntax in Java.)■The array types are themselves types. By adding the brackets you basically create a new type that is an array of the base type. You can do this with any type.6Multidimensional Arrays■If array types are types and we can make arrays of any type then we can make arrays of arrays.■This is what produces multidimensional arrays. To declare a multidimensional array simply put multiple sets of brackets with sizes after the variable name.int a[10][20];■When you pass a multidimensional array, you must specify the size of every dimension except the first one.■You can put lots of dimensions on an array, but there are few applications needed more than three. Memory requirements grow quickly.7Mazes■There are lots of different uses for 2-D arrays, but one of my favorite is that of mazes.■These also provide a great playground for recursion because maze functions are among the set that are hard to write with loops, but easy to do with recursion.8Minute Essay■Given that an int takes four bytes on these machines, how much memory would the following declaration consume?int a[10][5][20][100];■Remember that the assignment is due on Friday.■ACM's “Make the Most of Your Major” event is this evening at 7pm in HAS 340.■Interclass Problem – Write a function that tells you the length of the longest path from a given location to 0,0 on a maze made with a 2-D array of


View Full Document

TRINITY CSCI 1320 - Multidimensional Arrays

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Multidimensional Arrays
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Multidimensional Arrays and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Multidimensional Arrays 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?