d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Coding Irc Bot In Java
Prev12
Add Reply New Topic New Poll
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jan 19 2013 12:53am
what kind of class teaches binary trees before arrays? o.O
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 19 2013 01:01am
Quote (carteblanche @ Jan 19 2013 01:53am)
what kind of class teaches binary trees before arrays? o.O


well I know about arrays lol just not any super cool stuff with them. We barely touched 2d arrays and we didn't cover any of the interesting algorithms and stuff for arrays.

But I am starting the Java class this semester (the OOP class) so maybe they will teach more of that stuff there.
Member
Posts: 299
Joined: Apr 11 2010
Gold: 2,491.00
Jan 28 2013 12:23pm
Code

   private List<Player> matchmaker(List<Integer> elos, List<String> names) {
       List<Player> players = new ArrayList<Player>();

       for (int i = 0; i < elos.size(); i++) {
           Player player = new Player();
           player.elo = elos.get(i);
           player.name = names.get(i);

           players.add(player);
       }

       Collections.sort(players);
       return players;
   }

   private class Player implements Comparable<Player> {

       private Integer elo;
       private String name;

       @Override
       public int compareTo(Player other) {
           return elo.compareTo(other.elo);
       }
   }


This post was edited by PumblesMumbles on Jan 28 2013 12:23pm
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Jan 28 2013 01:56pm
Quote (Eep @ Jan 19 2013 12:01am)
well I know about arrays lol just not any super cool stuff with them. We barely touched 2d arrays and we didn't cover any of the interesting algorithms and stuff for arrays.

But I am starting the Java class this semester (the OOP class) so maybe they will teach more of that stuff there.


there's nothing special or interesting about arrays, other than how they are actually implemented by the language/machine.

in any case, trees are implemented using arrays anyway, so it's not like you can avoid arrays by talking about trees.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 28 2013 04:18pm
Quote (irimi @ Jan 28 2013 02:56pm)
there's nothing special or interesting about arrays, other than how they are actually implemented by the language/machine.

in any case, trees are implemented using arrays anyway, so it's not like you can avoid arrays by talking about trees.


we did our trees using pointers :o
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jan 28 2013 04:42pm
Quote (Eep @ Jan 28 2013 06:18pm)
we did our trees using pointers :o


same thing.

an array is a continuous block of allocated memory
a binary tree is a continuous block of allocated memory

all the pointer does is point to the beginning of those blocks.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 28 2013 11:42pm
Quote (AbDuCt @ Jan 28 2013 05:42pm)
same thing.

an array is a continuous block of allocated memory
a binary tree is a continuous block of allocated memory

all the pointer does is point to the beginning of those blocks.


ahh. I guess I have a bad conception of these things still.
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll