← all problems

Introduction to Algorithms 🌶️

An algorithm is an ordered series of steps to solve a problem.

Let's say that you are trying to buy the posts and fence sections to build a fence. Each fence panel is 8 feet long and there need to be posts at each end of the whole fence and in between each panel. If you need 16 feet of fence, how many posts and panels do you need?

Well, if one panel covers 8 feet, two panels will cover our 16 feet length. How about posts? With two panels, we need one post at each of our two ends and one more between them for a total of three. Our answer is two panels and three posts.

We solved one fencing problem, but what if we wanted to make an algorithm or procedure for solving many such cases? What if all we knew was that we had some unknown length named x. Could we make a series of steps that figures out our quantities of materials?

What about the following:

Divide x by 8 feet, this is the number of panels needed.Add 1 to the number of needed panels, this is the number of posts

1. A school bus holds 48 students. If x represents the total number of students on a field trip, what expression will yield how many buses are needed at minimum?

Click a placed token to send it back. With drag-and-drop enabled, you can also drag tokens to reorder them.

Click these, in order, if they belong in the line
Your line, in order

Your score for your class is recorded when you click Submit all — checking individual questions doesn't save it. You can submit again to improve your score; your best one counts.