This file contains 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
from hashlib import md5 | |
from DataStructures.LinkedList.LinkedList import * |
This file contains 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
defaultHashTableSize = 32 |
This file contains 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 HashTable: |
This file contains 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
# @param {number} hashTableSize | |
def __init__(self, hashTableSize = defaultHashTableSize): | |
# Should probably be named HashTableEntry. You get the point. | |
self.buckets = [LinkedList() for x in range(0, hashTableSize)] | |
# A quick lookup for has() and getKeys(). | |
self.keys = {} |
This file contains 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
# @params {string} key | |
# @returns {number} | |
def hash(self, key): | |
k = 0 | |
for s in list(md5(str(key).encode('utf-8')).hexdigest()): | |
k += ord(s) | |
return k % len(self.buckets) |
This file contains 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
# @param {string} key | |
# @param {*} value | |
def set(self, key, value): | |
keyHash = self.hash(key) | |
self.keys[key] = keyHash | |
bucketLinkedList = self.buckets[keyHash] | |
# custom linkedlist find | |
node = None |
This file contains 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
# @param {string} key | |
# @returns {*} | |
def get(self, key): | |
bucketLinkedList = self.buckets[self.hash(key)] | |
# custom linkedlist find | |
currentNode = bucketLinkedList.head | |
while not currentNode == None: | |
for k in currentNode.value: |
This file contains 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
# @params {string} key | |
# @returns {boolean} | |
def has(self, key): | |
if key in self.keys.keys(): | |
return True | |
else: | |
return False | |
# @returns {string[]} | |
def getKeys(self): |
This file contains 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
// Example Call | |
// asyncScript('https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'); | |
asyncScript = (scriptPath) => { | |
const script = document.createElement('script'); | |
script.src = scriptPath; | |
script.async = true; | |
document.body.appendChild(script); | |
This file contains 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
import java.util.Scanner; //Scanner Function to take in the Input Values | |
public class Dijkstra { | |
static Scanner scan; // scan is a Scanner Object | |
public static void main(String[] args){ | |
int[] preD = new int[5]; | |
int min = 999, nextNode = 0; // min holds the minimum value, nextNode holds the value for the next node. |
OlderNewer