Beispiel #1
0
void addValuesInHeap(BinaryHeap<int> &h){
	cout<<"Adding 3, 17, 92, 44, 2, and 13 to the binary heap"<<endl;
	h.add(3);
	h.add(17);
	h.add(92);
	h.add(44);
	h.add(2);
	h.add(13);

}
Beispiel #2
0
int main() {
	srand(time(NULL));
	BinaryHeap<int> heap;
	ArrayStack<int> randList;

	for(int i = 0; i <= 1000; i++){
		int rando = rand() % 10000 + 1;
		randList.add(rando);
	}
	for(int i = 0; i < 1000; i++){
		heap.add(randList.get(i));
		if(heap.checkHeap()){
		  //cout << "Heap Conditions Met..." << endl;
		}
		else{
		  cout << "Heap Conditions NOT Met!" << endl;
		  cout << randList.get(i) << endl;
		  cout << i;
		  return 0;
		}
	}

	int n = 1000;
  for(int i = 0; i <= 100; i++){
  	int rando = rand() % n + 1;
  	heap.remove(rando);

  	if(heap.checkHeap()){
  		cout << "Heap Conditions Met..." << endl;
  	}
  	else{
  		cout << "Heap Conditions NOT Met!" << endl;
  		return 0;
  	}
  	n--;
  }
  cout << "Heap Conditions Were Met On All Removes. Great Success!" << endl;
	return 0;
}