Another Sorting Question!

Ok, I already asked something like this, but I was unsure about what to do.
But now I know.
I want to create a linked list of items. each item has a String and an int.
in a different class, i want to create a linked list of these items, inserted in random order.
what i want to do is sort the list alphabetically by the String.
package political;
import java.util.Comparator;
public class Item {
     String s, state;
     int p, people;
     public Item (String s, int p)
          people = p; state = s;
     public String name ()
     {return state;}
     public void printer () {System.out.println(state + " "+ people);}
}

You mean you don't understand the arithmetic involved in dividing a given number into given ratios? Or the details of how the US electoral votes in particular are determined?
The latter will be described at Wikipedia I would guess.
The former is straightfoward. Suppose there were just three states with populations given by A: 100 B: 200 C:500 and you wanted to share 10 votes between them.
First determine the proportion of the entire population (100+200+500=800) that each state has. A: 100/800=0.125, B: 200/800=0.25 C:500/800=0.625.
Then multiply these by the number of votes to be shared. A: 0.125*10=1.25, B: 0.25*10=2.5, C: 0.625*10=6.25
So A gets 1 vote, B gets 2 votes and C gets 6 votes.
The problem is that there is one vote left over. I seem to recall reading years ago (when I was a student - over half a life time ago!) that the US has used different strategies at different times. To suit whoever could best stack the electoral authorities. You could argue that B gets the extra vote (because B's "left over" 0.5 is biggest) or that C should have it (because C's "left over" represents the largest number of people 0.25*500=125). Or you could come up with other algorithms. As I said Wikipedia is sure to document the currently used process.
Edited by: pbrockway2 on Jan 11, 2008 7:32 PM
This page has details:
http://en.wikipedia.org/wiki/United_States_Electoral_College
In fact the number of votes is determined by the number of Representatives and Senators each state has in the US Congress (except for DC which rides a bicycle).
It's the House of Representatives that is fixed in size (currently 435) dished out in proportion to the decennial census count. I can't find any details about the exact allocation of the "left over" representatives, the details of the process are apparently specified by the Reapportionment Act of 1929 and the Apportionment Act of 1941.
http://en.wikipedia.org/wiki/United_States_House_of_Representatives
http://en.wikipedia.org/wiki/Size_of_the_U.S._House_of_Representatives
Edited by: pbrockway2 on Jan 11, 2008 8:04 PM
There is a discussion of the apportionment problem beginning on page 32 here:
http://www.maths.sussex.ac.uk/Staff/JH/MIEL/MIELUpdated.pdf
The first method I described (give the extras to those with the highest decimal parts) is called "Hamilton's Method". George Washington vetoed this proposal in 1790: he didn't like the fact that Maryland (akin to state B) would get a representative that should have gone to Delaware (C).
Apparently no "paradox free" solution is possible (Balinski and Young's theorem).
The actual method used since 1942 - "Hill's method" - is described in detail.

Similar Messages

  • Sorting question over state...

    Hi there,
    Anyone know where you amend the over state / hover of an option in a sorting question ???
    Been looking in the object style manager but can't find it in there...
    Thanks in advance...

    You are talking about the partially transparent grey bar that appears when hovering over an answer in the Sequence type of questions. There is no style that can be customized AFAIK. It is not even changing with the included themes. Same is valid for the connecting lines in matching questions that are always black, color cannot be changed for them neither. It is a pity, would recommend you enter a feature request to be able to customize the color of both the hover bar and those lines.
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Lilybiri

  • Another newb question: multiple virtual servers

    Hi, I have yet another ignorant question. I have several unrelated web projects that I am working on, and I would like to be able to set up a virtual server for each one for testing purposes, such as: http://project1, http://project2, http://project3. Can someone tell me if this is doable, and if there are any tutorials/resources on this for someone who has 0 experience running a web serer? Sorry for being so ignorant!

    Yes, it is doable.
    You can setup virtual server either by IP or by name.
    If you have one IP, and want to set them up by name (ex. http://project1, http://project2, http://project3) you can do so easily with this type of configuration:
    <virtual-server>
        <name>mydomain</name>
        <http-listener-name>http-listener-1</http-listener-name>
        <host>*.mydomain.com</host>
        <document-root>/www/domain</document-root>
      </virtual-server>
      <virtual-server>
        <name>myotherdomain</name>
        <http-listener-name>http-listener-1</http-listener-name>
        <host>*.myotherdomain.com</host>
        <document-root>/www/myotherdomain</document-root>
      </virtual-server>
    ....The important part here is that
    a) all virtual servers share the same HTTP listener
    b) which virtual server serves the request depends on the $HOST request header send by the client. Sun Web Server does the matching for you. It will match $HOST vs. the virtual server's host attribute. Depending on which site you connect to the right virtual server will be used.
    c) if the $HOST request header does not match any of the virtual servers, then the default virtual server defined in the HTTP listener will be used.
    To create a virtual server, use the Admin GUI, access the configuration, and then add new virtual server. Or use the following CLI command.
    wadm> create-virtual-server --config=myconfig --http-listener-name=http-listener-1 --document-root=/www/docs/myserver.com --host-pattern=myserver.com --log-file=../logs/myserver.com-error_logs myserverHost pattern will be used for matching. Some of this elements might be optional.
    Hope that helps. And keep the questions coming :D
    Edit: Also check the documentation
    Using Virtual Servers in SJS Web Server 7.0

  • Another simple questions

    Hello friends:
    Another simple question: I need to learn things about Oracle on my desktop.
    My machine runs Windows 98. Oracle has some desktop product of its Database Line?
    For example: Oracle Personal?
    And Oracle Lite? What's the main difference between Oracle Personal and
    Oracle Lite?
    Thank You
    Gracias
    Ing. Pablo Romero
    CORDOBA ARGENTINA

    1. I didn't know the answer to your first question, but I googled it and it says the item is the in-call audio boost.
    http://forums.crackberry.com/f71/flag-icon-47659/
    2. isn't this setting determined by the carrier? So it's not a setting in the phone, but when you call in to your voicemail you can change your options?

  • Re: another build question! (sorry lol)

    Hi all
    right, after days and days of researching all the excellent articles on here ive had to write a post! So apologies for going over old ground
    Im going to build a new CS5.5 rig (having had a guts full of Apple and their FCPX fiasco its back to pc!)
    so although i appreciate the 990x o'c is prob best option, bang for  buck is leading me down the sandybridge i7 2600k o'c option on p67 mobo with 16gb of ram (option to take to 32 down the line when the chips are out)
    anyway, im sorted on chip mobo (msi big bang marshal p67), nivida 570 etc , its the drives im struggling on!! Im edit avchd video and some after effects, small amount of 3d, and in FCP i always transcoded everything to prores. Now on cs5.5 it looks like real time performance is possible with high end hardwear.
    So mobo, ram, and chip aside, my HDD config im unsure on, ive not really got the cash to go crazy with raid controllors etc, but understand need for seperate drives, etc and tbh might even go downt he cineform route as a prores alternative (prob avoiding hassles of drive speed with avchd)
    im thinking as the SSD's are now dropping in price and the ocz are producing these 500 mb r/w speed sata 6 120gb drives for a reasonable price, would 3 of these drives (one for os, one for media , one for scracth disk ) be a good set up or is it a waste of cash and should i raid 0 from bios/mobo?
    I appreicate that 120 gb drives for media etc are small, but i would take project media from another much large backup drive and just use the 3x ssd set up as working disks for editing & os? once project over, clear out drives to larger back up and start new project!
    Its either that or i go SSD as bootdrive, but some sort of cheap raid set up for my scratch disk, media drives? prob is if i do that, from what ive read (brain dead now) i would be best off with 2 x raid 0 as scratch disk and orginal media respectively when workign with avchd
    HOWEVER, on my mobo there are only 4 sata 6 ports, so if i use one for ssd boot drive, and then im left with 3 x sata 6 ports and another 4 x sata 3 ports to raid on? how does this work? any point in getting the sata 6 drives as one would be stripped with a sata 6 drive plugged into a sata 3 port (this was my reasoning behind using 3 small sata 6 ssd's plugged to the sata 6 ports  and rest of sata 3 ports as storage and backups!
    confused lol!! I just want the overclocked sandybridge system with decent gpu card, as much ram as possible at present, but im thinking my bottleneck will be in the HDD config! any suggestions are much appreicated! im not that techy so whilst have read all the articles am more confused now (plus normally a mac user, so its out of the box configuration usually!) for what its worth looking to purchase something from scan uk in terms of parts! total build cost including a reasonable screen £2,000
    many thanks

    You have a limited budget, especially in the UK, but then don't we all?
    Going for the 980X will triple the cost of the CPU, but even when editing AVCHD material the gains are not sizable enough IMO to justify that cost differential. Add to that you will need 24 GB instead of 16 GB and that carries an additional price tag. Both factors will easily move you out of budget range if you want to have a number of disks and possibly a raid controller.
    Did you read my article To Raid or not to Raid, that is the question. It can be found under the Overview tab at the top of the page? (Currently responding from abroad on my notebook and not having the bookmarks available for easy linking). http://forums.adobe.com/thread/525263
    With media and projects I would advise against a raid0, because of the lack of redundancy. For pagefile, media cache and previews (scratch disks) raid0 is quite OK. They will be recreated if needed. The performance gain from a raid0 for media and projects over a parity raid is easily offset by the time spent on making backups. For parity raids do not use WD Caviar Blacks, but look at the Hitachi 7K3000 line of disks.
    The question of Sandy Bridge versus the old X58 platform is essentially one of 'which limitations are acceptable to me'.
    The Sandy Bridge is a great processor and at least the equal to the old i7-9xx quad cores. However, the platform, the chipset, has its shortcomings in terms of PCIe lanes. Whether that is relevant to you, only you can decide. But hey, we would be in serious trouble if Intel did not manage some progress in two years time from the i7-920 to the i7-2600K. So of course the i7-2600K shows much more potential than the almost retired 920, it is the chipset for the Sandy Bridge that is 'flawed' in comparison to the X58, but that is no surprise, since the Sandy Bridge is a 'middle-of-the-road' platform and the X58 was a 'high performance' platform.
    BFTB-wise I think that within your budget limits, you should look at the i7-2600K, but with the best disk setup you can afford.

  • Another resolution question.....sorry

    Thanks to Zac and Bogie for helping me out with the whole resolution questions but I do have one more....sorry. Do I need to log and capture in FCP in order to import the file into compressor to change the codec or is there another way? Maybe direct from the camera so it doesn;t get any more compressed than it is?
    Thanks again for putting up with me
    Rick

    If you shot on DV, for example, capturing it isn't compressing more. It is what it is. You shot it DV, it is DV. What's on the tape isn't "better" than what gets captured to your hard drive.
    Anyway, yes, you have to capture or ingest the footage or have some sort of existing movie file to put it into Compressor. You can't take it from the camera directly.

  • Stacked Bar Chart with Multiple Series Sort Question

    Hi,
    Apex version 4.1.1
    I have a stacked bar chart with three separate series, one showing customer effort, another showing project effort and the third showing other effort, summarized by calendar week. The x-axis of the chart is the calendar "week of" date, and the y-axis has a bar for each of the three series. Not every type of effort occurs every week.
    When AnyChart renders the chart, the order of entries on the x-axis seems to be dependent both on which series are present in a given week as well as the "week of" date. Weeks with all three series sort in order by calendar date, followed by weeks where just the 2nd & 3rd series are present, followed by weeks where just the 3rd series is present. See this [url http://tinypic.com/r/b9zdt/6] picture of the chart  noting the "week of" dates. Note that the months go Sep-Oct-Nov-Aug-Oct.
    Is there a way to force AnyChart to sort the x-axis in chronological order regardless of whether there is data for all three series for a given week? I have looked through the AnyChart XML reference but cannot find a way to do this.
    Incidentally, I can solve the sorting problem by combining all three series into a single query:
    select
      null as link,
      week_of as label,
      sum(customer_effort) as "Customer Effort",
      sum(project_effort) as "Project Effort",
      sum(other_effort) as "Training, Admin and Other Effort"
    from ...But if I do this, I cannot figure out how to have each bar on a given week link to a different detail page, e.g., if I click on a bar representing customer effort I want to link to one page, but if I click on a bar representing project effort, I want to link to a different page. I have had a look at the [url http://apex.oracle.com/pls/apex/f?p=36648:59:1570983160946101::NO:::] chart examples  posted on apex.oracle.com, but cannot figure out how to apply to multiple series in a single query.
    Thanks,
    Mike

    Thanks, Jeff. I did try this but for whatever reason it doesn't make a difference. I think it is because if there's no data for a given series for a certain week, there is no entry in the data set that is sent to AnyChart.
    I was able to get around the issue by "filling in" the missing weeks from each data series. To generate the list of "Week Of" dates for a given date range, I used this code:
    select
         trunc (each_day) as week_of,
         0 as effort
    from (
         select
              (to_date(:p920_start_date,:app_date_format) + 2 - to_char(to_date(:p920_start_date,:app_date_format),'D') - 1) + level each_day
         from dual
         connect by level <= to_date(:p920_end_date,:app_date_format) - to_date(:p920_start_date,:app_date_format) + 1
    where
         to_char (each_day, 'D') = '2'This creates an effort entry of 0 for each week within the date range; I use the Monday date of a week as the "Week Of" date. I then union this with my actual data and summarize by week and viola, I get the weeks in order. This also has the benefit of showing a week for which there are no entries in any of the three series.
    Thanks for taking a look at this.
    Mike

  • Library Folder Panel Sorting Question

    Can the folder sort criteria be changed in the library module folders panel (Win LR V 2.2)?
    I have looked in the help and either I overlooked the instructions or they are not there. I did find out how to change the contents of the folder display but not the sorting of the display.
    My problem is that I use a folder hierarchy of c:\yyyy\mm\dd-subject and the folder display only sorts on the lowest folder in the hierarchy. Therefore, if I have two (or more) folder sets ending with 05-james they display one under the other even though the full folder path may be c:\2005\03\05-james and c:\2008\11\05-james. I would like the sorting to be on the entire path as is done in Photoshop Elements folder view.
    Thanks for any insights or help.
    Cliff

    I would agree with Lee Jay; if you have a parent folder, then everything in the folder hierarchy displays correctly, in numerical order (using your setting of c:\yyyy\). And it displays sub-folders in numerical/alphabetic order too.
    So if you right-click on your current folders and pick "Add Parent Folder" it should work. In your example, it will create a parent with just the drive letter C: and all your sub-folders should now be listed in correct order. If that does not work, just highlight the newly-created top-level folder, right-click and pick "Remove" and in the pop-up window click the "Promote sub-folders" button; that will get you back to where you were.
    Another option is to do it in Windows. Create a folder called, for example, Photos on your drive. Move all your photo folders into that folder. When you start Lightroom, all folders will be shown as missing, but the job of finding them is simple; a right-click on the missing folder and picking the pop-up menu item with words similar to "locate missing folder" will find your "missing" folders.

  • Sorting question xsl

    hi,
    I am sorting a list by category, but now I know that one of the categories should go to the bottom of the list when displayed.
    I tried concatenating some value to it so it would go to the bottom, but it's not working correctly. Any other ideas to achieve this?
    mhoran

    You are talking about the partially transparent grey bar that appears when hovering over an answer in the Sequence type of questions. There is no style that can be customized AFAIK. It is not even changing with the included themes. Same is valid for the connecting lines in matching questions that are always black, color cannot be changed for them neither. It is a pity, would recommend you enter a feature request to be able to customize the color of both the hover bar and those lines.
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Lilybiri

  • Another BW question about filter in the query definition

    Hi ,
    I have another question about filter in the query definition.
    <u>Question:</u>
    Which of the following objects can be filtered in the query definition?
    A. characteristic
    B. Key figure
    C. Structure
    D. Units
    E. Hierarchy
    My answer is A,B,D,E.
    The answer in the book is A,B,D
    Can anybody tell me which one is wrong?
    Thanks in advance,
    Liu Jia

    HI
    1.The answer could be A,B,D.you can not apply filters on hierarchies
    2.Whenever there is a change in Attribute data(like Location,Num etc...)that has to be reflected in all aggregates of the cube.Thsi can be done by running "ATTRIBUTE CHANGE RUN".
    sri

  • Playlist name sorting question

    First off, sorry if this has been discussed before, I couldn't find it anywhere.
    My question is, is there any way to sort my playlists via a "Sort Name" option or something so that a playlist starting with 'the' (for example, "The Letter Black") will be sorted, in the case of the example, under 'L' instead of 'T'? Thanks in advance.
    Blessings.

    Sorry, there are no controls about the sort order of playlists. They go folders, smart playlists, and regular playlists, with a lexical sort in each.
    However, you don't need to create playlists for individual artists and albums. You can easily get to them by the column browser. To turn it on, click View > Column Browser > Show. Then type "lett" in the search bar and you will be right there.

  • Yet another standby question...

    Hi gurus,
    Please help to resolve the quiz. I have completed manual physical standby installation. It is up and running. I then decided to install Grid Control and to use Data Guard for the standby creation. I've successfully installed GC, deployed all agents, I can see my previous standbys, life is good in short. Now, when I am trying to create the second standby for my production database using the Data Guard I stuck on a logical question:
    On the step 3 of Data Guard standby creation, there is a note, saying:
    The instance name (also referred to as the SID) must be unique on the standby host.
    Yeah, fair enough. But i can't understand what should I do next? I have:
    db_name YELLOW - primary prod
    db_name YELLOW - standby prod 1st
    and i need db_name YELLOW - standby 2nd
    But I can't create it on the same server where the first standby resides.. What options do I have? Do I need to create the second standby on another server? Do I need to kill 1st standby? Is there any way to avoid this conflict? I am confused. I have no equipment for TWO standby servers... I thought I can install there up to 9 standbys.. But it seems to be a problem.. And definitely, I cannot give my second standby other name than YELLOW as all my applications are strongly tied on db_name...
    Friends, please clarify this if you can. I am kinda lost in here..
    Thanks as usual,
    Maria

    well, that's a good question! :)
    because I don't have spare server for the standby. the question is not about: 'should I or should not put more than one standbys in one server' , but more about: 'is there any way to put two standbys with the identical db_names in one server'. I know that I probably sound unprofessional, but I just wanna know.. If the answer is 'no way', I will kill the first standby then and recreate the second one using DG with the correct name.
    Thanks for writing to me,
    M.

  • Another transparency question. CLARIFICATION NEEDED

    OH experts -- you who are unknown and unseen-- please know you are so appreciated!!
    so, here's the question
    have master pages set up with a picture, a screen over the picture in a certain spot.
    on regular pages i place my text on that transparent screen. When printing from my small printer at home, my type & graphics are looking screened; less than 100% of their ink value.
    how can i get these graphics/type to be ON TOP of the slightly transparent layer and print 100%??  why are they printing less than 100% when on the screened box from the master page? a
    rent graphics on master pages underlying?
    do they affect the graphics on top of them in the regular document???
    tia

    thanks for the info. its hard to be exact in describing what is going on!
    But after lots of testing, i've narrowed it down to some sort of print/color settings within my programs AI & Indd -- not a problem with the files. SO -- FOR THAT i'm glad!
    illustrator and indesign are printing my colors in a very muted fashion. Not black, but gray -- and a screened back color for every color.
    other programs print pages fine -- dark blacks and vibrant colors.
    SO -- as long as i know its not my file --  I can at least get through this project. -- i have a long line of things to figure out when i'm finished!
    thanks for your ideas earlier; i'll keep in mind how to use the picture within these forums.

  • Collections.sort question

    Hi,
    This is my question. I have the following classes
    class A {
         int num = 1;
    class B extends A implements Comparable<B>{
       int count = 0;
       public int compareTo(B b) {
            return count - b.getCount;  
      public void setCount(int count) {
            this.count = count;
      public int getCount() {
             return count;
    }After i put the a couple of the B classes (after setting count) in a LinkedList of type A, i get a problem trying to sort them. The compiler gives me a variable Collections error on the Collections.sort
    Any ideas on how to solve this would be appreciated.
    Thanks

    Are you talking about this A* algorithm? (I've never heard of it before.)
    http://en.wikipedia.org/wiki/A-star_search_algorithm
    The code you have with the "instanceof" test might work. Not sure what the goal is, or how the algorithm works (I didn't read the above link in detail), so I can't say for sure whether it will "work" for what you are doing. Once you sort the "B" objects, what do you need to do with that sublist (i.e., with the bList in your code)?
    I've never used generics, so I don't know much about them. Is it possible to make "A" Comparable, giving a dummy implementation to compareTo (i.e., maybe even just make it always return '0' [all values are equal]), and then have "B" implement Comparable such that B's compareTo will override A's version? I don't know if it is possible (or even desirable)--just a thought.

  • Another Noobie question - readLine()

    Hi all
    This is another one of the extreme noob questions. I wrote a small program to read form a text file
        String NetworkLine = new String();
        try{
            FileReader inputFile = new FileReader("Test.txt");  //
            BufferedReader in = new BufferedReader(inputFile);
           try{
               while (in.readLine() != null){
                NetworkLine = in.readLine();
                System.out.println(NetworkLine);
           }catch (IOException e){
                System.err.println("Error in reading the file");
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }My Test.txt is
    One
    Two
    Three
    Four
    Five
    Six
    without the *
    The output I get is
    Two
    Four
    Six
    I cannot figure out why only even no. lines are being read. I inserted a breakpoint at the line
              System.out.println(NetworkLine);This shows me that only even no. lines are being read by readLine(). Any help will be appreaciated.
    Thanks
    Ayesha

        String NetworkLine = new String();
        try{
            FileReader inputFile = new FileReader("Test.txt");  //
            BufferedReader in = new BufferedReader(inputFile);
           try{
               while (in.readLine() != null){  // <-- This reads a line, checks it for null ,and drops it
                NetworkLine = in.readLine(); // <-- this reads the next line
                System.out.println(NetworkLine);
           }catch (IOException e){
                System.err.println("Error in reading the file");
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }So the upshot is that you print every other line.
    Corrected:
        String networkLine = new String();
        try{
            FileReader inputFile = new FileReader("Test.txt");  //
            BufferedReader in = new BufferedReader(inputFile);
           try{
               while ((networkLine = in.readLine()) != null){
                System.out.println(networkLine);
           }catch (IOException e){
                System.err.println("Error in reading the file");
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }

Maybe you are looking for