Final Assignment for CS310 Fall 2010

Let's start working on the Assignment.

It says that You will create a class to represent Trees, and a Map class that is implemented using a chained hash table.

And it also says that You will write a simple application that performs queries on family tree (genealogical) data.

Where should I gat started????

/* 
<span style="font-size:x-large;">This is the list what professor gave us</span>.

<span style="color:#0033FF;">* Class Tree<T></span>

*1295476711*Class Node<T>
import java.util.*;

/**
 * Represents a node of the Tree < T > class. 
 */
class Node < T > {

    // a data object of type T
    public T data;
    // a List < Node < T > > of children nodes
    public List<Node<T>> children;
    // a reference to this node's Node < T > parent
    public Node<T> parent;
   
    /**
     * Default constructor
     */
    public Node() { }
 
    /**
     * Constructor for creating a Node<T> with an instance of T.
     * @param data an instance of T.
     */
    public Node(T data) { }
     
    /**
     * Return the children of this node
     * @return List < Node < T > > of the children 
     */
    public List < Node < T > > getChildren() { 
  // if there are no children then the returned List is empty
  
    }
   
    /**
     * Return the parent of this node. 
     * @return parent Node<T>
     */
    public Node < T  > getParentNode() {}

    /**
     * set the parent of this node. 
     * @param parent of this Node < T >
     */
    public void setParentNode(Node < T > parent) {}
    
    /**
     * Returns the number of immediate children of this node.
     * @return number of immediate children.
     */
    public int getNumberOfChildren() { 

    }
     
    /**
     * Adds a child to the list of children for this node. The addition of
     * the first child will create a new List < Node < T > >.
     * @param child a Node < T > object to add.
     * @return the Node < T> with added new child.     
     */
    public Node<T> addChild(T child) { }
    
    /**
     * get a child from the list of children for this node. 
     * @param child T to get.
     * @return the node < T > of the child.   
     */     
    public Node<T> getChild(T  child) throws ChildNotFoundException { 
 
    }    

    /**
     * Remove a child from the list of children for this node. 
     * @param child T to remove.
     */     
    public void removeChild(T  child) throws ChildNotFoundException { 
      
    }

    /**
     * Return the data of this node. 
     * @return T data object of this node
     */  
    public T getData() {}
 
    /**
     * Set the T data object of this node. 
     * @parm T data object to set
     */
    public void setData(T data) { }
     
    /**
     * Return a String representation of the node, this includes the T data objects
     * of this node and its children, and the parent of this node. (See output from main().)
     * @return String representation of the node
     */
    public String toString() {    

    }
    
    public static void main(String[] args) {
     System.out.println("Build Tree");
     System.out.println("  0  ");
     System.out.println(" / \\ ");
     System.out.println("1   2");    
     System.out.println("|   |");
     System.out.println("3   4");     
     
     Node<Integer> n0 = new Node<Integer>(new Integer(0));
  Node<Integer> n1 = n0.addChild(new Integer(1));
     Node<Integer> n2 = n0.addChild(new Integer(2));    
     Node<Integer> n3 = n1.addChild(new Integer(3));    
     Node<Integer> n4 = n2.addChild(new Integer(4)); 
  System.out.println();
  
     System.out.println("Display Tree");
     ArrayList<Node<Integer>> nodeArray = new ArrayList<Node<Integer>>();
     nodeArray.add(n0);nodeArray.add(n1);nodeArray.add(n2);
     for (int i=0; i<3; i++) {
      Node<Integer> node = nodeArray.get(i);
      int numChildren = node.getNumberOfChildren();
      System.out.println("Child " + node.getData() + " has " + numChildren + (numChildren>1?" children: ":" child: "));
      List<Node<Integer>> L = node.getChildren();
      Iterator iter = L.iterator();
      while (iter.hasNext()) {
       Node<Integer> child = (Node<Integer>) iter.next();
       Integer childData = child.getData();
       Node<Integer> parent = child.getParentNode();
       Integer parentData = parent.getData();
       System.out.println("Child " + childData + " of parent " + parentData);
      }
      System.out.println();
     }
     
     System.out.println("Test toString on n0: ");
     System.out.println(n0);  
     System.out.println();
     
     System.out.println("Test removeChild: remove child 4 of 2 and child 2 of 0:"); 
     try {
      n2.removeChild(new Integer(4));
      n0.removeChild(new Integer(2));
       System.out.println(n0); 
       System.out.println(n2);
       System.out.println();
  } catch(ChildNotFoundException e) {
    System.out.println("removeChild fails");
    }    
      
    System.out.println("Test getChild:");  
      try {
       n1 = n0.getChild(new Integer(1));
     System.out.println("getChild(1) passes");        
    } catch(ChildNotFoundException e) {
    System.out.println("getChild fails");
    }    
      try {
       n2 = n0.getChild(new Integer(2));
    } catch(ChildNotFoundException e) {
     System.out.println("getChild(2) passes"); 
    }
    System.out.println();
      
     System.out.println("Test setData: setData of n1 to 11:");        
      n1.setData(new Integer(11));
      System.out.println(n1);
   }
}

*1295476712*Class ChainedHashTable
import java.util.*;

public class ChainedHashTable <T > {
    private static final int DEFAULT_TABLE_SIZE = 101;

    /** array of Lists. */
    private List<T> [ ] theLists; 
    
    // number of elements in hash table
  private int currentSize;
  
    /**
     * Construct the hash table.
     */
    public ChainedHashTable( ) { }

    /**
     * Insert into the hash table. If the item is
     * already present, then do nothing.
     * @param x the item to insert.
     */
    public void insert( T x )  {  
    // use doHash(x) to get the hash code for x

    }
    
    /**
     * Find an element in the hash table. Return a reference
     * to the item if it is present; otherwise, return null.
     * @param x the item to find.
     */
    public T find( T x )  {  }    

    /**
     * Remove from the hash table.
     * @param x the item to remove.
     */
    public void remove( T x ) {  }

    /**
     * Determine whether an item is in the hash table.
     * @param x the item to search for.
     * @return true if x is found.
     */
    public boolean contains( T x ) {  }

    /**
     * Make the hash table logically empty.
     */
    public void makeEmpty( ) {  }
    
    /**
     * return the number of elements in the hash table.
     */
    public int size( )  {  } 
    
    /**
     * return true if the hash table is empty.
     */
    public boolean isEmpty( ) { }     
    

    private int doHash( T x )
    {
        int hashVal = x.hashCode( );

        hashVal %= theLists.length;
        if( hashVal < 0 )
            hashVal += theLists.length;

        return hashVal;
    }
    
    public static void main( String [ ] args )
    {
        ChainedHashTable<Integer> Table = new ChainedHashTable<Integer>( );

        for( int i = 0; i < 10; i++ )
            Table.insert( i );
            
        boolean allFound = true;
        for( int i = 0; i < 10; i++ ) {
          boolean T_F = Table.contains(i);
          if (!T_F) {
           allFound = false;
           break;
          }
        } 
        
        if (allFound) {
          System.out.println("insert() and contains() pass");
        }        
            
        allFound = true;
        int j=0;
        for( int i = 0; i < 10; i++ ) {
          Integer x = Table.find(i);
    if (j > 0) {
     System.out.print(", ");
    }  
    System.out.print(x);
          if (x == null) {
           allFound = false;
           break;
          }
          j++;
        }
        
        if (allFound) {
          System.out.println("find() passes");
        }
        
        for( int i = 0; i < 10; i++ )
            Table.remove( i );
            
        boolean foundAny = false;
        for( int i = 0; i < 10; i++ ) {
          Integer x = Table.find(i);
          if (x != null) {
           foundAny = true;
           break;
          }
        }  

        if (!foundAny) {
          System.out.println("remove() passes");
        }

   Table.makeEmpty();
   
   if (Table.isEmpty() && Table.size() ==0) 
      System.out.println("makeEmpty(), isEmpty(), and size pass()");
    }

}

*1295476713*Class MyMap
import java.util.*;

public class MyMap<KeyType, ValueType> {
 public MyMap() {
  items = new ChainedHashTable<Entry<KeyType,ValueType>>(); 
 } 
 
 /* map key to value. Create a new (key,val) Entry and store it in the ChainedHashTable. */
 public void put( KeyType key, ValueType val ) { 

 } 

 /* get the value that key is mapped to by retrieving the Entry from the ChainedHashTable. */
 public ValueType get( KeyType key ) { 
 } 

 /* return true if the map is empty; otherwise, return false. */
 public boolean isEmpty() { 

 }
 
 /* return the size of the map */
 public int size() {

 }

 /* make the map empty. */
 public void makeEmpty() { 
 
 }

 private ChainedHashTable<Entry<KeyType,ValueType>> items; 

 /* An Entry is a (key,value) pair */
 public static class Entry<KeyType, ValueType> {
 // Note: KeyType and ValueType should provide toString() methods
  private KeyType key;
  private ValueType val;
  
  Entry( KeyType k, ValueType v ) {
   key=k;
   val=v;
  }

  public int hashCode() {
   return key.hashCode();
  }

  public boolean equals( Object rhs ) {
  // Two Entry objects are equal if they have the same key value.  
   return rhs instanceof Entry && 
   key.equals( ((Entry<KeyType, ValueType>)rhs).key ); 
  } 
  
  public KeyType getKey() {return key;}
  public ValueType getValue() {return val;}
  public String toString() {
   return (key.toString() + "," + val.toString());
  }
 }
 
   public static void main( String [ ] args ) {
        MyMap<String,String> M = new MyMap<String,String>( );

        System.out.println("Insert Carver and Nordstrom.");
        M.put("Carver","CS310-003");
        M.put("Nordstrom","CS310-002");
        System.out.println("Insert Carver again.");
        M.put("Carver","CS310-001");
        System.out.println("M.size: " + M.size());
        System.out.println("Get Carver: " + M.get("Carver"));
        System.out.println("is empty: " + M.isEmpty()); 
        System.out.println("Make empty"); 
        M.makeEmpty();
        System.out.println("is empty: " + M.isEmpty()); 
   }
}


</span>
*?

Those are Java codes.

Also He gave us the description of the application.

I'll keep posting my progress here.

Check it out man!! lol

久しぶりの大学☆

えっと、いきなりこんな題名なんですが......

実は自分、大学入試以来、大学の校内に入った事無かったんです!!
あれっ!?大学受験ってイツの話だ??笑

えっ!?じゃあオマエはNEETなのかって?
違いますよ!大学生やってますよ!アメリカで!

基本情報技術者試験

本当に良い勉強になった。
試験からも学ぶことって多いなぁって久しぶりに実感しました♪

本当にモチベーションが上がる、こぉいう類いの試験なりテストって!

これからも定期的に受けれたらいいなぁ、なんて思ってます。

さぁ!今日からまたコーディング再開だな!

今はJavaとC++中心にやってます。

まだまだ未熟だけど、しっかり頑張るぞ!!!

「また会いたい」と思われる人の38のルール

昨日は本当に眠れなかった!!
もぉ終わった事なのに、なんだか昨日?の面接の結果が気になって気になって.......
終いには、歯まで痛くなってたなんて?!はぁ....勉強しなくてはならないのに、明日は「歯医者なう」なんてTweetしてるのかもなぁ。

今日は、その『勉強』に必要な本を買いに、近くにある書店(丸善)までフラッと足を運んでみました。
お目当ての本は、えぇ〜〜っと....なんだっけか?あっ!思い出した!!サーバー構築に関する基礎を学ぶための書籍を求めて2時間?(もっと居たかな?)ほど立ち読みしてきました。
で、「この本かな」って決めて、レジの列に並んでる時に何気なく目に入ったのが........そぉ!”「また会いたい」と思われる人の38のルール”(吉原珠央)なんです!

えっ??何で『勝間和代』じゃないんだ!!って?
それは、自分でもビックリです(笑)
何はともあれ、そのレジに並んでるタカが5分くらいですかね??
少し、チラって中覗いただけなのに買ってしまった......ハッキリ言ってこの類いの本は、面接に行く前の見つけて読むべきものだったんでしょうね。今、必死こいてよんでます(笑)サーバー構築の本よりも真剣によんでます(笑)
で、気がついたんです、ある事に.....それはですね.....
この本”「また会いたい」と思われる人の38のルール”(吉原珠央)に書いてあることって、今自分が影響されてる人みんな出来てるんですよね(笑)やっぱり基本中の基本なんですかね??はぁ....まだまだ子供ですね自分は(汗)
また、新しく一つ学んだ!よしよし!今日もご苦労自分!笑

ってなわけで、やっぱり僕は『吉原珠央』さんではなくて、『勝間和代』さんに一票ですかね、この次の参議院選挙は!笑

はぁ、只今午後十一時五十八分(なんか中国語みたい)かな?
あと2時間ほど学習してから就寝したいと思います。

ではでは......

起きていることはすべて正しい―運を戦略的につかむ勝間式4つの技術

起きていることはすべて正しい―運を戦略的につかむ勝間式4つの技術

IT系開発エンジニア第一歩??

今日、都内のとあるIT企業の面接に行ってきました!!
そんなに大きな会社では無いんですけど、みんなアプリケーションの開発が本当に好きで仕事してるってのが目に見える活気あふれた良い企業でした。

で、ここで問題が、、、、サーバー構築の知識を身につけなくては!!
入社時は知らなくてもいいらしいのだが、、、、、知っててもちろん損は無い!!わけであって、勉強勉強。
ってな訳で今、ググってみた所ですねぇぇ、、、、本当に奥が深い!そして、面白そう!!
何で今まで勉強しなかったんだろ??IT系開発エンジニア志望の学生あるまじき行為だ。。。。。

はい、勉強します(笑)

これではスーパークリエイターの足下にも及ばないなぁ。
gamellaさん!!頑張ります!!笑
IPA利権に迫る勢いで........

ってな感じで、今日も『勝間和代』さんの書籍の紹介で締めくくりたいと思います。

断る力 (文春新書)

断る力 (文春新書)

AERA MOOK 勝間和代「まねる力」

AERA MOOK 勝間和代「まねる力」

『サブカルパジャマ』論??

初めまして。
IT系開発プログラマー志望の学生です!
学生といっても、アメリカに留学している留学生です。

実はこのブログ、僕の大好きなPodcastである『サブカルパジャマトーク』のメインであるgamellaさんの影響で始めました。
さすが、スーパークリエイターです。
本当に影響される事が多くてですね。
「勝間和代」酔い?ならぬ病にかかったのもスーパークリエイターであるgamellaさんの影響だったりします。
今日はですね、、、初めてって事もあるので、そこまで込み入った話ができないので僕からの『サブカルパジャマ論』みたいな物を少しお話できたらと思っています。

只今1月24日現在、全31話配信されています。最新話は「NEETの再定義」
この回も本当に面白かった!
で、為になるなぁと感じるのは、恐らく僕自身、海外(アメリカ)での生活で一杯一杯だったので、日本で今なにがおこっているとかに対して本当に疎かったからかなぁと。
でも、別に為になるならないで聞いている訳ではもちろんなく(ここ重要)、gamellaさんとYoshikoさんのトークが単純に好きで聞いてるんですよねぇ。

これって、僕からするとあり得ないんですよ、今までは。
人の話聞いて面白い????なんじゃそりゃ〜〜!!笑
本当に感心感心の一言に尽きます。
あれ??何にも『サブカルパジャマ論』なんて語ってねぇじゃん!!って今思いました??
すみません。
でも、これからですよ〜〜!!
僕も一段落ついたら、しっかり『サブカルパジャマトーク』の魅力、『勝間和代』の魅力??(笑)について語っていきたいと思います。
それでは、また。

結局、女はキレイが勝ち

結局、女はキレイが勝ち