Complete questions only 1- 3
Projects
A sequential search of a sorted list can halt when the target is less than a given element in the list. Define a modified version of this algorithm, and state the computational complexity, using big-0 notation, of its best-, worst-, and average-case performances.
The list method reverse reverses the elements in the list. Define a function amed reverse that reverses the elements in its list argument (without using the method reverse!). Try to make this function as efficient as possible, and state its computational complexity using big-0 notation.
Python’s pow function returns the result of raising a number to a given power. Define a function expo that performs this task, and state its computational complexity using big-0 notation. The first argument of this function is the number, and the second argument is the exponent (nonnegative numbers only). You may use either a loop or a recursive function in your implementation. Caution: do not use Python’s operator or pow function in this exercise
An alternative strategy for the expo function uses the following recursive definition:
expo(number, exponent)
= 1, when exponent
= 0 = number expo(number, exponent – 1), when exponent is odd
= (expo(number, exponent // 2))2, when exponent is even
Define a recursive function expo that uses this strategy, and state its computational complexity using big-0 notation.
Python’s 1 i st method sort includes the keyword argument reverse, whose default value is False. The programmer can override this value to sort a list in descending order. Modify the selection Sort function discussed in this chapter so that it allows the programmer to supply this additional argument to redirect the sort.