DOC PREVIEW
TRINITY CSCI 1320 - Multidimensional Arrays

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

Save
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

Unformatted text preview:

Multidimensional Arrays 10 17 2007 1 Opening 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 2 Searching 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 3 Binary 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 4 Array 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 5 Multidimensional 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 6 Mazes 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 7 Minute 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 ints 8


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 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?