Thread: Algorithm for most frequently used item?

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    Algorithm for most frequently used item?

    Basically I need the algorithm similar to WinXP start menu which display the most frequently used programs. Is there any common algorithm for that floating around the net? Just give me the algorithm name and I'll do my own research

    thnx in advance
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yeah, we call it the for loop.
    Code:
    int array[SIZE];
    
    /* fill array here... */
    
    int x, highest;
    for( x = highest = 0; x < sizeof array / sizeof array[0]; x++ )
        if( array[x] > array[highest] )
            highest = x;
    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    You want me to compare the count of each item has been used? It's not gonna work well because say I used a program 1000 times then it will take the other items 1001 to replace the most used.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  4. #4
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    why not have somekind of a search tree structure (AVL for example) where they key would be the item and the value would be frequency of use. You just have to figure out some tie braking method and you should be set.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Then only keep a record to a certain point. For example, don't allow any program to be counted as having been used more than say, 50 times. Or have each use time out after a certain number of days - but that would require a lot more disk space.

  6. #6
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Quote Originally Posted by sean_mackrory
    Then only keep a record to a certain point. For example, don't allow any program to be counted as having been used more than say, 50 times.
    Then after 50 times all items will have the same position.???

    Quote Originally Posted by sean_mackrory
    Or have each use time out after a certain number of days - but that would require a lot more disk space.
    This one is what I've thought of the most. I have to reset something at some point.

    *posibility 1* reset all items' counts after say, 3 days, but then on the fourth day I have to make sure to use old-most-used items so that they won't be replaced.

    *posibility2* reset count of all items that haven't been used for the past 3 days. Sounds better, do you see any flaws?

    *or maybe other possibilities?
    Last edited by alphaoide; 07-20-2004 at 07:16 PM.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Keep track of
    1) The number of times used in the last X days
    2) The last time it was used

    If a program hasn't been used in Y days then consider it unused
    If a program has a higher per day usage in the last Z days then another program it is ranked higher.

  8. #8
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Quote Originally Posted by Thantos
    Keep track of
    1) The number of times used in the last X days
    2) The last time it was used

    If a program hasn't been used in Y days then consider it unused
    If a program has a higher per day usage in the last Z days then another program it is ranked higher.
    Oh, sweet, I'll just implement this one, just perfect for my need.
    Thanks
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 12:52 PM
  2. Retail Outlet Managment System - the 4th
    By Presidentofusa in forum C Programming
    Replies: 3
    Last Post: 11-10-2007, 10:44 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM