The Artima Developer Community
Sponsored Link

Java Answers Forum
Recursive method to find minimum value in an array

3 replies on 1 page. Most recent reply: Nov 12, 2002 9:00 AM by Dante T. Salvador

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Marie Harris

Posts: 6
Nickname: match
Registered: Nov, 2002

Recursive method to find minimum value in an array Posted: Nov 11, 2002 3:03 PM
Reply to this message Reply
Advertisement
How do I find the minimum value in an array by writing a recursive method recursiveMinimum that takes an integer array and the array size as arguments and returns the smallest element of the array. The method should stop processing and return when it receives an array of one element.

Thank you very much.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Recursive method to find minimum value in an array Posted: Nov 11, 2002 3:43 PM
Reply to this message Reply
For one thing, you don't need to pass the size. This isn't C, you know (well, maybe you didn't, but you do now).
def whoNeedsRecursionJustToFindAMinimum( a ):
   a.sort()
   return a[0]

Or would you like that in C#? Or maybe Ruby?

Marie Harris

Posts: 6
Nickname: match
Registered: Nov, 2002

Re: Recursive method to find minimum value in an array Posted: Nov 11, 2002 5:35 PM
Reply to this message Reply
Thanks for your help, however, your response will not assist me in solving this problem. I need to use a recursive method to find the minimum balance in an array.

Dante T. Salvador

Posts: 19
Nickname: anteng
Registered: Nov, 2002

Re: Recursive method to find minimum value in an array Posted: Nov 12, 2002 9:00 AM
Reply to this message Reply
i can't understand your problem, can you explain further and try to code something first

Flat View: This topic has 3 replies on 1 page
Topic: Masking in Java Previous Topic   Next Topic Topic: Java Exercise help?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use