Skip to content

Instantly share code, notes, and snippets.

View chenyanzhe's full-sized avatar

Yanzhe chenyanzhe

View GitHub Profile
@chenyanzhe
chenyanzhe / merge_sort_recursive.cpp
Last active August 29, 2015 14:06
Merge Sort Recursive Version
#include <iostream>
#include <vector>
#include <limits>
using namespace std;
void merge(vector<int> & data, int p, int q, int r) {
// merge data[p..q] and data[q+1..r]
int n1 = q - p + 1;
int n2 = r - q;
@chenyanzhe
chenyanzhe / selection_sort.cpp
Created September 12, 2014 12:46
Selection Sort
#include <iostream>
#include <vector>
using namespace std;
void selection_sort(vector<int> & data) {
for (int i = 0; i < data.size() - 1; i++) {
// find ith smaller data
int min = i;
for (int j = i + 1; j < data.size(); j++) {
@chenyanzhe
chenyanzhe / insertion_sort.cpp
Created September 12, 2014 12:21
Insertion Sort
#include <iostream>
#include <vector>
using namespace std;
void insertion_sort (vector<int>& data) {
for (int i = 1; i < data.size(); i++) {
// insert data[i] into data[0..i-1]
int key = data[i];
int j = i - 1;
#include <fstream>
#include <vector>
#include <string>
#include <functional>
int numlines;
std::string _1st_seg, _2nd_seg;
std::vector<std::string> vec_output;
std::vector<bool> vec_endpoints;
#include <iostream>
#include <vector>
using namespace std;
vector<int> arr_to_hp;
vector<int> hp_to_arr;
vector<int> hp;
void max_heapify(int i) {
//
// Created by Yanzhe Chen on 5/25/14.
//
#include <iostream>
#include <vector>
using namespace std;
int partition(vector<int> &array, int head, int tail);
#lang racket
(provide (all-defined-out)) ;; so we can put tests in a second file
;; put your code below
;; Problem 1
(define (sequence low high stride)
(if (> low high)
null
@chenyanzhe
chenyanzhe / _tmux.conf
Last active August 29, 2015 14:01
tmux configurations
# witch panes in vim way
unbind-key j
bind-key j select-pane -D
unbind-key k
bind-key k select-pane -U
unbind-key h
bind-key h select-pane -L
unbind-key l
bind-key l select-pane -R
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.22 (Darwin)
mQENBFM34rwBCADmQj29ZJcmpqD879BOH+NLFxcjsaOdoA2cEyUDncfxU8bHcp0I
7zYyrUJI0q3qzw2wtlW90MgMamGTbPy3Ge13mTG6WiEPc55Cd1cteKZg4+CH9S2s
e1ipboAe2ZdhQs43vjEWd3jGku2+fvPF8RbuUvHiYrN6j6ruSn0PF4kDDoDkTQKM
j46r7blNoeM4DOjOHEzb0n6oU98ybUUiDAmnGrspBgfo2JyfJZKsBZVdjGnUxA77
EdKRfe9LTZJuEkymi+F/Mk4kKICzmA3XycfLTtxJRvBrtGFPObgWGYpPCWN2kDc6
UsvewT03XNT+FLsJWm5Kevkc+AmpYhddl5rVABEBAAG0MFlhbnpoZSBDaGVuIChr
ZXkgZm9yIHBhc3MpIDx5YW56aGUuY25AZ21haWwuY29tPokBOQQTAQIAIwUCUzfi
@chenyanzhe
chenyanzhe / topology.data
Created March 10, 2014 14:06
script for ScriptBasedMapping in HDFS rack topology implementation
brick10 /rack0
brick11 /rack0
brick12 /rack1
brick13 /rack1
192.168.13.171 /rack0
192.168.10.61 /rack0
192.168.13.144 /rack1
192.168.12.78 /rack1