JAVA Expert Help me.. Write a function that accepts an array of integers and returns

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2007
Posts: 5
Reputation: bc030400412 is an unknown quantity at this point 
Solved Threads: 0
bc030400412 bc030400412 is offline Offline
Newbie Poster

JAVA Expert Help me.. Write a function that accepts an array of integers and returns

 
0
  #1
Oct 12th, 2007
Write a function that accepts an array of integers and returns the second largest integer in the array. Return -1 if there is no second largest.

The signature of the function is

public class bc
{
public static void main(String[] args){ }
int f(int[ ] a) { }

}

Examples:

if the input array is {1, 2, 3, 4} return 3
if the input array is {{4, 1, 2, 3}} return 3
if the input array is {1, 1, 2, 2} return 1
if the input array is {1, 1} return -1
if the input array is {1} return -1
if the input array is {} return -1


bc.java (Required code)
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,506
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 521
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: JAVA Expert Help me.. Write a function that accepts an array of integers and returns

 
0
  #2
Oct 12th, 2007
Just post your code and ask about the parts you don't understand. All you have posted here is your assignment.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC