# DS&A

Data Structures and Algorithms

## Exercises: Recognising “Plans”

Mar 192018

Before attempting these exercises, you should read the posts on specifying problems, problem-solving and algorithmic “plans”.

### Exercises

1. Name the plans used in the following code, and specify the problem this function solves.
``````def exercise1(numbers):
for i, value in enumerate(numbers):
numbers[i] = 10 * value``````
2. Name the plans used in the following code, and specify the problem this function solves.
``````def exercise2(numbers):
total = 0
for value in numbers:
cube = value ** 3
total += cube
3. Name the plans used in the following code, and specify the problem this function solves.
``````def exercise3(numbers, cutoff):
for i, value in enumerate(numbers):
if value >= cutoff:
return i
return -1``````
4. Name the plans used in the following code, and specify the problem this function solves.
``````def exercise4(strings, max_length):
counter = 0
for value in strings:
if len(value) > max_length:
counter += 1
return counter``````

## New comment

Your comment will not appear until a moderator approves it.

Atom

hosted on werp.site