Skip to content

Instantly share code, notes, and snippets.

@eazybit
eazybit / MyVector.cpp
Last active August 29, 2015 13:56
using c++ to implement a simple vector data structure (including test part)
#include "MyVector.h"
template <typename T>
MyVector<T>::MyVector(void)
{
_size = 0;
_cap = 2;
_vals = new T[_cap];
}
@eazybit
eazybit / Lists
Last active August 29, 2015 13:56
My private gists
My sample codes are showing below
c++ vector data structure:
https://gist.github.com/zy66543/999ade0ac5cf57e16fab
sort a array (1 million data set, saving customers' ages, 0 to 130)
https://gist.github.com/zy66543/3861654a7adcdf37e081
@eazybit
eazybit / MyCountingSort.cpp
Last active August 29, 2015 13:56
Interview Question: Design an algorithm to sort a list
#include "CountingSort.h"
CountingSort::CountingSort(void)
{
}
CountingSort::CountingSort(int *original, int size)
{
int cap = (int)DEF_RANGE;
@eazybit
eazybit / MyAngBetHandM.cpp
Last active August 29, 2015 13:56
Given a time, calculate the angle between the hour and the minute hand
#include "AngBetHandM.h"
#include <stdlib.h>
AngBetHandM::AngBetHandM(void)
{
}
AngBetHandM::~AngBetHandM(void)
@eazybit
eazybit / FindMin.cpp
Last active August 29, 2015 13:56
a sorted array has been rotated, for example, 34512. Design an algorithm to find the smallest number.
///////////////////////////////////////////////////////////////////////////
// Function FindMin() //
// ver 1.0 //
// Type: cpp file //
// Language: C++ //
// Platform: Dell Alienware M14x, Win8 //
// Author: Yu Zhang, Syracuse University //
// yzhan39@syr.edu //
// Date: Feb 22, 2014 //
///////////////////////////////////////////////////////////////////////////
@eazybit
eazybit / Interfaces01.h
Last active August 29, 2015 13:57
Simple Singly Linked List
#pragma once
#include <cstdlib>
struct ISingleNode {
ISingleNode() {}
virtual ~ISingleNode() {}
virtual void setValue(int value) = 0;
virtual int getValue() = 0;
virtual ISingleNode * getNext() = 0;
@eazybit
eazybit / DoubleList.cpp
Created March 16, 2014 02:48
Simple Doubly Linked List
#include "DoubleList.h"
#include "DoubleNode.h"
#include "Interfaces01.h"
IDoubleNode * DoubleList::getHead()
{
return _head;
}
@eazybit
eazybit / TestString.cpp
Last active August 29, 2015 14:03
[C++] - String
///////////////////////////////////////////////////////////////////////////
// TestString.cpp //
// ver 1.0 //
// Type: source file //
// Language: C++ //
// Platform: Dell Alienware M14x, Win8 //
// Author: Yu Zhang, Syracuse University //
// yzhan39@syr.edu //
// Description: http://www.yu-zhang.net/blog/2014/07/06/c-string/ //
///////////////////////////////////////////////////////////////////////////
@eazybit
eazybit / UniqueString.cpp
Last active August 29, 2015 14:03
[C++] - Unique String
///////////////////////////////////////////////////////////////////////////
// UniqueString.cpp //
// ver 1.0 //
// Type: source file //
// Language: C++ //
// Platform: Dell Alienware M14x, Win8 //
// Author: Yu Zhang, Syracuse University //
// yzhan39@syr.edu //
// Description: http://www.yu-zhang.net/blog/2014/07/06/cci150c-unique-string //
///////////////////////////////////////////////////////////////////////////
@eazybit
eazybit / ReversString.cppe
Last active August 29, 2015 14:03
[C++] & [C] - Reverse String
///////////////////////////////////////////////////////////////////////////
// ReverseString.cpp //
// ver 1.0 //
// Type: source file //
// Language: C++ //
// Platform: Dell Alienware M14x, Win8 //
// Author: Yu Zhang, Syracuse University //
// yzhan39@syr.edu //
// Description: http://www.yu-zhang.net/blog/2014/07/07/cci150c-reverse-string///
///////////////////////////////////////////////////////////////////////////