ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos


AP Computer Science Videos 113 videos

AP Computer Science 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 1.4 Standard Algorithms
200 Views

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
191 Views

AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?

See All

AP Computer Science 1.3 Standard Data Structures 174 Views


Share It!


Description:

APCS: Standard Data Structures Drill 1, Problem 3. Which of the following is the best postcondition for the fillArray method?

Language:
English Language

Transcript

00:00

Thank you We sneak and here's your shmoop too Sure

00:06

And by the way this week in history the first

00:08

software pirates sailed the high c plus plus is in

00:11

search of ruby and earl All our geeky coder friends

00:15

are really laughing at that one All right phil array

00:19

method has the following preconditions our is a valid in

00:23

terrain declared with a specified length greater than or equal

00:26

to one Are that bar well which of the following

00:32

is the best post condition for the pillory method And

00:35

here the potential answers we're thinking we're thinking and if

00:40

we stop now we're thinking again okay free and post

00:43

conditions are like promises we make to ourselves almost like

00:47

new year's resolutions except we actually wind up keeping In

00:51

the case of the phil ary method we're working with

00:53

the precondition that r is a valid array of imagers

00:57

with a length greater than or equal to one let's

01:00

walk through the method to see what it actually does

01:03

well first line hear gives us an imager named flynn

01:06

which is the length of the array we're going to

01:09

be filling The next line starts up for life the

01:12

three parameters were set up to create emitter i as

01:15

the counter starting at zero and specifies that lupul run

01:18

until ice less than len becomes false and iterated I

01:24

buy one each time The looks like the code within

01:27

the loop itself visits the array of whichever position i

01:30

is at the time and fills that position's content with

01:33

again number that eyes that though position zero in the

01:37

array will contain the number zero position four will contain

01:41

the number four and so on Get it let's Look

01:44

at the potential answers option a this one says that

01:47

our is an imager array of length twenty Well no

01:51

the hillary method is written in such a way that

01:54

it'll fill an array of whatever size we specified Option

01:57

b says our is an imager array of a length

02:00

thread a ventricle the one and each value equals its

02:03

index Hey that sounds exactly like what we're making better

02:07

check the other cells What option c says is technically

02:10

true but it's less specific than option b and that

02:12

it doesn't say anything about the values being the indices

02:16

though it's not our best choice option d again with

02:19

the twenty thing no option a is pretty similar to

02:22

be except that the arrays and unspecified size that's not

02:26

true erase sizes definitely greater than zero because the loops

02:29

generator starts at zero and aloof runs until the generator

02:33

is equal to or greater than our yeah software pirate

02:37

joke we've beaten to death If we specified we wanted

02:40

in a ray the sides of negative three for example

02:42

aside from being impossible the four loop wouldn't run it

02:45

all because the generator is already greater than our and

02:49

no array would be generated Not only that but our

02:51

precondition already specified The array of length is greater than

02:54

or equal to one so nuts to that Our answer's 00:02:57.115 --> [endTime] Definitely B no not r it's b

Related Videos

AP Computer Science 1.4 Standard Algorithms
200 Views

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
191 Views

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
204 Views

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 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 4.2 Standard Algorithms
191 Views

AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?