answersLogoWhite

0


Best Answer

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

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Design an algorithm for finding the maximum in a set and position?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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


Write algorithm compute sum of square of N numbers?

1. Design an algorithm to compute sum of the squares of n numbers?


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