This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
OK: 200, // Everything went fine. I return the resource you requested. | |
CREATED: 201, // Voilá. We successfully created a new resource for you. | |
NO_CONTENT: 204, // There is nothing to see here. Useful if you just deleted an object successfully. | |
UNAUTHORIZED: 401, // You did not provide valid credentials. | |
NOT_FOUND: 404, // Return this if a requested object could not be found. | |
UNPORCESSABLE_ENTITY: 422, // Resource cannot be saved. Maybe a validation error? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Emitter() { | |
this.events = {}; | |
} | |
Emitter.prototype.addListener = function (type, listener) { | |
// check if the listener is a function and throw error if it is not | |
if (typeof listener !== "function") { | |
throw new Error("Listener must be a function!"); | |
} | |
// create the event listener property (array) if it does not exist. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.left = None | |
self.right = None | |
class BST: | |
def __init__(self): | |
self.root = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, key): | |
self.left = None | |
self.right = None | |
self.val = key | |
# Traverse preorder | |
def traversePreOrder(self): | |
print(self.val, end=' ') | |
if self.left: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.next = None | |
class HashTable: | |
def __init__(self, size=100, load_factor=0.75): | |
self.size = size | |
self.items_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in state list: 1 means occupied, 0 means empty and -1 means deleted | |
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.next = None | |
class QuadraticProbing: | |
def __init__(self, size=100, load_factor=0.75): | |
self.items_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in state list: 1 means occupied, 0 means empty and -1 means deleted | |
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.next = None | |
class DoubleHashing: | |
def __init__(self, size=100, load_factor=0.75): | |
self.items_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in state list: 1 means occupied, 0 means empty and -1 means deleted | |
class Node: | |
def __init__(self, key): | |
self.key = key | |
self.next = None | |
class HashTable: | |
def __init__(self, size=100, load_factor=0.75): | |
self.items_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include "hashTable.h" | |
// TODO: rehash if load factor is passed. | |
// hash table functions | |
HashTable * createHashTable(int capacity) { | |
HashTable * ht = malloc(sizeof(HashTable)); | |
int index; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include "kll.h" | |
// Function on linked list: | |
LinkedList * createList() { | |
LinkedList *ll ; | |
ll = malloc(sizeof(LinkedList)) ; | |
ll -> head = NULL ; |
NewerOlder