Results 1 to 2 of 2
  1. #1
    marcosol is offline Member
    Join Date
    Feb 2012
    Posts
    17
    Rep Power
    0

    Default retrieving the ith heaviest item in constant time

    Hi
    I have a person class. A person can carry items(saved in a possesions collection<Item>). All Items have a weight. The person class should provide a method to retrieve the ith heaviest item in constant time. What collection type should I use to save these items? I figured the index has to be connected to the weight in a way.
    Thanks!

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: retrieving the ith heaviest item in constant time

    I suggest using a sorted ArrayList.

Similar Threads

  1. Constant scrolling background
    By mwr1976 in forum Java 2D
    Replies: 5
    Last Post: 04-13-2012, 08:32 AM
  2. Cannot use as static constant
    By KiranA in forum Eclipse
    Replies: 1
    Last Post: 12-01-2011, 10:19 AM
  3. Constant Variables
    By harshakantha in forum New To Java
    Replies: 3
    Last Post: 06-13-2011, 08:51 AM
  4. constant variables questions
    By sgthale in forum New To Java
    Replies: 3
    Last Post: 05-06-2011, 06:34 AM
  5. static constant and performance
    By felixtfelix in forum New To Java
    Replies: 2
    Last Post: 08-31-2010, 02:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •