Skip to content

Instantly share code, notes, and snippets.

View anupsavvy's full-sized avatar

Anup anupsavvy

  • Northwestern University
  • Chicago
View GitHub Profile
@anupsavvy
anupsavvy / Hashtable.java
Created July 23, 2011 22:07
Simple Hashtable with linear probing in java ( Does not apply any growth strategy).
public class Hashtable{
private static final int SIZE = 97;
private Pair[] map = null;
public Hashtable(){
this(SIZE);
}
public Hashtable(int N){
map = new Pair[N];
@anupsavvy
anupsavvy / Queue.java
Created July 23, 2011 00:30
Simple Circular Queue
package com.operations.queue;
public class Queue{
private int N ;
private static final int SIZE = 1024;
private int[] arr = null;
private int t = 0;
private int f = 0;
@anupsavvy
anupsavvy / Stack.java
Created July 19, 2011 02:37
Creation of simple array based stack
package com.operations.stack;
public class Stack{
private static final int SIZE = 1024;
private int N;
private int t = -1;
@anupsavvy
anupsavvy / Tree.java
Created July 15, 2011 06:35
Check to see if the tree is balanced.
package com.example.tree;
import com.example.Node;
// Tree is balanced when the difference between maximum and minimum height is <= 1.
public class Tree{
public static void main(String args[]){
Node root = new Node();
if(checkTreeBalance(root))
System.out.println("Its a balanced tree");
else
@anupsavvy
anupsavvy / Triangle.java
Created July 15, 2011 03:23
Triangle Problem - By starting at the top of the triangle and moving to adjacent numbers on the row below, find the maximum total from top to bottom.
package com.example.triangle;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Triangle {
public static void main(String args[]){