Example #1
0
void Solve()
{
  AVLtree tree;
  for(int T = 0; T < n; T++)
  {
    char c;
    scanf("%c", &c);
    if(c == '+')
    {
      int i, x;
      scanf("%d %d%*c", &i, &x);
      tree.InsertToPos(i, x);
      /*if(!tree.check())
      {
        printf("shit\n");
      }*/
    }
    else
    {
      int i, j;
      scanf("%d %d%*c", &i, &j);
      printf("%d\n", tree.GetMinimal(i, j));
    }
  }
}
Example #2
0
int main()
{
    AVLtree<int> a;
    srand(time(0));
    int xRan;
    int testNum = 10000;


    // Insert
    for (int i = 1; i <= testNum; i++)
        a.add(i);

    // Search for random number
    for (int i = 1; i <= testNum; i++) {
        xRan = rand() % testNum + 1;
        a.find(xRan);
    }

    // Delete
    for (int i = 1; i <= testNum; i++)
        a.remove(i);

    cout << "done" << endl;





    //cout << "Memory Used: " << UI_MemoryUsed;
    return 0;
}
Example #3
0
int main(void)
{
	AVLtree<int> t;

	int ex[]={2,1,4,3,5};
	for (int i = 0; i <sizeof(ex)/4; ++i)
        t.insert(ex[i]);
	t.display();
	cout<<endl;
    t.deleteKey(1);
    t.display();
    cout<<endl;
}
Example #4
0
  void avltest<T>::ShowAll(AVLtree<T> & b)
  {
	 inorderAVLTreeTraversal<T>  itr(b.begin());
	 itr.init();
	 while (!itr)  {
		 cout << itr () << '\n';
		 itr++;
		 }
  }
Example #5
0
  int avltest<T>::IsFound(AVLtree<T> & b, T  v)  {
	 return b.includes(v);
  }
Example #6
0
  void avltest<T>::remove(AVLtree<T> & b, T  v)  {
	 b.remove(v);
  }
Example #7
0
  void avltest<T>::insert(AVLtree<T> & b, T  v)  {
	 b.add(v);
  }