ShmoopTube
Where Monty Python meets your 10th grade teacher.
Search Thousands of Shmoop Videos
AP Computer Science 4.1 Standard Data Structures 10 Views
Share It!
Transcript
- 00:05
And here's your shmoop du jour brought to you by multi-dimensional [Spacecraft opens up in space and cube character appears]
- 00:08
arrays they're not just a sci-fi alien weapon people...What is the value of Q
- 00:13
and here are your potential answers..... well quick visualize an array
- 00:21
of eight elements do it got it? yeah pretty simple it's a little like a [Man thinking of 8 elements]
- 00:25
number line but with data sitting on it that and to refer to any element you can
Full Transcript
- 00:30
call it by its index what if you want another row of data well sure you could
- 00:34
make a whole new separate array but that's little clunky this is more of a
- 00:38
job for a two-dimensional array add an extra set of brackets and well off we go [array with added set of brackets]
- 00:42
we can reference anything in this array by using two indices horizontal and
- 00:47
vertical or clever names x and y want to get wild I'll we can keep going on to [Men in a boxing ring ready to fight]
- 00:52
three dimensional arrays are totally doable and turn our square into a
- 00:56
cube and again we'd be using the arrays three indices so we can reference [Cube with an array]
- 01:00
elements anywhere along its three axes so now we have a three dimensional array
- 01:05
full of data sounds very futuristic already but we can go further than that [Man hurdling over arrays]
- 01:08
what would a fourth dimension be like where would you put it? easy! well right
- 01:13
next to it just like a complaint from your physicist friend all right if a
- 01:17
one-dimensional array gave us a number line 2D gave us a square and 3D
- 01:22
gives us a cube then 4D is a number line made of cubes did we just blow your [Explosion occurs]
- 01:28
mind all right and a 5d array well you guessed it a grid made of cubes.. 6D? a
- 01:34
cube made of cubes.. 7D a number line made of a cube made of cubes you can see
- 01:40
where this is headed into infinity well the Java language specification states [Buzz flys away and java specification book appears]
- 01:44
that you could theoretically have infinite dimensions but the Java Virtual
- 01:47
Machine the thing that actually excutes the code sets a limit of 250 five [Laptop with 255 dimensions on the screen]
- 01:53
dimensions thankfully for our brains the need for that many dimensions doesn't
- 01:57
come up all that often in fact an array of more than three dimensions is [Mans head opens and arrays enter inside]
- 02:00
downright rare and this question is asking us what the length of a certain
- 02:04
two-dimensional array would be logically speaking
- 02:07
since we're dealing with a 2d array it'd makes sense to multiply width x height
- 02:11
like measuring a rectangle like 12 times 10 but that's not how the length function
- 02:16
works in Java it returns a simple integer based on the length of a single
- 02:20
dimension in this case the first dimension because we didn't specify a [Java code line circled]
- 02:23
deeper one that said the answer was right in front of our faces the entire
- 02:27
time it's just as well.
Up Next
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
Related Videos
AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?
AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?
AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism. Which of the following will satisfy the conditional if statement for boo, str,...
AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?