Skip to content

Instantly share code, notes, and snippets.

View Harryyan's full-sized avatar
🏠
Working from home

Harry Harryyan

🏠
Working from home
View GitHub Profile
@Harryyan
Harryyan / Binary Insertion Sort
Created March 31, 2014 06:35
Ruby 实现折半插入排序
#!/usr/bin/env ruby
def b_insertion_sort(data)
stop = data.length - 1
(1..stop).each do |i|
tmp = data[i]
low = 0
high = i- 1
@Harryyan
Harryyan / Insertion Sort
Created March 31, 2014 05:17
Ruby 实现直接插入排序
#!/usr/bin/env ruby
def insertionSort(data)
len = data.length
(1..len-1).each do |i|
if data[i]>data[i-1]
next
end
@Harryyan
Harryyan / Binary Search Common Implementation
Created March 30, 2014 15:26
python 2分查找普通实现,和jdk中一样
#!/usr/bin/python
import sys
def binaryComm(data,key):
stop = len(data) - 1
start = 0
while start <= stop:
@Harryyan
Harryyan / Binary Search Recursive implementation
Created March 30, 2014 15:25
Python 递归实现2分查找
#!/usr/bin/python
import sys
class Bsrecursive:
name = 2
def BinarySearch(self,sortedArray,start,stop,key):