Finding top five number in an array of arraylists.

I have to write a method with a heading
public static int [] findTopFiveMostSteps ( ArrayList [] temp )i will input an array of arraylists, and I have to write this method
that will return a integer array containing the top five number in that
array of arraylists.
I have no idea how to go on about this
please help

How would you do it "manually"? That is, if you just
had pencil and paper and several lists of numbers,
what would be the steps? Keep them very simple and
precise.Socrates would be so proud.
I was just reminiscing about how I once tried to teach Java to the web designer
at my last job. I gave him the task of writing:
static int max(int[] values) He just didn't grok it:
Me: How would you figure it out by hand?
WD: I'd look at the numbers and pick the biggest.
Me: Break that down into steps.
WD: I'd -- look -- at -- the -- numbers -- and -- pick -- the -- biggest.
In the end, we tacitly agreed to stop the teaching and hope the manager didn't notice.

Similar Messages

  • Finding the minimum number greater than zero in an array

    Hi All,
    I have an Array (Attached). I need to find the minimum number that is NOT zero.
    Using the Array Max & Min returns 0 as the min. What I want is the next minimum number.
    Thank you.
    D
    Attachments:
    Array.jpg ‏72 KB

    Do you also need the position of the found element? What if several numbers have the same minimum value?
    If you just want the value of the smallest nonzero element,  here's what I would do. All you neet to do is retain is a single number.
    This assumes that your zeroes are really zero. With DBL you never know.  
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SmallestNEZero.png ‏20 KB

  • How do I find the total number of elements in a multi dim array

    How do I find the total number of elements in a single or multi dim array?
    For example, a 2x3 array has 6 elements, and a 2x3x4 has 24. How do I compute this very easily - is there a single VI that does this?
    David
    Solved!
    Go to Solution.

    Use "array size" (array palette) followed by "multiply array elements" (numeric palette)
    (Works also equally well for 3D arrays and higher)
    For a 1D array, just use "array size".
    Message Edited by altenbach on 02-05-2009 05:57 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    NumberOfElements.png ‏3 KB

  • Finding the 25th largest number in an array

    How would I say find the 25th largest number in an array?
    Or nth largest number?
    Chris

    I find most of these answers correct, but without previous knowledge of the size of the array, I would do things differently.
    In the enclosed VI, a cluster is formed of all array values and their index. When the array is then sorted, the first cluster element is used as the first sort criterium, then the second cluster element. This allows a single array operation (Sorting) to take care of any searching, whilst the cluster retains the index of the original array.
    Coupling this method with an unitialised shift register, you can also cache the sorted array to allow for more rapid processing if you require more than a single indexed value.
    Another way to achieve this is (Assuming you`re seeking the 25 largest) to simply get the max and min at t
    he very beginning, feed the array into a loop with a shift register, set the value at the index returned for max each run to the initial min value -1, and repeat another 24 times.
    Regarding memory use and execution speed, I`m not sure if searching an array 25 times is quicker than a single sort or not (No new array is created), but both versions are viable.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Get_Nth_largest-smallest_(6.1).vi ‏31 KB
    Get_Nth_largest-smallest_(6.1)_-_version_2.vi ‏42 KB

  • AV - Top Five Audit Sources by Number of Alerts - INTERNAL ERROR

    Hi again!
    We have one problem with audit vault console while connecting with auditor role.
    There's one strange problem that occurs intermitently when clicking on "Top Five Audit Sources by Number of Alerts " graph on audit vault home page.
    Sometimes it works perfectly and maybe next time it produces an internal error. It does not follow any logic. Maybe it works 1,2,3,... times and next one it doesn't and the links carriess you to an empty page with "INTERNAL ERROR" message.
    It is something related with the url.
    When you place the mouse coursor on the graph you can see the url at the bottom of internet explorer/firefox.
    It's something like this: (it works)
    http://<av hostname>:5707/av/console/database/avt/:::::P2_REPORT_TYPE,P2_DATE_TYPE,P2_SOURCE:WARNING_ALERT,DAY,<source name>
    then you continue working come back to home page and place the cursor again on it. Then sometimes you see the same url(all it's going to work) or the next one:
    http://<av hostname>:5700/av/console/database/avt/:::::P2_REPORT_TYPE,P2_DATE_TYPE,P2_SOURCE:WARNING_ALERT,DAY,<source name>
    As you can see port number has changed misteriously... and it does not work.
    The strange thing is that after the error i try to open a new auditor session with another explorer and it some times it works!!! until same thing happens.
    Has anyone seen anything like this????? I don't know if it something about Audit Vault configuration, a bug or an internet explorer configuration issue.
    i've tried different languages with my explorers and it continues happening ...
    All the rest of the parts of the application work perfectly
    Thanks!

    Whenever posting here ALWAYS include full version number.
    Whenever posting an error post the full and complete error message (not your interpretation of it). "INTERNAL ERROR" in and of itself is meaningless.
    I would suggest that you open an SR at metalink.

  • Code for find the missing number in array without sorting/comparing in java

    Hi all,
    We have 1 to 100 number in an array, but one number is missing (from 1 to 100). we have to find it out without sorting or comparing of this missing number in array.
    please help me out to find the solution this query.
    regards & thanks
    Mohan Kumar
    Bangalore,
    India

    Maybe you could sum up the numbers you've got in your array and subtract the result from 5050 [the term [code](N*N+N)/2 where N is your upper bound (i.e. 100)]. You'll get the sum of all missing values (which in this case would be exactly the missing number). n.b. that you could genaeralize on that for arbitrary finite series.
    Kind Regards,

  • Finding the smallest value from an array

    Hi there :)
    I started learning Java a few days ago and have now run into my first problem :p
    I am using Netbeans on Mac OS X.
    I need to find the smallest value from an array. So far I've had no luck. Any suggestions would be fantastic.
    The code so far:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
            int O = A.length - 3;
            int B = A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7] + A[8] + A[9] + A[10] + A[11] + A[12] + A[13] + A[14];
            A[15] = B;  // Stores the sum of the integers in A[15]
            int C = B / O;
            A[16] = C;  // Computes and stores the average in A[16]
            int D = 101;
                if (A[0] < A[1]) { D = A[0]; }
                else { D = A[1]; }
                if (A[1] < A[2]) { D = A[1]; }
                else { D = A[2]; }
            System.out.println("There are " + O + " numbers in the Array");
            System.out.println("Those numbers add up to " + B + ".");
            System.out.println("The average of those numbers is " + C + ".");
            System.out.println("The smallest value in the array is " + D + ".");
    }The code is incomplete, but it works so far. The problem is I know there must be an easier way. SAVE ME :)

    OK :)
    Just thought I should show you the output as to help anyone else with the same problem:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17                           // COMPLETED
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    import java.util.Arrays;
    public class Main { 
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
         public static void main(String[] args) {
                  int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
              Arrays.sort(A);
              System.out.println("The smallest value in the array is " + A[0] + ".");
              int num = A.length;
              System.out.println("There are " + num + " values in the Array.");
              int sum = 0;
              for (int i = 0; i < A.length; i++) {
                   sum+=A;
              System.out.println("Those numbers add up to " + sum + ".");
              double d = (double)sum/num;
              System.out.println("The average value of those numbers is " + d + ".");
    What Iearned:
    1) How to create for loops properly
    2) How to import java.util.Arrays ( =D )
    3) How to get a more accurate average using double instead of int
    4) This forum is the best and has very helpful people 24/7 ( =D)
    Thanks Again,
    Mo.

  • FW: [Adobe Reader] I want my credit card information to be removed from Adobe's file and I can't find a phone number to contact someone in your company, how come, please help!  Lucie

    What a dumb answer, the payment is done and charged already,
    ADOBE DOES NEED MY CREDIT CARD INFO ANYMORE, PLEASE REMOVE IT
    FROM YOUR DATABASE AS I CANNOT DO IT MYSELF.  It is quite annoying
    to be controlled like this, please confirm that my request has been answering
    with intelligence please.
    Lucie Lévesque
    Date: Mon, 8 Dec 2014 08:09:59 -0800
    From: [email protected]
    To: [email protected]
    Subject:  I want my credit card information to be removed from Adobe's file and I can't find a phone number to contact someone in your company, how come, please help!  Lucie
        I want my credit card information to be removed from Adobe's file and I can't find a phone number to contact someone in your company, how come, please help!  Lucie
        created by Bernd Alheit in Adobe Reader - View the full discussion
    Adobe needs the credit card information for the payments.
         If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/6995243#6995243 and clicking ‘Correct’ below the answer
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/6995243#6995243
         To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
         Start a new discussion in Adobe Reader by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

    Adobe Reader is a FREE program, so you would not enter a credit card
    If you have a subscription to a PAID program, removing your credit card information would cause that program to stop working when you stop paying for your subscription
    If that is what you want, here is the information on how to cancel
    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • How do I find the model number on my keyboard?

    How do I find the model number on my keyboard? I have an anodised aluminium (short with no numeric pad on it) keyboard that came with my iMac that I bought in 2009, and I am wanting to find out what model it is.
    Any suggestions?
    Thanks.

    Many of the Apple keyboards have the model number on the underside, often in very tiny grey print that is really, really hard to read
    You can also go to the Apple symbol in the top left corner of your screen, drop down to About this Mac, then click more Info and navigate to the the hardware information about the interfacing equipment.
    If you have your original order information from purchase, it may list each item you received with model/part number.
    Ralph

  • How do i find the model number on my macbook?

    how do i find the model number on my macbook?

    Click the Apple at the top left and select More Info or System Report depending n which version of OS X you're running. Select and copy the serial number and paste it here http://www.everymac.com/ultimate-mac-lookup/ and you'll find complete specs for your MacBook.

  • Where do i find the reference number for my preorder? and yes i no this is prob a dumb question but i cant find it anywhere......

    Where do i find the reference number for my preorder? and yes i no this is prob a dumb question but i cant find it anywhere......

        Hi droidboy52999,
    Your email won't have the same confirmation number as it was ordered over the phone. You will need the last name used for the order, the location code (this ends in 01) and an order number (five to six digit number). Please keep us posted if you need further assistance with this.
    Thank you,
    MariaC_VZW
    Please follow us on Twitter @VZWSupport

  • Where can i find the TRACKING NUMBER on my macbook pro?

    before i bought my mbp, i was told that i should write down its tracking number in case it got stolen. where do i find it?

    Hi there - are you sure they (whoever that is) asked you to keep track of the Tracking number? Do you think they meant the Serial Number?
    You can find the serial number of your MBP by clicking on the apple icon at the top of your menu bar, and go to About this Mac, then you can click on more information, which will give you the serial number of your macbook pro.
    PS - in terms of safeguards for stolen macs, you might want to do a search on the forum discussion related to this issue (stolen or lost) . . .
    Message was edited by: belovedjs

  • Maximum five values in 2d array

    Hi, I have a vi that reads in values from a 2D array and then uses this information. I am currently using the "Array Max & Min" vi to find the maximum values from the array. It may be beneficial for my application to find the maximum 5 or some other number of values in the array. My current plan is to use a loop that finds the maximum value from the original array and then subtract that value and repeat the operation 5 or so times. However, I believe this is innefficient and may take a long time in a vi that needs to run fairly quickly. I would appreciate some suggestion. Thanks in advance.
    Solved!
    Go to Solution.

    Hi,
    In my case, I need to find peak values in the 2D array that, usually, are not the biggest values in the array. For example, in the color map below, I need to get the peak values that are isolated from each other. Any ideas?
    Thanks in advance.
    Attachments:
    color map.jpg ‏45 KB

  • I bought a new laptop and tried to reinstall Photoshop elements 11. I saved the original packaging and everything inside(or so I thought). I can't find the serial number anywhere.what if anything an I do?

    I bought a new laptop and tried to reinstall Photoshop Elements 11. I saved saved the original packaging and all contents (or so I thought). I can't find the serial number anywhere. Any thoughts on what I can do?

    If you originally registered your product the serial number will be stored in your Adobe account. Click the red logo (top left on this web page) sign-in, and then click the Manage Account button. It should be possible to browse your purchase history. You are looking for a 24 digit number commencing 1o57.

  • I cant find my serial number. Can someone help?

    I cant find my serial number for photoshop elements 11

    This is probably a question for the Elements forum or perhaps the Downloading and Installing forum, not the Creative Cloud forum.
    Is this the first time you’ve installed PSE11 (which is an older version) so wouldn’t still be for sale, or did you have it installed somewhere else, prior, or are planning on installing it somewhere else?
    How did you purchase PSE11?  Online from Adobe, a boxed version from Adobe, online from someone else, a boxed version from a brick-and-mortar store?
    If you purchased from Adobe and/or registered it, then the serial number should be online at Adobe.com and then under the items you can see by hovering over your name at the top right.

Maybe you are looking for