answersLogoWhite

0

First, let's assume that this is a set of integers that you want to find the maximum of:

Set setOfInts; // also assume that this set is full of some ints

Iterator it = setOfInts.iterator();

int max;

if(it.hasNext()) {

max = it.next();

while(it.hasNext()) {

int current = it.next();

if(current > max) {

max = current;

}

}

// max is now the largest number in the set

}

The problem comes when trying to find the position of the maximum number in the Set. By definition, a Set is an unordered group of numbers. So any order that the Set returns (say, by the Set's iterator) will be arbitrary.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Design an algorithm for finding all the factors of positive integerfor example in the case of the integer 12your algorithm should report 12346 and 12?

design an algorithm for finding all the factors of a positive integer


Design an algorithm for finding integer solutions for equations of the form x2 y2 n where n is some given positive integer Determine the time complexity of your algorithm?

yea me too dude. Mahleko :(


Design an algorithm to show the different operations on a stack?

Design an algorithm to show the different operations on a stack?


Design an algorithm to show the different operations on degree?

Design an algorithm to show the different operation on the degree.


Design step by steps algorithm on how to write the letter A and display the result?

Design step by steps algorithm on how to write the letter A and display the result


What is the design technique that programer use to breakdown algorithm into modules?

top-down design


Divide and conquer what does it mean?

Divide and conquer is computer science. It is an important algorithm design.


Is algorithm design part of the description of a dsp engineering job?

It appears that algorithm design is a part of having a DSP engineering job. To find out what exactly a DSP engineer may have to do, visit http://www.careerbuilder.com/jobs/keyword/dsp+engineer


Design and analysis of algorithm question bank?

hai this web site very useful senthil


Design recursive algorithm for computing 2n for any non negative integer n which is based on the formula2n2n-1 2n-1?

The formula, as far as I can see, is not appropriate for the algorithm.


What is design capacity?

maximum obtainable output


Design an algorithm to find a reverse of number?

An example of an algorithm that will reverse a number is written as such, digit reverse(num), while (num>0) then, digit =num%10. This particular algorithm divides a number by 10 until the original number from the LSD is found.