William Pollard’s quotes.

I found his great quotes. Those quotes drive me to the Innovation for my life. I always thought about what I should do and how to carry it out. And I have given 100% effort and have never ever compromised.

 

“It is not always what we know or analyzed before we make a decision that makes it a great decision. It is what we do after we make the decision to implement and execute it that makes it a good decision.”

 “Without change there is no innovation, creativity, or incentive for improvement. Those who initiate change will have a better opportunity to manage the change that is inevitable.”

ThinkExist.com

http://thinkexist.com/

Technorati のタグ: ,

In fact, I’m looking for a new position for the Testing engineer in USA. I really want to try NEW challenge.

Advertisements

Data Structures and Algorithms: Single List

Recently, I have to teach my co-worker about the Data structures and algorithms with C#. Today, I made a Single List sample and published it.

And, I found cool site about the Algorithms.

Computer Programming Algorithms Directory

http://www.algosort.com/

 

How to compile this source code: csc /nologo SingleList.cs SingleApp.cs Node.cs

Node.cs

————————–

using System;

public class Node {
    Node _next;
    Object _value;

    public Node(Node next, Object value) {
        _next = next;
        _value = value;
    }

    public Node Next {
        get {
            return _next;
        }
        set {
            _next = value;
        }
    }

    public Object Value {
        get {
            return _value;
        }
    }

    public override String ToString() {
        return _value.ToString();
    }
}

———–

SingleList.cs

————-

using System;
using System.Text;

public class SingleList {
    Node _head = new Node(null, "Dummy");

    public bool Contains(Object obj) {
        Node node = _head.Next;
        while (node != null) {
            if (node.Value.Equals(obj)) {
                return true;
            }
            node = node.Next;
        }
        return false;
    }

    public void InsertAtHead(Object obj) {
        _head.Next = new Node(_head.Next, obj);
    }

    public void InsertAtHeadFromArray(Object[] array) {
        if (array != null) {
            for (int i = 0; i < array.Length; i++) {
                InsertAtHead(array[array.Length – 1 – i]);
            }
        }
    }

    public bool InsertAt(Object obj, int index) {
        if (index < 0) {
            return false;
        } else {
            Node node = _head;
            for (int i = 0; i < index; i++) {
                node = node.Next;
                if (node == null) {
                    return false;
                }
            }
            node.Next = new Node(node.Next, obj);
            return true;
        }
    }

    public override String ToString() {
        StringBuilder builder = new StringBuilder();
        builder.Append("[ ");
        Node node = _head.Next;
        while (node != null) {
            builder.Append(node.ToString());
            builder.Append(" ");
            node = node.Next;
        }
        builder.Append("]");
        return builder.ToString();
    }
}

———————-

SingleApp.cs (testing code)

———————-

using System;

public class SingleApp {
    public static void Main(String[] args) {
        String[] name = {
            "Alice", "Bob", "Diana", "Elmo", "Fred", "Gaas",
        };
        SingleList list = new SingleList();
        Console.WriteLine("list = {0}", list.ToString());

        list.InsertAtHeadFromArray(name);
        Console.WriteLine("list = {0}", list.ToString());

        list.InsertAt("Chris", 2);
        Console.WriteLine("list = {0}", list.ToString());

        list.InsertAt("Harold", 7);
        Console.WriteLine("list = {0}", list.ToString());

        Console.WriteLine("list.Contains(Chris) = {0}", list.Contains("Chris"));
        Console.WriteLine("list.Contains(Zoe) = {0}", list.Contains("Zoe"));
    }
}