find more than one minimum

This is a discussion on find more than one minimum within the C Programming forums, part of the General Programming Boards category; Hey everybody, I'm wondering if there is any way to find the last 5 min from the input data in ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8

    Question find more than one minimum

    Hey everybody,

    I'm wondering if there is any way to find the last 5 min from the input data in a regular c program by using array.

    I got maximum, average ,and minimum.

    but, I'm looking for five minimum or as many numbers less than the average.

    thank you.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The same way you find the actual minimum. You scan through; if the number is one of the five smallest numbers so far, put it in the correct spot.

  3. #3
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    Posts
    111
    Just sort it, then select the members you want.

    Sorting it will also allow you to do other things more easily.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If you keep a sorted list of the X minimums, then you can compare with the "biggest minimum", and if it's less than that, then insert the new into the list (dropping the biggest one). That is O(n), so a bit better than O(nlogn) that a sort would be.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. How to find O of threads ?
    By jabka in forum C Programming
    Replies: 3
    Last Post: 03-11-2008, 12:25 PM
  3. ld.exe: cannot find -l-lstdc++
    By Tonto in forum Tech Board
    Replies: 3
    Last Post: 04-10-2007, 11:20 PM
  4. please help!...find and replace
    By amy589 in forum C++ Programming
    Replies: 26
    Last Post: 10-13-2006, 06:42 PM
  5. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 08:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21