Question: Write a recursive function called smallest that given a non - empty Python list, returns the smallest element in the list. Thinking recursively, the smallest
Write a recursive function called smallest that given a nonempty Python list, returns the smallest element in the
list. Thinking recursively, the smallest integer is either the first integer in the list or the smallest integer in the rest
of the list, whichever is smaller. If the list has only one integer, then the smallest integer is this single value.
Examples:
Input: Output:
Input: Output:
Helpful Python syntax: If A is a
list of integers, and you want to
set the list B to all of the
integers in A except the first
one, you can write B A:
Problem points
Given a sorted in ascending order Python list of distinct integers, return all the indices i such that the elements
at index i equals i There may be more than one such index, so the return type is a Python list containing all
indices that satisfy the criteria.
Write two functions for the same problem. The first function, linearSearchValueIndexEqual, uses linear search, and the
second function, binarySearchValueIndexEqual, uses binary search. The test cases for the two functions in Gradescope
are the same.
When the input list is empty, return an empty list.
Examples:
Input:
Output:
Explanation: The element at index is so the value equals its index.
Input:
Output:
Explanation: The element at index is and the element at index is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
