ShmoopTube
Where Monty Python meets your 10th grade teacher.
Search Thousands of Shmoop Videos
Computer Science Videos 112 videos
AP Computer Science: Classes and Objects Drill 1, Problem 1. Which of the following is a correct {/* Implementation */} for the isInsect method?
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
AP Computer Science 1.3 Classes and Objects. Which of the following should be declared as a static variable?
AP Computer Science 3.5 Standard Data Structures 176 Views
Share It!
Description:
AP Computer Science: Standard Data Structures Drill 3, Problem 5. The resulting array from this code snippet has which of the following shapes?
Transcript
- 00:00
Sorry And here's your smug du jour Brought to you
- 00:05
by the multi dimensional array It sounds like a device
- 00:08
used to travel across the universe But it's just a
- 00:10
computer science thing that'll make you wish a meteorite would
- 00:13
fall on your face All right The resulting array from
Full Transcript
- 00:16
this code snippet has which of the following shapes And
- 00:20
here your potential answers Where rectangles circles Okay here we
- 00:25
go Nothing pushes a person's brain to the breaking point
- 00:28
Quite like the street magic of rubik's cubes and multidimensional
- 00:32
raised well looks like this code uses the first two
- 00:35
lines to create a two dimensional array of length ten
- 00:38
and twelve hollywood squares on mars Then a loop is
- 00:41
created and something gets added each cycle Well well look
- 00:45
at that lube or in depth in a second But
- 00:47
let's take a moment to see if we can knock
- 00:49
out some potential answers based on that information alone Option
- 00:52
a says the resulting array would look like a square
- 00:56
being that we've created two arrays with length of ten
- 00:58
and twelve there's No way it's going to be a
- 01:00
perfect square option B says we're creating a rectangle Well
- 01:03
maybe We'll hang on to be for now a better
- 01:05
shot he says we'll be creating a circle Well that
- 01:08
doesn't seem very likely because the four loop only increases
- 01:11
some factor in value probably widening the shape forever We'll
- 01:15
see that second circle It obviously need to come back
- 01:18
down to zero toe Drop the second half All right
- 01:20
let's put sea into the no pile All right d
- 01:23
a triangle Well totally possible If the shape is increasing
- 01:27
in size with every generation that loop things might end
- 01:29
up looking like a right triangle Thank you paige Rhys
- 01:33
We'll need to walk through the code To be sure
- 01:35
though e none of the above Well let's find out
- 01:37
Okay we've got our two dimensional array called multi with
- 01:41
length of ten and twelve Then loop begins with the
- 01:43
generator i at zero and runs until eyes no longer
- 01:47
lessen the length of the multi array which is ten
- 01:49
At least in terms of the first given dimension From
- 01:52
that we can predict the code within louisville Run ten
- 01:55
times One's inside It'll take the multi raise second mention
- 01:58
it Whatever I currently and zero on the first cycle
- 02:01
and create a new imager at the position of zero
- 02:04
plus one no one Then it'll cycle again with i
- 02:08
increased by one and again and again and again we
- 02:10
could keep going but it looks like we're just getting
- 02:12
a right triangle just to double check Let's open our
- 02:15
interpreter and add this line to loop so we can
- 02:18
visualize what's being constructed system out print line a raise
- 02:22
to string multi eye all right that'll print to the
- 02:26
console in string form Whatever the content of multi at
- 02:29
the eye dimension is and you're goes and yep that's
- 02:32
pretty triangle e and a right triangle e is that
- 02:36
the ideas are answer and we didn't even have to
- 02:38
try Is that hard Hi sorry we'll try to do 00:02:42.11 --> [endTime] better He's going forward there yeah
Related Videos
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
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?