Kotlin
Java

Functions and Algorithms
Kotlin

Created By: Geoffrey Challen
/ Updated: 2022-05-26

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

But let's start with some debugging practice!

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.

Reimplement array search, wrap in a method, and then test.

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.

Get students started on the practice problem. Make sure to discuss the difference between the playground and the homework environment.

Show how to complete the homework problem above. Feel free to cover multiple approaches!

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.

Reimplement array sum, wrap in a method, and then test.

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.

Get students started on the homework problem. Demonstrate how methods can modify the values of arrays that are passed to them.

Show how to complete the homework problem above. Feel free to cover multiple approaches!