## Write a recursive function makeMessage(text,number) that takes two parameters: a string, and a positive integer.

### computer science

##### Description

Problem 1

Write a class called Clock to conceivably be used for keeping track of time. Assume that this is a 24 hour clock, where the hour number ranges from 0 (which is midnight) to 23 (which is 11 pm), and the minutes range from 0 to 59. Include the following methods:

a constructor that initializes the time to 8:30 am.

setTime(hour, minute): sets the clock time to a particular value

getMinutesPastMidnight(): returns the number of minutes that have elapsed since midnight. For example, if the time is 1:03, the method should return 63.

copyTime(anotherClock): sets the time of this clock to be the time that anotherClock has, where anotherClock is another Clock object

You should have no print statements anywhere in your code.

Problem 2

Each of the two problems below is worth half of an “M” for purposes of grading.

Part a

Write a recursive function makeMessage(text,number) that takes two parameters: a string, and a positive integer. The function should return a string consisting of the original string concatenated together the number of times specified. For example, if you call makeMessage(`hi!',3), it should return the string 'hi!hi!hi!'. Your function should not print anything.

Part b

Write a recursive function changeLetter(word, letter, replacement). The function should return a new word that is identical to the original, but with all occurrences of letter changed to the word replacement. For example, changeLetter('abbbacbd', 'b', 'dog') should return 'adogdogdogacdogd'. (Your code should not use the Python built-in methods find, index, partition, split, or replace.)

Problem 3

Each of these problems below is worth 0.25 of an “M” for purposes of grading.

You may type at your answers to this using software of your choice, or you may write it NEATLY on paper and take a picture. You should submit it as a PDF if you use software to create it, or submit a PNG or JPG/JPEG if you take a photo. (Please do not submit formats from Microsoft Word or Apple Pages; the layout isn’t always stable when opening on other computers. Export to PDF if you use any of those tools.)

Part a

Suppose that I am given the list [1, 17, 19, 20, 36, 40, 56, 59, 93, 98, 99], and that I do a linear search for a 107. Provide a list of all the numbers in the list that are tested, in the order that they are tested, before concluding that 107 is not in the list.

Part b

Now suppose that I am given the list [1, 17, 19, 20, 36, 40, 56, 59, 93, 98, 99], and I do a binary search for a 97. Provide a list of all the numbers in the list that are tested, in the order that they are tested, before concluding that 97 is not in the list. Assume that if the next location in the list to be tested is calculated to be halfway between two actual locations, then we pick the location that is closer to 0.

Part c

Show how selection sort would sort the list [5, 3, 7, 2, 6]. Specifically, show what the list would look like each time the positions of two numbers are changed.

Part d

Redo the previous part for insertion sort. You only need to show what it looks like after each round of insertions; you don’t need to show the values getting copied down as the insertions are done.

]