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
| void dyHeapRemoveMin(DynamicArray* heap, compareFunction compare) | |
| { | |
| // FIXME: implement | |
| int last = dySize(heap)-1; | |
| assert (last != 0); /* make sure we have at least one element */ | |
| /* Copy the last element to the first position */ | |
| dyPut(heap, dyGet(heap, last), 0); | |
| dyRemoveAt(heap, last); /* Remove last element.*/ | |
| adjustHeap(heap, last, 0, compare);/* Rebuild heap */ | |
| } |
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
| void buildHeap(DynamicArray* heap, compareFunction compare) | |
| { | |
| // FIXME: implement | |
| for(int i=dySize(heap)/2-1;i>=0;i--) { | |
| adjustHeap(heap, dySize(heap)-1, i, compare); | |
| } | |
| } |
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
| void hashMapPut(HashMap* map, const char* key, int value) { | |
| // FIXME: implement | |
| float load = hashMapTableLoad(map); | |
| if(load >= MAX_TABLE_LOAD) { | |
| resizeTable(map, hashMapCapacity(map)); | |
| } | |
| int i = HASH_FUNCTION(key) % map->capacity; | |
| HashLink *cur = map->table[i]; | |
| while(cur) { | |
| if(strcmp(cur->key, key) == 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
| def majority(array, tiebreaker=None): | |
| n = len(array) | |
| if n == 0: | |
| return tiebreaker | |
| pairs = [] | |
| if n % 2 == 1: | |
| tiebreaker = array[-1] | |
| for i in range(0, n-1, 2): | |
| if array[i] == array[i+1]: | |
| pairs.append(array[i]) |
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
| import matplotlib.pyplot as plt | |
| import time | |
| import numpy as np | |
| import sympy | |
| from sympy import S, symbols | |
| import random | |
| from math import floor | |
| def randomArray(totalNumbers,min,max): | |
| array = [] |
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
| from pulp import * | |
| # Creates a list of the Ingredients | |
| Ingredients = ['TOMATO', 'LETTUCE', 'SPINACH', 'CARROT', 'SUNFLOWER', 'TOFU', 'CHICKPEAS', 'OIL'] | |
| kcal = {'TOMATO': 21, | |
| 'LETTUCE': 16, | |
| 'SPINACH': 40, | |
| 'CARROT': 41, | |
| 'SUNFLOWER': 585, |
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
| Problem 2 | |
| Part A: | |
| i. | |
| MINIMIZE e | |
| to = 21e + 0.85p + 0.33f + 4.64c + 9s + 1cs | |
| le = 16e + 1.62p + 0.2f + 2.37c + 28s + 0.75cs | |
| sp = 40e + 2.86p + 0.39f + 3.63c + 65s + 0.50cs |
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
| <?php echo(“Hello world!”); ?> |
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
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
| } | |
| export PS1="\u@\h \W\[\033[034m\]\$(parse_git_branch)\[\033[0m\] $ " | |
| [alias] | |
| co = checkout | |
| br = branch | |
| st = status | |
| c = commit |
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
| import matplotlib | |
| import seaborn as sns | |
| import pandas as pd | |
| from scipy.stats import zscore | |
| from sklearn.preprocessing import MinMaxScaler | |
| from sklearn.cluster import DBSCAN | |
| from matplotlib import cm | |
| from datetime import datetime | |
| from dateutil import parser | |
| import json |
OlderNewer