Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / gist:1437751
Created December 6, 2011 10:45
merge.py
'''
by Adrian Statescu <adrian@thinkphp.ro>
MIT Style License
'''
def merge(arrA,arrB):
arrC = []
i = 0
j = 0
n = len(arrA)-1
m = len(arrB)-1
@thinkphp
thinkphp / gist:1448754
Created December 8, 2011 21:44
Binary Search Tree Implementation in PHP
<?php
/**
* by Adrian Statescu <adrian@thinkphp.ro>
* Twitter: @thinkphp
* G+ : http://gplus.to/thinkphp
* MIT Style License
*/
@thinkphp
thinkphp / gist:1450738
Created December 9, 2011 08:29
Binary Search Tree implementation in Python
'''
by Adrian Statescu <adrian@thinkphp.ro>
Twitter: @thinkphp
G+ : http://gplus.to/thinkphp
MIT Style License
'''
'''
Binary Search Tree
------------------
@thinkphp
thinkphp / gist:1450784
Created December 9, 2011 08:49
Binary Search Tree in MooTools
/**
* by Adrian Statescu <adrian@thinkphp.ro>
* Twitter: @thinkphp
* G+ : http://gplus.to/thinkphp
* MIT Style License
*/
var Node = new Class({
initialize: function(info) {
@thinkphp
thinkphp / gist:1450799
Created December 9, 2011 08:57
Binary Search Tree implementation in pure JavaScript
/**
* by Adrian Statescu <adrian@thinkphp.ro>
* Twitter: @thinkphp
* G+ : http://gplus.to/thinkphp
* MIT Style License
*/
function Node(info){
this.info = info
this.left = null;
@thinkphp
thinkphp / gist:1469013
Created December 12, 2011 20:46
Data Structure: Singly Linked List
#defines a linked list iterator for the list
class NodeIterator:
def __init__(self,listHead):
self._currNode = listHead
def __iter__(self):
return self
def next(self):
if self._currNode is None:
@thinkphp
thinkphp / gist:1472473
Created December 13, 2011 15:13
Binary Tree Traversal in Python
class Node:
def __init__(self, info, left=None,right=None):
self.info = info
self.left = left
self.right = right
def __call__(self, left=None, right=None):
self.left = left
self.right = right
return self.info
@thinkphp
thinkphp / gist:1472489
Created December 13, 2011 15:19
Binary Tree Traversal from input file in Python
'''
Twitter: @thinkphp
Website: http://thinkphp.ro
G+ : http://gplus.to/thinkphp
MIT Style License
input.txt:
2 4 6 8 0 0 0 0 0
3 5 7 9 0 0 0 0 0
||
@thinkphp
thinkphp / gist:1501320
Created December 20, 2011 11:48
math.pi
'''
Calculate the value of PI using Infinite Series
Twitter: @thinkphp
Website: http://thinkphp.ro
G+ : http://gplus.to/thinkphp
MIT Style License
4*(1- 1/3 + 1/5 - 1/7 + 1/9 +...)
'''
import math
@thinkphp
thinkphp / gist:1528363
Created December 28, 2011 15:32
e in Python
'''
Computes the value of e(2.718281827...) using infinite series
Twitter: @thinkphp
Website: http://thinkphp.ro
G+ : http://gplus.to/thinkphp
MIT Style License
1 + 1/1! + 1/2! + 1/3! + ...
2 + 1/2! + 1/3!+ ...
'''