Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a recursive function CoconutSearch that takes three parameters: an array, starting position, and the number to search. It returns the location of a

image text in transcribed

1. Write a recursive function CoconutSearch that takes three parameters: an array, starting position, and the number to search. It returns the location of a number if exists in the array, otherwise returns - 1. The function works as per the following recursive definition: - if e is at the location loc in the array then returns loc, - Otherwise, search again at loc+1 - If loc is greater than number of elements than returns - 1 def Coconut Search (array, loc, e): 1/ your code goes here Example: array = [1,2,3,4,5) print (Coconut Search (array, 0, 2)) print (Coconut Search(array, 0, 6)) #the function should return 1 -1 2. Write a function RotateLeft that rotates an array of size n to the left. The function takes two parameters an integer d which is the amount to rotate by and an array. The function should return the rotated array. def RotateLeft (array, d): // your code goes here Example: array - [1,2,3,4,5) d = 2 #two rotations print (RotateLeft (array,d)) #the function should return [3,4,5,1,2]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago