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
def insert(self, d): | |
if self.head is None: | |
self.head = Node(d) | |
else: | |
self.insert_helper(self.head, d) | |
def insert_helper(self, nd, d): | |
if d < nd.data: | |
if nd.left is None: | |
nd.left = Node(d) |
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
def sub(N, S): | |
sub_helper(S, range(1,N+1), list()) | |
def sub_helper(S, remainingList, subseq): | |
if S == 0: | |
print subseq | |
return | |
else: | |
for i in range(0, len(remainingList)-S+1): | |
subseq.append(remainingList[i]) |
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
input: | |
(c1, [p1]) | |
(c2, [p1, p2]) | |
(c3, [p1]) | |
----------------------------------------------------------------- | |
QUESTION 1: | |
Given a customer-product graph where customers and products are nodes, | |
and an edge is formed if a customer buys a product, design an MapReduce | |
algorithm to compute the frequency distribution of the number of customers |
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 Node: | |
def __init__(self, val=None): | |
self.data=val | |
self.left=None | |
self.right=None | |
class BST: | |
def __init__(self): | |
self.root=None | |
self.head=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
# Title: charfreq.py | |
# Author: Michael Gard | |
# Date Created: 8/14/16 | |
# Description: Given the plain text resume "pt_MG_Resume.txt", output a barplot in Seaborn representing individual character frequency. Colors of the bars are determined by creating one "color bucket" per each of the 26 characters. Higher frequencies get darker colors | |
import seaborn as sns | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import string |
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
#include <fstream> | |
#include <iostream> | |
#include <unordered_map> | |
#include <vector> | |
int main() { | |
std::ifstream datafile("data.txt"); | |
int64_t numlists; | |
int64_t a, b, c, d; | |
std::vector<int64_t> A, B, C, D; |
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
#include <iostream> | |
using namespace std; | |
void printTriangle(int n) { | |
for (int i = 0; i < n; ++i) { | |
for (int j = ((2*n-1) - (2*i+1))/2; j > 0; --j){ | |
cout << " "; | |
} | |
for (int k = (2*i+1); k > 0; --k){ |
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
var callback = function(x) { coordinates = x; } | |
navigator.geolocation.getCurrentPosition(callback); | |
console.log(coordinates); |
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
#include <iostream> | |
#include <vector> | |
#include <climits> | |
using namespace std; | |
class Max2{ | |
public: | |
Max2() : largest(INT_MIN), nextlargest(INT_MIN), lindex(-1), nlindex(-1) { }; | |
friend ostream& operator<<(ostream& os, Max2 m); | |
void insert(int n, int nindex); |
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
#include <iostream> | |
using namespace std; | |
int reverseAsHex(int n) { | |
int mask = 0xF; // or 15 | |
int answer = 0; | |
while (n != 0) { | |
answer = (answer << 4) | (n & mask); | |
n >>= 4; | |
} |
OlderNewer