Skip to content

Instantly share code, notes, and snippets.

View campbellmarianna's full-sized avatar
🎯
Focusing

Marianna Campbell campbellmarianna

🎯
Focusing
  • San Francisco, California
View GitHub Profile

Marianna Campbell

San Francisco, CA | marianna.campbell@students.makeschool.com | 248-558-0510

Portfolio| Github | LinkedIn

HIGHLIGHTS

  • 1st Place Hackathon Winner with 5 person team at Wayne State University in 2015 & 2018
  • Awardee of the Academic Excellence Award - Congress of Future Science and Technology Leaders 2017
@campbellmarianna
campbellmarianna / get_hashtable.py
Created May 20, 2019 02:31
get a value from a hash table
def get(self, key):
"""Return the value associated with the given key, or raise KeyError.
Best case running time: O(1) if the key is found early in iterating through
the bucket
Worst case running time: O(n + i) for n nodes in the LinkedList because
we have to iterate over all n nodes, iterate over all the i items and check
to see whose data matches the given key"""
# Find the bucket the given key belongs in
index = self._bucket_index(key)
bucket = self.buckets[index]
@campbellmarianna
campbellmarianna / init_hashtable.py
Created May 20, 2019 02:11
Init function for hash table
#!python
from linkedlist import LinkedList
class HashTable(object):
def __init__(self, init_size=8):
"""Initialize this hash table with the given initial size."""
self.buckets = [LinkedList() for i in range(init_size)]
self.size = 0 # Number of key-value entries
@campbellmarianna
campbellmarianna / acronym_after.py
Last active May 14, 2019 20:32
Convert a phrase to its acronym
def abbreviate(words):
acronym = []
clean_words = sanitize(words)
words_list = clean_words.split()
# loop through each word and append the first character of each
for word in words_list:
acronym.append(word[0].upper())
return "".join(acronym)
def sanitize(words):
@campbellmarianna
campbellmarianna / acronym_before.py
Last active May 14, 2019 20:30
Convert a phrase to its acronym
def abbreviate(words):
acronym = []
charc_location = 0
first_char = words[0]
acronym.append(first_char)
charc_location += 1
for i in range(1, len(words)):
charc_location_after_space = 0
if words[i] == ' ' or words[i] == '-' or words[i] == '_':
charc_location_after_space = i + 1
@campbellmarianna
campbellmarianna / linked_list_insert.py
Created May 1, 2019 22:20
Linked List Insert Node At Index Implementation
def insert_at_index(self, index, item):
"""Insert the given item at the given index in this linked list, or
raise ValueError if the given index is out of range of the list size."""
...
# Initialize the previous node index
prev_node_index = 0 # Constant time to assign a variable
# Set to the index of the node before the given index
prev_node_index = index - 1 # Constant time to assign a variable
# Initialize the previous node
prev_node = None