Finding the smallest integer in an array using a recursive function (Python) -


this question has answer here:

i have write function uses recursion in order determine smallest number in array. have no idea how approach this, since recursion not part of introductory course taking, want give exposure it.

so far i've had following idea (but not rely on recursion, , have not made go through entire array):

           if numbers[0] <= numbers[1]:                  del numbers[1]            else:                  del numbers[0] 

where numbers array, instance numbers=[2,1,3,4]. instance want function return 1 smallest integer in array. how go using recursive function solve this?

ps: use python 3.

you can use builtin function (min), if want iterate, can use cicle. variable "i" goes through array , gets each value in iteration. can use while cicles iterate not recommended in case

numbers=[2,1,3,4]  #using min builtin function print(min(numbers))       #using low_num = numbers[0] in numbers:     if < low_num:         low_num = print(low_num) 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -