KotlinCS 124 LogoJava

Functions and Algorithms

Functions are so important that we’re going to continue getting more practice with them. We’ll also discuss the connection between functions and algorithms, the conceptual heart of computer science.

Throughout this lesson we’ll return to bits of code that we previous implemented as snippets and reimplement them as methods. We’ll also use this as a chance to reinforce some important programming patterns that we’ve already been using.

Debugging Challenge
Debugging Challenge

But let’s start with some debugging practice!

Array Search
Array Search

Next, let’s revisit the code we wrote for array search, rewrite it is a method, and then test it using some sample inputs.

// Array Search

Array Is All Larger
Array Is All Larger

Our next practice problem has a tricky loop setup. Let’s review that together, and then you can attempt the problem itself.

// Array Is All Larger Setup

Array Sum
Array Sum

Now, let’s revisit the code we wrote for array sum, rewrite it is a method, and then test it using some sample inputs.

// Array Sum

Catchup Quiz Grading
Catchup Quiz Grading

As a bit of homework preparation support, let’s talk through how to approach this lesson’s homework problem, since it has another interesting loop setup. We’ll also demonstrate how we can modify the values of arrays that are passed to methods. And we’ll provide practice with a variant of the problem that you need to complete for today’s homework.

// Catchup Quiz Grading Setup

More Practice

Need more practice? Head over to the practice page.