Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Find biggest 2 numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Find biggest 2 numbers" Watch "Find biggest 2 numbers" New topic

Find biggest 2 numbers

kavitha vasu
Ranch Hand

Joined: Feb 22, 2007
Posts: 70
Hi friends,

Yesterday I have attended one interview , I got question like these,


How to find biggest of 2 numbers amoung these numbers .

Should not use any sorting algorithm
also they asked me to use any collection classes.
Also how to find duplicate of these numbers

Please any one help me to get solution for this.

Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3640
Kavitha, you got to read Collection API from Thinking In Java !!
[ March 03, 2008: Message edited by: Chetan Parekh ]

My blood is tested +ve for Java.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575


in collection class,TreeSet class is there,which avoid dupulicatevalue and also it will arrage the datas in ascending last number is greatest number,and prvious one is 2nd greatest number

note:which class implements set interface always has the above properties

thanks & regards,

kavitha vasu
Ranch Hand

Joined: Feb 22, 2007
Posts: 70

Here i have to find the which is duplicate number and that should be printed on screen.

How to do that?
I agree. Here's the link:
subject: Find biggest 2 numbers
jQuery in Action, 3rd edition