Skip to content

Instantly share code, notes, and snippets.

View deepakk87's full-sized avatar

Deepak Kumar deepakk87

  • Calgary, Canada
View GitHub Profile
int main(){
binary_search_tree<int> bstTree;
avl_tree<int> avlTree;
bstTree.insert(5);
bstTree.insert(4);
bstTree.insert(6);
bstTree.insert(12);
bstTree.insert(1);
bstTree.insert(3);
@deepakk87
deepakk87 / avl_tree.hpp
Last active August 29, 2015 14:26
AVL Tree
#include "bst_tree.hpp"
template<typename KeyType, typename Comparator = std::less<KeyType> >
class avl_tree : public binary_search_tree<KeyType, Comparator>{
protected:
class avl_node : public binary_search_tree<KeyType, Comparator>::bst_node{
public:
avl_node(KeyType key):
binary_search_tree<KeyType, Comparator>::bst_node(key),height(1){}
int height;
@deepakk87
deepakk87 / bst_tree.hpp
Last active August 29, 2015 14:26
Search Tree
#include <iostream>
#include <stack>
template<typename KeyType, typename Comparator = std::less<KeyType> >
class binary_search_tree{
protected:
Comparator isLessThan;
class bst_node{
public:
KeyType key;