Example #1
0
int main()
{  
   BinarySearchTree t;
   t.insert("D");
   t.insert("B");
   t.insert("A");
   t.insert("C");
   t.insert("F");
   t.insert("E");
   t.insert("I");
   t.insert("G");
   t.insert("H");
   t.insert("J");
   t.erase("A"); // Removing leaf
   t.erase("B"); // Removing element with one child
   t.erase("F"); // Removing element with two children
   t.erase("D"); // Removing root
   t.print();
   cout << t.count("E") << "\n";
   cout << t.count("F") << "\n";
   return 0;
}
Example #2
0
File: main.cpp Project: fjur/Big-C
int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    cout << (z) << "\n";
    
    set<int> a;
    a.insert(1);
    a.insert(2);
    a.insert(3);
    a.insert(5);
    
    set<int> b;
    b.insert(3);
    b.insert(4);
    b.insert(5);
    
    set<int> c;
    
    
//    c = set_Union(a, b);
//    c = intersection(a, b);
    
    //set<int> d = sieveofEratosthenes(10);
    
    //exercise1();
  //  exercise2();
    
    BinarySearchTree t;
    
    t.insert("D");
    t.insert("B");
    t.insert("A");
    t.insert("C");
    t.insert("F");
    t.insert("E");
    t.insert("I");
    t.insert("G");
    t.insert("H");
    t.insert("J");
    t.erase("A"); // Removing leaf
    t.erase("B"); // Removing element with one child
    t.erase("F"); // Removing element with two children
    t.erase("D"); // Removing root
    t.print();
    cout << t.count("E") << "\n";
    cout << t.count("F") << "\n";
    
    cout << "\nHeap Tasks\n";
    Heap tasks;
    tasks.push(2);
    tasks.push(3);
    tasks.push(2);
    tasks.push(1);
    tasks.push(4);
    tasks.push(9);
    tasks.push(1);
    tasks.push(5);
    while (tasks.size() > 0)
    {
        int task = tasks.top();
        tasks.pop();
        cout << task << "\n";
    }
    
    std::cout << "Hello, World!\n";
    return 0;
}