Data Types

Note: This page is still being put together. I’m still missing some basic stuff like stacks and queues.

Fundamental Data Types

Data Type Byte Size Range
Character 1
Signed -128 to 127
Unsigned 0 to 255
Short Integer 2
Signed -32768 to 32767
Unsigned 0 to 65535
Integer 4
Signed -2147483648 to 2147483647
Unsigned 0 to 4294967295
Long Integer 4
Signed -2147483648 to 2147483647
Unsigned 0 to 4294967295
Boolean 1 True or False
Floating Point 4 +/- 3.4e +/- 38 (~7 digits)
Double Precision Floating Point 8 +/- 1.7e +/- 308 (~15 digits)
Long Double Precision Floating Point 8 +/- 1.7e +/- 308 (~15 digits)
Wide Character 2 or 4 1 wide character

Source: http://www.cplusplus.com/doc/tutorial/variables/

Linked Lists

A linked list is a linear collection of nodes. Here is what a linked list node might looked like in Java. To get a better understanding you might check out this wikipedia page:

http://en.wikipedia.org/wiki/Linked_list

I also made a node object in Java.  It’s missing some code but you should be able to fill in the gaps and design your own node structure.

public class Node> {
	T data;
	Node head, tail;

	public Node(){}

	public Node( T data){
		this.data = data;
		this.tail = null;
		this.head = null;
	}
}

Trees

In a nutshell, A tree is just a collection of nodes organized in a tree like structure. Here is a simple tree I made to show you what they look like.

Read this wikipedia page if you want to learn more about tree data structures: http://en.wikipedia.org/wiki/Tree_(data_structure)

Here is what tree node might look like in Java. I’ve left most of the code but looking at how this class is organized you should be able to design your own node.

public class Node> {
	T data;
	Node parent, left, right;

	public Node(){}

	public Node( T data){
		this.data = data;
		this.parent = null;
		this.left = null;
		this.right = null;
	}
}

Stacks

Stacks normally operate on a LIFO system, Last in First out. There are three core stack commands, push, peek and pop. Push inserts an element at the top of the stack, peek returns the variable on top of the stack, and pop removes the top variable on the stack. I didn’t feel like coding one yet but you can your own stacks in a variety of ways, such as arrays or linked lists. This simple demonstration just uses the built-in Stack datatype of the C# library.

http://en.wikipedia.org/wiki/Stack_(data_structure)

Stack<Int32> stack = new Stack<Int32>();
stack.Push(1); // Pushing 1 onto the stack
System.Console.WriteLine(stack.Peek()); // Top value on the stack.
            
stack.Push(2); // Pushing 2 onto the stack
System.Console.WriteLine(stack.Peek()); // Top value on the top of the stack - will be 2.

Int32 old = stack.Pop(); // Removing the top value and storing it into a variable.
System.Console.WriteLine(stack.Peek()); // Top value on the stack - will be 1.
System.Console.ReadLine();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s