Skip to content

Instantly share code, notes, and snippets.

View melouver's full-sized avatar

Yuzhe (Lucas) Li melouver

View GitHub Profile
@melouver
melouver / cmu_course.md
Created October 24, 2017 14:16 — forked from kowakowa93/cmu_course.md
CMU CS Course Info

#CMU Course Info 整理自一亩三分地

##08722 – Data Structurefor application programmers 这门课主要是开给EBIZ和MISM的,在MISM那边的课号是95772. 但是很多ECE, INI的同学,以及咱ME转CS帮都在上这门课。这门课只有半学期,一共6个credits,相当于1.5学分。内容非常基础,但是我觉得帮助挺大的,对于非CS科班出身想转CS的同学非常建议上一下, 基础越弱收获越大,要是基础比较硬的话就不用上了。LZ上的其它CS的课几乎都是各种牛校的PHD出身,这门课的老师好像都没有PHD学位,肯定没法去上15的课,但是讲课挺用心,讲的也很清楚。讲课这东西真的不是老师自己越牛就讲的越好。尤其数据结构这种比较基础的内容。这门课从最简单的内容讲起,包括array, arraylist, linked list, stack, queue,sorting(bubble, selection, insertion, merge, quick, heap), hashTable, hashMap,hashSet, BST, TreeMap, TreeSet, Huffman coding, Heap. 每周一次quiz, lab, homework。讲的时候内容都围绕Java Collection 来讲,还涉及与collection有关的comparator, iterator 等内容。这门课完全就是针对面试的,作业要求先手写代码(虽然大部分时候都是先ECLIPSE敲好再抄到纸上的)。

6次homework,前面的非常简单,后面稍微麻烦一点,难度都不大,就是让你去熟悉这些数据结构能自己implement,也能用JAVA COLLECTION。

  1. 自己implement 一个 arraylist 实现各种要求
  2. Queue, stack 的implement和应用
@melouver
melouver / 10.28
Last active November 18, 2017 01:41
gist today
CMU database group:15445
Youtube: https://www.youtube.com/watch?v=xjhQ0e9Hlds&list=PLSE8ODhjZXjYutVzTeAds8xUt1rcmyT7x
course info: [main](http://15445.courses.cs.cmu.edu/fall2017/index.html)
Linux man page:
[manpage](https://linux.die.net/man/)
UIUC system programming
@melouver
melouver / malloc-hint2.txt
Created October 28, 2017 11:02 — forked from kowakowa93/malloc-hint2.txt
hints malloc lab
(text of an email to the class from Dave O'Hallaron)
I've noticed that a number of you are having trouble getting started
with Lab 6. The purpose of this note is to help you get started by
guiding you through the initial steps I take when I do the lab.
This lab is too hard to do all at once, so I break it up into more
managable pieces. I start by developing a simple implicit list
allocator. Later, I will improve this code with a faster and more
memory efficient free list organization. But by starting with the
@melouver
melouver / 1029.md
Last active November 25, 2017 15:04
today
#include <iostream>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cassert>
using namespace std;
//static const int CNT = 10;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define BIDIRECTIONAL 0 /* change to 1 if you're doing extra credit */
/* and write a routine called B_output */
#define DEBUG 1
#define N 8
/* a "msg" is the data unit passed from layer 5 (teachers code) to layer */
/* 4 (students' code). It contains the data (characters) to be delivered */
@melouver
melouver / inversion_pairs.cpp
Last active November 21, 2017 14:35
just add sth to merge sort and we can get inversion pairs
int cnt = 0;
void merge(vector<int> &A, int p, int q, int r)
{
int n1 = q - p + 1; // # of L
int n2 = r - q; // # of R
vector<int> L(n1+1, 0), R(n2+1, 0);
for (int i = 0; i < n1; i++) {
L[i] = A[p+i];
}
for (int i = 0; i < n2; i++) {
@melouver
melouver / cmd.sh
Last active November 22, 2017 02:43
GDB command in mind
thread apply all bt
用于打印所有线程调用栈,debug死锁
x/bx ptr
以字节为单位打印内存
@melouver
melouver / first.c
Created November 26, 2017 02:23
Firstreader-writer problem solution (first: reader with high priority )
/*
COPYRIGHT: CSAPP author RB
*/
#define NITERS 100
/* Sample code demonstrating reader-writers. Create NITERS agents,
* numbered from 1 to NITERS. Each agent is randomly chosen to bea
* reader (probability 80%) or a writer (probability 20%). Writers
* assign their ID to the global value. Readers read the global
@melouver
melouver / second.c
Last active November 26, 2017 02:37
second reader-writer problem solution(second means writer has high priority)
/*
COPYRIGHT: CSAPP author RB
*/
/* My thoughts
For the second rw problem, we give the writers have higher priority
than readers.That is when a writer arrives at some time, it will wait
all the readers in critical section currently to finish their work,
and at the same time, prevent any incoming readers entering their critical
section ,by doing a P operation on r.