daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef struct HeapStruct *PriorityQueue;
  2. typedef struct Customer *CustomerP;
  3.  
  4. struct HeapStruct {
  5.     int Capacity;
  6.     int Size;
  7.     int *Elements;
  8. };
  9.  
  10. struct Customer {
  11.     float arrivalT;
  12.     float waitT;
  13.     float departureT;
  14.     float currentT;
  15.     CustomerP *siblingR; //Used for linked list
  16. };
  17.  
  18. PriorityQueue Initialize() {
  19.     PriorityQueue H = (PriorityQueue) malloc(sizeof (struct HeapStruct));
  20.     CustomerP sentinal = malloc(sizeof (struct Customer));
  21.     sentinal->currentT = MinData;
  22.     H->Capacity = 101;
  23.     H->Size = 0;
  24.     H->Elements[0] = &sentinal; //Syntax Error
  25.     return H;
  26. }
  27.  
  28. void Insert(CustomerP X, PriorityQueue H) {
  29.     int i;
  30.     if (IsFull(H)) {
  31.         printf("Priority queue is full");
  32.         return;
  33.     }
  34.     //Syntax errors
  35.     for (i = ++H->Size; H->Elements[i/2]->currentT > X->currentT; i /= 2)
  36.     H->Elements[i] = H->Elements[i/2];
  37.     H->Elements[i] = X;
  38. }
  39.    
  40. struct HeapStruct {
  41.     int Capacity;
  42.     int Size;
  43.     CustomerP *Elements;
  44. };
  45.    
  46. H = (PriorityQueue) malloc(sizeof (struct HeapStruct));
  47. CustomerP sentinal = malloc(sizeof (struct Customer));
  48. sentinal->currentT = MinData;
  49. H->Capacity = 101;
  50. H->Size = 0;
  51. H->Elements = malloc(sizeof(CustomerP) * H->Capacity);
  52. H->Elements[0] = sentinal;
  53.    
  54. CustomerP*
  55.    
  56. H->Elements =  malloc(sizeof (CustomerP) * H->Capacity);
  57.    
  58. H->Elements = (int *)malloc(sizeof(int));
  59. H->Elements[0] = &sentinal;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top