ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos

AP Computer Science 3.4 Standard Algorithms 177 Views


Share It!


Description:

AP Computer Science: Drill 3, Problem 4. What should go in "expression 2" to complete the method?

Language:
English Language

Transcript

00:00

Sorry On here's your shmoop du jour about to convey

00:06

some knowledge and maybe erection Hear that All right this

00:11

code is a method for a sequential search through an

00:14

array list called ah list Clever title Well what should

00:19

go in expression to to complete the method this expression

00:24

here time and here your potential answers What do you

00:28

think Value value All right here we go Okay well

00:33

this code is pretty simple Sequential search the four loop

00:36

the finer points of which we've covered in the previous

00:39

question iterated through an array list and the if statement

00:43

will check each element to see if it's equal to

00:46

the imager called number that we were looking for donald

00:49

that alright well having covered expression one in a previous

00:52

question looks like this by the way were now being

00:55

asked for expression too or do if you're in paris

00:59

and really clever All right if the four loop is

01:03

the conveyor belt that brings us the next item down

01:06

the line the if statement will be the bit that

01:09

looks for a match You know like jd we're being

01:13

asked what the structure of the if statement should be

01:16

options And beer both out They use standard array style

01:19

brackets to refer to elements a rainless require using the

01:23

get method to retrieve stuff As for picking apart option

01:26

c and d well the objective here is to return

01:28

a true or false for the if statement toe work

01:31

with with option d there's a conditional operator present within

01:35

those parentheses a double equal sign which will check if

01:38

the two items are equal and return a true or

01:42

false Got it well then it attempts to shove that

01:45

whore false into our values variable which is an imager

01:48

It's where bag meat round hole not good option c

01:52

copies the current element in a list to the variable

01:56

value here then checks If it's equal to the imager

01:59

number which is the number we're looking for The result

02:03

of this statement would be a true or false that

02:05

would enable the if statement then either execute the code

02:09

inside it's blocked or not All right there is the 00:02:12.91 --> [endTime] answer I don't know

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 4.2 Standard Algorithms
191 Views

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

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 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,...