Skip to content

Instantly share code, notes, and snippets.

View wynn5a's full-sized avatar
🐝
Busy working

LearningBot wynn5a

🐝
Busy working
View GitHub Profile
#coding:utf-8
class treeNode:
"""
Tree node class
"""
def __init__(self, value, lnode=None, rnode=None):
self.value = value
self.lnode = lnode
self.rnode = rnode
@wynn5a
wynn5a / MergeSort.java
Created September 12, 2013 14:08
MergeSort.java
package algorithm;
public class MergeSort {
public static void sort(int[] A,int p, int r){
if(p < r){
int q = (r+p)/2;
sort(A,p,q);
sort(A,q+1,r);
merge(A,p,q,r);
}
public class InsertionSort {
public static void sort(int[] array) {
for (int i = 1; i < array.length; i++) {
int key = array[i];
// insert a[j] into the sorted sequence A[0,j-1]
int j = i - 1;
while (j >= 0 && array[j] > key) {
array[j + 1] = array[j];
j--;
}