Ask your own question, for FREE!
Mathematics 22 Online
OpenStudy (sparrow2):

c++ pointers .is anyone familiar with?

OpenStudy (sparrow2):

const int maxsize=4; void changeIndex(); int usedsize=0; string *arr; HeapPriorityQueue::HeapPriorityQueue() { usedsize=0; maxsize=4; arr=new string[maxsize]; } HeapPriorityQueue::~HeapPriorityQueue() { delete[]arr; } int HeapPriorityQueue::size() { return usedsize; } bool HeapPriorityQueue::isEmpty() { return usedsize==0; } void HeapPriorityQueue::enqueue(string value) { if(usedsize==maxsize){ string *temp=new string[2*maxsize]; for(int i=0;i<usedsize;i++ ){ temp[i]=arr[i]; } delete[]arr; arr=temp; maxsize*=2; } arr[usedsize]=value; usedsize++; changeIndex(); } void changeIndex(){ int k=0; string last=arr[usedsize-1]; for(int i=usedsize;i>0;i--){ if(last<arr[i]){ k=i; } } string *pt=new string[usedsize]; pt[k]=last; for(int i=0;i<usedsize-1;i++){ if(i==k){ pt[i+1]=arr[i]; }else{ pt[i]=arr[i]; } } } string HeapPriorityQueue::peek() { return arr[0]; } string HeapPriorityQueue::dequeueMin() { if(usedsize==1){ string first=arr[0]; arr=new string[0]; usedsize--; return first; } string *temp=new string[usedsize-1]; for(int i=1;i<usedsize;i++){ temp[i-1]=arr[i]; } delete[]arr; arr=temp; usedsize--; return arr[0]; }

OpenStudy (sparrow2):

comp science group is dead!

OpenStudy (sachintha):

@Jaynator495

jaynator495 (jaynator495):

Incorrect subject. Refuse help. End program.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!