fork download
  1. // C program for efficient data structure
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <limits.h>
  5.  
  6. // A node of doubly linked list
  7. struct LNode
  8. {
  9. int data;
  10. int minHeapIndex;
  11. int maxHeapIndex;
  12. struct LNode *next, *prev;
  13. };
  14.  
  15. // Structure for a doubly linked list
  16. struct List
  17. {
  18. struct LNode *head;
  19. };
  20.  
  21. // Structure for min heap
  22. struct MinHeap
  23. {
  24. int size;
  25. int capacity;
  26. struct LNode* *array;
  27. };
  28.  
  29. // Structure for max heap
  30. struct MaxHeap
  31. {
  32. int size;
  33. int capacity;
  34. struct LNode* *array;
  35. };
  36.  
  37. // The required data structure
  38. struct MyDS
  39. {
  40. struct MinHeap* minHeap;
  41. struct MaxHeap* maxHeap;
  42. struct List* list;
  43. };
  44.  
  45. // Function to swap two integers
  46. void swapData(int* a, int* b)
  47. { int t = *a; *a = *b; *b = t; }
  48.  
  49. // Function to swap two List nodes
  50. void swapLNode(struct LNode** a, struct LNode** b)
  51. { struct LNode* t = *a; *a = *b; *b = t; }
  52.  
  53. // A utility function to create a new List node
  54. struct LNode* newLNode(int data)
  55. {
  56. struct LNode* node =
  57. (struct LNode*) malloc(sizeof(struct LNode));
  58. node->minHeapIndex = node->maxHeapIndex = -1;
  59. node->data = data;
  60. node->prev = node->next = NULL;
  61. return node;
  62. }
  63.  
  64. // Utility function to create a max heap of given capacity
  65. struct MaxHeap* createMaxHeap(int capacity)
  66. {
  67. struct MaxHeap* maxHeap =
  68. (struct MaxHeap*) malloc(sizeof(struct MaxHeap));
  69. maxHeap->size = 0;
  70. maxHeap->capacity = capacity;
  71. maxHeap->array =
  72. (struct LNode**) malloc(maxHeap->capacity * sizeof(struct LNode*));
  73. return maxHeap;
  74. }
  75.  
  76. // Utility function to create a min heap of given capacity
  77. struct MinHeap* createMinHeap(int capacity)
  78. {
  79. struct MinHeap* minHeap =
  80. (struct MinHeap*) malloc(sizeof(struct MinHeap));
  81. minHeap->size = 0;
  82. minHeap->capacity = capacity;
  83. minHeap->array =
  84. (struct LNode**) malloc(minHeap->capacity * sizeof(struct LNode*));
  85. return minHeap;
  86. }
  87.  
  88. // Utility function to create a List
  89. struct List* createList()
  90. {
  91. struct List* list =
  92. (struct List*) malloc(sizeof(struct List));
  93. list->head = NULL;
  94. return list;
  95. }
  96.  
  97. // Utility function to create the main data structure
  98. // with given capacity
  99. struct MyDS* createMyDS(int capacity)
  100. {
  101. struct MyDS* myDS =
  102. (struct MyDS*) malloc(sizeof(struct MyDS));
  103. myDS->minHeap = createMinHeap(capacity);
  104. myDS->maxHeap = createMaxHeap(capacity);
  105. myDS->list = createList();
  106. return myDS;
  107. }
  108.  
  109. // Some basic operations for heaps and List
  110. int isMaxHeapEmpty(struct MaxHeap* heap)
  111. { return (heap->size == 0); }
  112.  
  113. int isMinHeapEmpty(struct MinHeap* heap)
  114. { return heap->size == 0; }
  115.  
  116. int isMaxHeapFull(struct MaxHeap* heap)
  117. { return heap->size == heap->capacity; }
  118.  
  119. int isMinHeapFull(struct MinHeap* heap)
  120. { return heap->size == heap->capacity; }
  121.  
  122. int isListEmpty(struct List* list)
  123. { return !list->head; }
  124.  
  125. int hasOnlyOneLNode(struct List* list)
  126. { return !list->head->next && !list->head->prev; }
  127.  
  128.  
  129. // The standard minheapify function. The only thing it does extra
  130. // is swapping indexes of heaps inside the List
  131. void minHeapify(struct MinHeap* minHeap, int index)
  132. {
  133. int smallest, left, right;
  134. smallest = index;
  135. left = 2 * index + 1;
  136. right = 2 * index + 2;
  137.  
  138. if ( minHeap->array[left] &&
  139. left < minHeap->size &&
  140. minHeap->array[left]->data < minHeap->array[smallest]->data
  141. )
  142. smallest = left;
  143.  
  144. if ( minHeap->array[right] &&
  145. right < minHeap->size &&
  146. minHeap->array[right]->data < minHeap->array[smallest]->data
  147. )
  148. smallest = right;
  149.  
  150. if (smallest != index)
  151. {
  152. // First swap indexes inside the List using address
  153. // of List nodes
  154. swapData(&(minHeap->array[smallest]->minHeapIndex),
  155. &(minHeap->array[index]->minHeapIndex));
  156.  
  157. // Now swap pointers to List nodes
  158. swapLNode(&minHeap->array[smallest],
  159. &minHeap->array[index]);
  160.  
  161. // Fix the heap downward
  162. minHeapify(minHeap, smallest);
  163. }
  164. }
  165.  
  166. // The standard maxHeapify function. The only thing it does extra
  167. // is swapping indexes of heaps inside the List
  168. void maxHeapify(struct MaxHeap* maxHeap, int index)
  169. {
  170. int largest, left, right;
  171. largest = index;
  172. left = 2 * index + 1;
  173. right = 2 * index + 2;
  174.  
  175. if ( maxHeap->array[left] &&
  176. left < maxHeap->size &&
  177. maxHeap->array[left]->data > maxHeap->array[largest]->data
  178. )
  179. largest = left;
  180.  
  181. if ( maxHeap->array[right] &&
  182. right < maxHeap->size &&
  183. maxHeap->array[right]->data > maxHeap->array[largest]->data
  184. )
  185. largest = right;
  186.  
  187. if (largest != index)
  188. {
  189. // First swap indexes inside the List using address
  190. // of List nodes
  191. swapData(&maxHeap->array[largest]->maxHeapIndex,
  192. &maxHeap->array[index]->maxHeapIndex);
  193.  
  194. // Now swap pointers to List nodes
  195. swapLNode(&maxHeap->array[largest],
  196. &maxHeap->array[index]);
  197.  
  198. // Fix the heap downward
  199. maxHeapify(maxHeap, largest);
  200. }
  201. }
  202.  
  203. // Standard function to insert an item in Min Heap
  204. void insertMinHeap(struct MinHeap* minHeap, struct LNode* temp)
  205. {
  206. if (isMinHeapFull(minHeap))
  207. return;
  208.  
  209. ++minHeap->size;
  210. int i = minHeap->size - 1;
  211. while (i && temp->data < minHeap->array[(i - 1) / 2]->data )
  212. {
  213. minHeap->array[i] = minHeap->array[(i - 1) / 2];
  214. minHeap->array[i]->minHeapIndex = i;
  215. i = (i - 1) / 2;
  216. }
  217.  
  218. minHeap->array[i] = temp;
  219. minHeap->array[i]->minHeapIndex = i;
  220. }
  221.  
  222. // Standard function to insert an item in Max Heap
  223. void insertMaxHeap(struct MaxHeap* maxHeap, struct LNode* temp)
  224. {
  225. if (isMaxHeapFull(maxHeap))
  226. return;
  227.  
  228. ++maxHeap->size;
  229. int i = maxHeap->size - 1;
  230. while (i && temp->data > maxHeap->array[(i - 1) / 2]->data )
  231. {
  232. maxHeap->array[i] = maxHeap->array[(i - 1) / 2];
  233. maxHeap->array[i]->maxHeapIndex = i;
  234. i = (i - 1) / 2;
  235. }
  236.  
  237. maxHeap->array[i] = temp;
  238. maxHeap->array[i]->maxHeapIndex = i;
  239. }
  240.  
  241.  
  242. // Function to find minimum value stored in the main data structure
  243. int findMin(struct MyDS* myDS)
  244. {
  245. if (isMinHeapEmpty(myDS->minHeap))
  246. return INT_MAX;
  247.  
  248. return myDS->minHeap->array[0]->data;
  249. }
  250.  
  251. // Function to find maximum value stored in the main data structure
  252. int findMax(struct MyDS* myDS)
  253. {
  254. if (isMaxHeapEmpty(myDS->maxHeap))
  255. return INT_MIN;
  256.  
  257. return myDS->maxHeap->array[0]->data;
  258. }
  259.  
  260. // A utility function to remove an item from linked list
  261. void removeLNode(struct List* list, struct LNode** temp)
  262. {
  263. if (hasOnlyOneLNode(list))
  264. list->head = NULL;
  265.  
  266. else if (!(*temp)->prev) // first node
  267. {
  268. list->head = (*temp)->next;
  269. (*temp)->next->prev = NULL;
  270. }
  271. // any other node including last
  272. else
  273. {
  274. (*temp)->prev->next = (*temp)->next;
  275. // last node
  276. if ((*temp)->next)
  277. (*temp)->next->prev = (*temp)->prev;
  278. }
  279. free(*temp);
  280. *temp = NULL;
  281. }
  282.  
  283. // Function to delete maximum value stored in the main data structure
  284. void deleteMax(struct MyDS* myDS)
  285. {
  286. MinHeap *minHeap = myDS->minHeap;
  287. MaxHeap *maxHeap = myDS->maxHeap;
  288.  
  289. if (isMaxHeapEmpty(maxHeap))
  290. return;
  291. struct LNode* temp = maxHeap->array[0];
  292.  
  293. // delete the maximum item from maxHeap
  294. maxHeap->array[0] =
  295. maxHeap->array[maxHeap->size - 1];
  296. --maxHeap->size;
  297. maxHeap->array[0]->maxHeapIndex = 0;
  298. maxHeapify(maxHeap, 0);
  299.  
  300. // remove the item from minHeap
  301. minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
  302. --minHeap->size;
  303. minHeap->array[temp->minHeapIndex]->minHeapIndex = temp->minHeapIndex;
  304. minHeapify(minHeap, temp->minHeapIndex);
  305.  
  306. // remove the node from List
  307. removeLNode(myDS->list, &temp);
  308. }
  309.  
  310. // Function to delete minimum value stored in the main data structure
  311. void deleteMin(struct MyDS* myDS)
  312. {
  313. MinHeap *minHeap = myDS->minHeap;
  314. MaxHeap *maxHeap = myDS->maxHeap;
  315.  
  316. if (isMinHeapEmpty(minHeap))
  317. return;
  318. struct LNode* temp = minHeap->array[0];
  319.  
  320. // delete the minimum item from minHeap
  321. minHeap->array[0] = minHeap->array[minHeap->size - 1];
  322. --minHeap->size;
  323. minHeap->array[0]->minHeapIndex = 0;
  324. minHeapify(minHeap, 0);
  325.  
  326. // remove the item from maxHeap
  327. maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
  328. --maxHeap->size;
  329. maxHeap->array[temp->maxHeapIndex]->maxHeapIndex = temp->maxHeapIndex;
  330. maxHeapify(maxHeap, temp->maxHeapIndex);
  331.  
  332. // remove the node from List
  333. removeLNode(myDS->list, &temp);
  334. }
  335.  
  336. // Function to enList an item to List
  337. void insertAtHead(struct List* list, struct LNode* temp)
  338. {
  339. if (isListEmpty(list))
  340. list->head = temp;
  341.  
  342. else
  343. {
  344. temp->next = list->head;
  345. list->head->prev = temp;
  346. list->head = temp;
  347. }
  348. }
  349.  
  350. // Function to delete an item from List. The function also
  351. // removes item from min and max heaps
  352. void Delete(struct MyDS* myDS, int item)
  353. {
  354. MinHeap *minHeap = myDS->minHeap;
  355. MaxHeap *maxHeap = myDS->maxHeap;
  356.  
  357. if (isListEmpty(myDS->list))
  358. return;
  359.  
  360. // search the node in List
  361. struct LNode* temp = myDS->list->head;
  362. while (temp && temp->data != item)
  363. temp = temp->next;
  364.  
  365. // if item not found
  366. if (!temp || temp && temp->data != item)
  367. return;
  368.  
  369. // remove item from min heap
  370. minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
  371. --minHeap->size;
  372. minHeap->array[temp->minHeapIndex]->minHeapIndex = temp->minHeapIndex;
  373. minHeapify(minHeap, temp->minHeapIndex);
  374.  
  375. // remove item from max heap
  376. maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
  377. --maxHeap->size;
  378. maxHeap->array[temp->maxHeapIndex]->maxHeapIndex = temp->maxHeapIndex;
  379. maxHeapify(maxHeap, temp->maxHeapIndex);
  380.  
  381. // remove node from List
  382. removeLNode(myDS->list, &temp);
  383. }
  384.  
  385. // insert operation for main data structure
  386. void Insert(struct MyDS* myDS, int data)
  387. {
  388. struct LNode* temp = newLNode(data);
  389.  
  390. // insert the item in List
  391. insertAtHead(myDS->list, temp);
  392.  
  393. // insert the item in min heap
  394. insertMinHeap(myDS->minHeap, temp);
  395.  
  396. // insert the item in max heap
  397. insertMaxHeap(myDS->maxHeap, temp);
  398. }
  399.  
  400. int main()
  401. {
  402. int n, k;
  403. int arr[500010];
  404. int max;
  405. while(1){
  406. scanf("%d%d", &n, &k);
  407.  
  408. if(n == 0 && k ==0)
  409. break;
  410. max = INT_MIN;
  411. struct MyDS *myDS = createMyDS(k);
  412.  
  413. for(int i = 0 ; i < n ; i++){
  414. scanf("%d", &arr[i]);
  415. }
  416.  
  417. for(int i = 0 ;i < k ; i++ ){
  418. Insert(myDS, arr[i]);
  419. int tmp = findMax(myDS) - findMin(myDS);
  420. if( tmp > max){
  421. max = tmp;
  422. }
  423. }
  424.  
  425. for(int i = k ;i < n ; i ++){
  426. Delete(myDS, arr[i - k]);
  427. Insert(myDS, arr[i]);
  428. //printf("arr[i - k ] : %d , findMax(myDS) : %d, findMin(myDS) : %d\n", arr[i - k ], findMax(myDS) , findMin(myDS));
  429. int tmp = findMax(myDS) - findMin(myDS);
  430. if( tmp > max){
  431. max = tmp;
  432. }
  433. }
  434.  
  435. printf("%d\n", max);
  436. //deleteMin(myDS);
  437. //Delete(myDS, 10);
  438. //findMax(myDS);
  439. //findMin(myDS);
  440.  
  441. free(myDS);
  442.  
  443. }
  444. return 0;
  445. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘deleteMax’:
prog.c:286:5: error: unknown type name ‘MinHeap’
     MinHeap *minHeap = myDS->minHeap;
     ^~~~~~~
prog.c:286:5: note: use ‘struct’ keyword to refer to the type
prog.c:286:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     MinHeap *minHeap = myDS->minHeap;
                        ^~~~
prog.c:287:5: error: unknown type name ‘MaxHeap’
     MaxHeap *maxHeap = myDS->maxHeap;
     ^~~~~~~
prog.c:287:5: note: use ‘struct’ keyword to refer to the type
prog.c:287:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     MaxHeap *maxHeap = myDS->maxHeap;
                        ^~~~
prog.c:289:24: warning: passing argument 1 of ‘isMaxHeapEmpty’ from incompatible pointer type [-Wincompatible-pointer-types]
     if (isMaxHeapEmpty(maxHeap))
                        ^~~~~~~
prog.c:110:5: note: expected ‘struct MaxHeap *’ but argument is of type ‘int *’
 int isMaxHeapEmpty(struct MaxHeap* heap)
     ^~~~~~~~~~~~~~
prog.c:291:33: error: request for member ‘array’ in something not a structure or union
     struct LNode* temp = maxHeap->array[0];
                                 ^~
prog.c:294:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[0] =
            ^~
prog.c:295:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[maxHeap->size - 1];
            ^~
prog.c:295:27: error: request for member ‘size’ in something not a structure or union
     maxHeap->array[maxHeap->size - 1];
                           ^~
prog.c:296:14: error: request for member ‘size’ in something not a structure or union
     --maxHeap->size;
              ^~
prog.c:297:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[0]->maxHeapIndex = 0;
            ^~
prog.c:298:16: warning: passing argument 1 of ‘maxHeapify’ from incompatible pointer type [-Wincompatible-pointer-types]
     maxHeapify(maxHeap, 0);
                ^~~~~~~
prog.c:168:6: note: expected ‘struct MaxHeap *’ but argument is of type ‘int *’
 void maxHeapify(struct MaxHeap* maxHeap, int index)
      ^~~~~~~~~~
prog.c:301:12: error: request for member ‘array’ in something not a structure or union
     minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
            ^~
prog.c:301:49: error: request for member ‘array’ in something not a structure or union
     minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
                                                 ^~
prog.c:301:64: error: request for member ‘size’ in something not a structure or union
     minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
                                                                ^~
prog.c:302:14: error: request for member ‘size’ in something not a structure or union
     --minHeap->size;
              ^~
prog.c:303:12: error: request for member ‘array’ in something not a structure or union
     minHeap->array[temp->minHeapIndex]->minHeapIndex = temp->minHeapIndex;
            ^~
prog.c:304:16: warning: passing argument 1 of ‘minHeapify’ from incompatible pointer type [-Wincompatible-pointer-types]
     minHeapify(minHeap, temp->minHeapIndex);
                ^~~~~~~
prog.c:131:6: note: expected ‘struct MinHeap *’ but argument is of type ‘int *’
 void minHeapify(struct MinHeap* minHeap, int index)
      ^~~~~~~~~~
prog.c: In function ‘deleteMin’:
prog.c:313:5: error: unknown type name ‘MinHeap’
     MinHeap *minHeap = myDS->minHeap;
     ^~~~~~~
prog.c:313:5: note: use ‘struct’ keyword to refer to the type
prog.c:313:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     MinHeap *minHeap = myDS->minHeap;
                        ^~~~
prog.c:314:5: error: unknown type name ‘MaxHeap’
     MaxHeap *maxHeap = myDS->maxHeap;
     ^~~~~~~
prog.c:314:5: note: use ‘struct’ keyword to refer to the type
prog.c:314:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     MaxHeap *maxHeap = myDS->maxHeap;
                        ^~~~
prog.c:316:24: warning: passing argument 1 of ‘isMinHeapEmpty’ from incompatible pointer type [-Wincompatible-pointer-types]
     if (isMinHeapEmpty(minHeap))
                        ^~~~~~~
prog.c:113:5: note: expected ‘struct MinHeap *’ but argument is of type ‘int *’
 int isMinHeapEmpty(struct MinHeap* heap)
     ^~~~~~~~~~~~~~
prog.c:318:33: error: request for member ‘array’ in something not a structure or union
     struct LNode* temp = minHeap->array[0];
                                 ^~
prog.c:321:12: error: request for member ‘array’ in something not a structure or union
     minHeap->array[0] = minHeap->array[minHeap->size - 1];
            ^~
prog.c:321:32: error: request for member ‘array’ in something not a structure or union
     minHeap->array[0] = minHeap->array[minHeap->size - 1];
                                ^~
prog.c:321:47: error: request for member ‘size’ in something not a structure or union
     minHeap->array[0] = minHeap->array[minHeap->size - 1];
                                               ^~
prog.c:322:14: error: request for member ‘size’ in something not a structure or union
     --minHeap->size;
              ^~
prog.c:323:12: error: request for member ‘array’ in something not a structure or union
     minHeap->array[0]->minHeapIndex = 0;
            ^~
prog.c:324:16: warning: passing argument 1 of ‘minHeapify’ from incompatible pointer type [-Wincompatible-pointer-types]
     minHeapify(minHeap, 0);
                ^~~~~~~
prog.c:131:6: note: expected ‘struct MinHeap *’ but argument is of type ‘int *’
 void minHeapify(struct MinHeap* minHeap, int index)
      ^~~~~~~~~~
prog.c:327:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
            ^~
prog.c:327:49: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
                                                 ^~
prog.c:327:64: error: request for member ‘size’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
                                                                ^~
prog.c:328:14: error: request for member ‘size’ in something not a structure or union
     --maxHeap->size;
              ^~
prog.c:329:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex]->maxHeapIndex = temp->maxHeapIndex;
            ^~
prog.c:330:16: warning: passing argument 1 of ‘maxHeapify’ from incompatible pointer type [-Wincompatible-pointer-types]
     maxHeapify(maxHeap, temp->maxHeapIndex);
                ^~~~~~~
prog.c:168:6: note: expected ‘struct MaxHeap *’ but argument is of type ‘int *’
 void maxHeapify(struct MaxHeap* maxHeap, int index)
      ^~~~~~~~~~
prog.c: In function ‘Delete’:
prog.c:354:5: error: unknown type name ‘MinHeap’
     MinHeap *minHeap = myDS->minHeap;
     ^~~~~~~
prog.c:354:5: note: use ‘struct’ keyword to refer to the type
prog.c:354:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     MinHeap *minHeap = myDS->minHeap;
                        ^~~~
prog.c:355:5: error: unknown type name ‘MaxHeap’
     MaxHeap *maxHeap = myDS->maxHeap;
     ^~~~~~~
prog.c:355:5: note: use ‘struct’ keyword to refer to the type
prog.c:355:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     MaxHeap *maxHeap = myDS->maxHeap;
                        ^~~~
prog.c:366:23: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
     if (!temp || temp && temp->data != item)
                  ~~~~~^~~~~~~~~~~~~~~~~~~~~
prog.c:370:12: error: request for member ‘array’ in something not a structure or union
     minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
            ^~
prog.c:370:49: error: request for member ‘array’ in something not a structure or union
     minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
                                                 ^~
prog.c:370:64: error: request for member ‘size’ in something not a structure or union
     minHeap->array[temp->minHeapIndex] = minHeap->array[minHeap->size - 1];
                                                                ^~
prog.c:371:14: error: request for member ‘size’ in something not a structure or union
     --minHeap->size;
              ^~
prog.c:372:12: error: request for member ‘array’ in something not a structure or union
     minHeap->array[temp->minHeapIndex]->minHeapIndex = temp->minHeapIndex;
            ^~
prog.c:373:16: warning: passing argument 1 of ‘minHeapify’ from incompatible pointer type [-Wincompatible-pointer-types]
     minHeapify(minHeap, temp->minHeapIndex);
                ^~~~~~~
prog.c:131:6: note: expected ‘struct MinHeap *’ but argument is of type ‘int *’
 void minHeapify(struct MinHeap* minHeap, int index)
      ^~~~~~~~~~
prog.c:376:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
            ^~
prog.c:376:49: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
                                                 ^~
prog.c:376:64: error: request for member ‘size’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex] = maxHeap->array[maxHeap->size - 1];
                                                                ^~
prog.c:377:14: error: request for member ‘size’ in something not a structure or union
     --maxHeap->size;
              ^~
prog.c:378:12: error: request for member ‘array’ in something not a structure or union
     maxHeap->array[temp->maxHeapIndex]->maxHeapIndex = temp->maxHeapIndex;
            ^~
prog.c:379:16: warning: passing argument 1 of ‘maxHeapify’ from incompatible pointer type [-Wincompatible-pointer-types]
     maxHeapify(maxHeap, temp->maxHeapIndex);
                ^~~~~~~
prog.c:168:6: note: expected ‘struct MaxHeap *’ but argument is of type ‘int *’
 void maxHeapify(struct MaxHeap* maxHeap, int index)
      ^~~~~~~~~~
stdout
Standard output is empty