Skip to content

Instantly share code, notes, and snippets.

View trafficinc's full-sized avatar

Ron trafficinc

  • Greater Philadelphia
View GitHub Profile
@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
*/
@meetrajesh
meetrajesh / hash_table.php
Created December 14, 2012 05:12
Basic implementation of a hash table in PHP with collision detection and management (no locking support)
<?php
class HashTable {
private $_array = array();
private $_size = 10000;
public function __construct($size=0) {
$size = (int)$size;
if ($size > 0) {
@femmerling
femmerling / hashtable.py
Last active September 22, 2017 14:35
Hashtable algorithm written in python
#create the key-value object
class KeyValue:
def __init__(self,key,value):
self.key=key
self.value=value
class HashTable:
#initiate an empty list that will store all key value pair based on the KeyValue object
def __init__(self):
@meetrajesh
meetrajesh / binary_search_tree.php
Last active January 18, 2022 16:53
An efficient binary search tree (BST) implementation in PHP.
<?php
class BinarySearchTree {
private $_root;
public function __construct() {
// setup sentinal node
$this->_root = new BinarySearchNode(null);
}
public function getRoot() {
return $this->hasNode() ? $this->_root->right : null;
@stonly
stonly / hashex.py
Last active September 22, 2017 14:35
hash table demonstration code
#!/usr/bin/python
"""
Hash Tables
Usage :
'python -i hashex.py'
The goal of a hash table is to map a keyword to a placeholder that contains the value you stored.
We will define 3 functions :
@jakemmarsh
jakemmarsh / binarySearchTree.py
Last active June 1, 2024 13:57
a simple implementation of a Binary Search Tree in Python
class Node:
def __init__(self, val):
self.val = val
self.leftChild = None
self.rightChild = None
def get(self):
return self.val
def set(self, val):
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links
@EntilZha
EntilZha / hashtable.py
Last active December 18, 2022 05:37
Hash Table (Open Address) implementation in Python practicing for interviews
from collections import namedtuple
TableEntry = namedtuple('Element', 'hash key value')
class HashTable(object):
DEFAULT_SIZE = 8
EMPTY_VALUE = TableEntry(None, None, None)
DELETED_VALUE = TableEntry(None, None, None)
LOAD_FACTOR = 2 / 3
MIN_FACTOR = 1 / 3
@im4aLL
im4aLL / php-event-listener-example.php
Last active June 20, 2024 21:25
PHP event listener simple example
<?php
// Used in https://github.com/im4aLL/roolith-event
class Event {
private static $events = [];
public static function listen($name, $callback) {
self::$events[$name][] = $callback;
}