Skip to content

Instantly share code, notes, and snippets.

@IvanIvanoff
IvanIvanoff / circular_queue.cpp
Created November 6, 2015 14:27
SDP - Circular queue
#pragma once
#ifndef __QUEUE_H__
#define __QUEUE_H__
#include <exception>
const int INIT_CAPACITY = 4;
template<class T>
class Queue
@IvanIvanoff
IvanIvanoff / circular_queue.cpp
Created November 6, 2015 14:28
Linear DS - Circular Queue
#pragma once
#ifndef __QUEUE_H__
#define __QUEUE_H__
#include <exception>
const int INIT_CAPACITY = 4;
template<class T>
class Queue
@IvanIvanoff
IvanIvanoff / fibbonaci.cpp
Created November 8, 2015 12:23
Three algorithms for calculating fibbonaci numbers
/*
* Source: http://fmi.wikidot.com/daa1
*/
#include <iostream>
#include <time.h>
typedef unsigned long long ull;
#define a(n) m1.pts[n]
#define b(n) m2.pts[n]
#pragma once
#ifndef __GRAPH_H__
#define __GRAPH_H__
#include <exception>
#include <vector>
#include "Queue.h"
using std::vector;
//Use int instead of size_t so it can be used as a 2d dir vector
//IMHO using Class for this task is an overkill
//So I am using just one struct and a few functions to operate with it
//NOTE: The input must start with ( and the first digit of the root must be at position 1 !!!
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
@IvanIvanoff
IvanIvanoff / TestMemoryAllocator.cpp
Last active November 23, 2021 15:04
Unit tests for the memory allocator using the Microsoft Unit Test Framework for C++
#include "stdafx.h"
#include "CppUnitTest.h"
#include "../MemoryAllocator/MemoryAllocator.h"
#include "../MemoryAllocator/MemoryAllocator.cpp"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
BEGIN_TEST_MODULE_ATTRIBUTE()
TEST_MODULE_ATTRIBUTE(L"Project", L"UnitTests")
TEST_MODULE_ATTRIBUTE(L"Date", L"24/01/2016")
END_TEST_MODULE_ATTRIBUTE()
#include "MemoryAllocator.h"
#include <iostream>
#include <exception>
#include <new>
#include <assert.h>
#include <algorithm>
// ALWAYS a power of 2 !!!
const int ALIGNMENT = 8;
@IvanIvanoff
IvanIvanoff / MemoryAllocator.h
Last active February 9, 2016 18:28
Custom memory allocator using explicit free lists. The allocator supports free header coalescence and splitting.
#pragma once
#ifndef __MEMORY_ALLOCATOR_H__
#define __MEMORY_ALLOCATOR_H__
/*! \file MemoryAllocator.h
\brief Header file for the memory allocator.
@author Ivan Aleksandrov Ivanov
@version 1.0
#pragma once
struct node;
class Stack
{
public:
Stack();
~Stack();
public:
bool push(int);
bool pop();
#pragma once
struct node;
class Queue
{
public:
Queue();
~Queue();
public: