Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct HeapStruct *PriorityQueue;
- typedef struct Customer *CustomerP;
- struct HeapStruct {
- int Capacity;
- int Size;
- int *Elements;
- };
- struct Customer {
- float arrivalT;
- float waitT;
- float departureT;
- float currentT;
- CustomerP *siblingR; //Used for linked list
- };
- PriorityQueue Initialize() {
- PriorityQueue H = (PriorityQueue) malloc(sizeof (struct HeapStruct));
- CustomerP sentinal = malloc(sizeof (struct Customer));
- sentinal->currentT = MinData;
- H->Capacity = 101;
- H->Size = 0;
- H->Elements[0] = &sentinal; //Syntax Error
- return H;
- }
- void Insert(CustomerP X, PriorityQueue H) {
- int i;
- if (IsFull(H)) {
- printf("Priority queue is full");
- return;
- }
- //Syntax errors
- for (i = ++H->Size; H->Elements[i/2]->currentT > X->currentT; i /= 2)
- H->Elements[i] = H->Elements[i/2];
- H->Elements[i] = X;
- }
- struct HeapStruct {
- int Capacity;
- int Size;
- CustomerP *Elements;
- };
- H = (PriorityQueue) malloc(sizeof (struct HeapStruct));
- CustomerP sentinal = malloc(sizeof (struct Customer));
- sentinal->currentT = MinData;
- H->Capacity = 101;
- H->Size = 0;
- H->Elements = malloc(sizeof(CustomerP) * H->Capacity);
- H->Elements[0] = sentinal;
- CustomerP*
- H->Elements = malloc(sizeof (CustomerP) * H->Capacity);
- H->Elements = (int *)malloc(sizeof(int));
- H->Elements[0] = &sentinal;
Add Comment
Please, Sign In to add comment