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

Similar Messages

  • Finding the most common value in an array of enums

    Hello,
    I'm looking for an elegant way of finding the most common value in an array of enums
    My enum being:
    0 - Close
    1 - Open
    2 - Undefined
    For instance, if my array contains:
    Close, Close, Open, Close, Close, Open.
    The most common value would be "Close"
    I have created a very customized VI that allows me to obtain the desired result, but I'm really not proud of doing it this way, simply because I would have to modify it if I were to add a new value to my enum...
    If someone can share some ideas to enlighten me, I would REALLY appreciate it.
    Thanks in advance!
    Jorge
    Solved!
    Go to Solution.

    Here is the variant using the search method. This method will run N-1 times where N is the number of ENUM elements. Yes, it is a bit more complex than the brute force method but it would execute fairly quickly. The sort would probably be the time consuming task.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    ENUM Counter.vi ‏14 KB
    Enum.ctl ‏4 KB

  • Find - tables with largest number of records?

    Hi,
    I need to find tables with largest number of records. Any transaction show this details?
    aRs

    Go to transaction DB02,  then click on the button that reads,  "Space Statistics", the dialog box, click ok, leave the "*" for all tables,   In the next screen put your cursor in the appropriate column labeled as Rows and click the sort button.  Now you will see your biggest tables at the top of the list.
    Regards,
    Rich Heilman

  • Finding the first unused number in a column

    I am attempting to write a single SQL statement that can find the first unused number for a column. For example, for a column called BLOCKID, that contains these values...1,2,3,4,6,7,8...I would like to be able to insert a record with BlockID equal to 5. I can do this by writting a loop, but that seems quite inefficient (may have to loop hundreds of times or more to find the first available hole).
    Any ideas? Thanks, Kieren
    null

    Here's one way
    1. Get a list of row numbers for the table
    2. Add an item to the list for 1 more than the largest id
    3. Remove from the list all numbers already used
    4. Use the smallest value of the list that is left.
    As a query this would be:
    SELECT MIN(BLOCKID) FROM
    (SELECT MAX(BLOCKID) + 1 BLOCKID
    FROM mytable UNION ALL
    SELECT ROWNUM BLOCKID
    FROM mytable MINUS
    SELECT BLOCKID FROM mytable
    Needless to say there should be a primary key or index on the BLOCKID column of 'mytable'.
    Good luck!
    null

  • Where can I find the latest version number in a document in the web? so I can download it with wget to check if the current installed firefox version is up to date and update ir if necessary?

    My problem is that I can't find the latest version number in here http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest/win32 as a document, so I can check against "HKLM\SOFTWARE\Mozilla\Mozilla Firefox\CurrentVersion" and update or not, all this is done by a script. It will be great not have to change the versión number in the script every time there is a new release.
    Thanks

    I think I solved, all I have to do is this:
    //here I download the entire page
    wget.exe http://www.mozilla.org/en-US/firefox/all.html -O index
    //here I search for the word curVersion and set a variable with the result, which is "10.0.2"
    for /f "tokens=3 delims=</> " %%A IN ('type index ^| FIND /I "curVersion" ' ) do set latestversion=%%A
    //here I just make sure I get a number
    echo "%latestversion%"
    pause
    Later I check it against the registry and voila! I hope this can help other admins who have the same problem.
    Regards.

  • Where does one find the product serial number?

    Where does one find the product serial number to enter and get a "Generate a response code" to finalize the license if the computer has no internet access?  I went to "Help>System Info" entered that number and it came up short of numbers.

    Find your serial number quickly

  • Where do I find the Group account number in SAP system

    Hi All,
    I have the same problem. I work in a company where all was installed and configured before my arrival and so I always need to do a lot of research to solve a problem.
    I tried somedays ago using txcode FS00 to create a new GL account but got stocked because the system requested a Group Account Number (Consolidation data in Charts of Accounts).
    I do not know where to find this number in the system. After a very long search, I have given up searching and hereby ask for your help.
    Can anyone tell me where to find the Group Account Number in the system. Is there a txcode for this? I tried already OBD4.
    As I am new in the SAP world, a step by step explanation will be appreciated.
    Many thanks in advance

    Hello aolowu
    Group Account Number field has lot of year/period end ramifications. Here is the definition " When you define the balance sheet and PL structures, then accounts are assigned to line items within the balance sheet and PL. This assignment is made either via the G/L account number or alternatively via the group account number given in this field. The usage of the group account number offers the advantage that by specifying a number, a group of accounts can be assigned immediately to the balance sheet or P+L item".  Suggest you work with a FI guy.
    To quickly get over however, you can enter the same number that you are creating in that field. At my current client, I have seen several accounts set up like this, although many of them have a different number there.

  • FM to find the purchase document number

    Hi All,
    Is there any function module to find the purchase document number from plant and material?
    regards,
    nirmal.

    Hi Naveen,
    Thanks for your quick reply. I have another requirement in which i need to fetch the standard price of a material from last 3 months invoice receipt. Is there any BAPI or FM which is used to accomplish this task? Thanks in Advance..
    Regards,
    Nirmal

  • Where can I find the WEP password/number stored on my mac

    Where can I find the WEP password/number stored on my mac.?

    Assuming you saved it it will be in your Keychain (Applications > Utilities > Keychain Access)
    Regards,
    Shawn

  • Where do i find the case id number

    hi im looking to find the case id number but i cant find do you kno where i can find it on the router

    Which Case ID you are refering ? Are you Looking for the Serial number of your Router ? To locate the Serail Number of your Router, Flip your router upside down and below the Linksys logo you will find the Serail Number of the Router.
    To find out your Case ID or the Reference number you need to call Linksys tech support, I think you will find that information with them.

  • Where do i find the warranty agreement number?

    Where do i find the warranty agreement number?

    If you purchase a notebook you have a simple 12 month warranty.
    But after notebook registration you will get additional 12 month extended warranty.
    Everything what you have to know you will find on this page under Service:
    http://eu.computers.toshiba-europe.com/

  • HT4061 How do I find the Device IMEI number for an iPad Mini?

    How do I find the Device IMEI number on an iPAD Mini?  It was not on the packaging or the back of the device.

    Settings > General > About

  • How do you find the iPad phone number for cellular data?

    How do you find the iPad phone number for cellular data?

    I know this post was a long time ago but people still seem to be viewing it.
    Quickest way:
    Via the iPad on 3G, go to http://m.telstra.com. The service number is then displayed and you are given the option to recharge.

  • Where can I find the original serial number? I have only one number indicating it's an upgrade when I try to reinstall LR 5 to my other computer

    Where can I find the original serial number? I have only one number indicating it's an upgrade when I try to reinstall LR 5 to my other computer

    You might be able to find the serial number for the older version of Lightroom thru your Adobe account online if you registered it when you installed it.

  • How do I find the Marketing Part Number for iLife '11 so I can register the product

    I want to register my iLife '11 but I can't find the Marketing Part Number as I only have the disk.  How can I find this number so I can reqister my copy?
    Thanks

    You don't need to register iLife.  Registeing iLife would get your just emails from Apple regarding their products.  It's not needed.  Anyway, the iLife 11 boxed disc is now a discontinued and unsupported product.
    OT

Maybe you are looking for