Skip to content

Instantly share code, notes, and snippets.

View thomashw's full-sized avatar

Thomas Hewton-Waters thomashw

View GitHub Profile
/* To use Scanner class */
import java.util.Scanner;
/* To write to file */
import java.io.*;
public class EasyChallengeOne
{
private String name;
private String age;
@thomashw
thomashw / string_permutations.c
Created February 19, 2012 07:52
The program will generate all permutations of the input string.
// Created by: Thomas Hewton-Waters
// Date: February 18, 2012
/* The program will generate all permutations of the input string. */
#include <stdio.h>
#include <string.h>
void merge( char end, char str[], char perms[][100] );
void permutate( char str[], int index, int *num_perms );
@thomashw
thomashw / BinaryTree.java
Created February 19, 2012 23:18
Example of implementing a binary tree. Includes adding nodes, printing, and searching the tree.
public class BinaryTree
{
public void insert( TreeNode node, int value )
{
if( value < node.value ) {
if( node.left != null ) {
insert( node.left, value );
} else {
System.out.println( " Inserted " + value + " to left of node " + node.value );
node.left = new TreeNode(value);
@thomashw
thomashw / Trie.java
Created February 20, 2012 00:47
Example of implementing a trie. Includes inserting and searching the trie (deletion not included.)
import java.io.*;
public class Trie
{
private TrieNode root;
public Trie()
{
root = new TrieNode( ' ' );
}
@thomashw
thomashw / BinarySearch.java
Created February 21, 2012 16:18
Example of implementing binary search.
import java.io.*;
public class BinarySearch
{
public int[] a;
public BinarySearch()
{
a = new int[] { 0, 1, 2, 3, 4, 8, 10, 14 };
@thomashw
thomashw / Quicksort.java
Created February 21, 2012 18:30
Example of implementing quick sort.
import java.util.Arrays;
public class QuickSort
{
public int[] a;
public QuickSort()
{
a = new int[] { 0, 6, 41, 54, 57, 874, 243, 324, 1, 23, 4, 69, 7, 104 };
}
@thomashw
thomashw / MergeSort.java
Created February 21, 2012 18:50
Example of implementing merge sort.
import java.util.*;
public class MergeSort
{
public int[] a;
public MergeSort()
{
a = new int[] { 0, 6, 41, 54, 57, 874, 243, 324, 1, 23, 4, 69, 7, 104 };
}
@thomashw
thomashw / tpwbooks.txt
Created February 26, 2012 23:20
Books recommended from TPW
tinyurl.com/tpwbooks