Thread: find more than one minimum

  1. #1
    Registered User
    Join Date
    Oct 2008
    Uinted States

    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
    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
    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
    Farncombe, Surrey, England
    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.

    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, 09:28 AM