{"id":99312,"date":"2022-10-13T09:53:47","date_gmt":"2022-10-13T09:53:47","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/data-structure-and-algorithm-heap\/"},"modified":"2022-10-13T09:53:47","modified_gmt":"2022-10-13T09:53:47","slug":"data-structure-and-algorithm-heap","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/data-structure-and-algorithm-heap\/","title":{"rendered":"Data structure and algorithm heap"},"content":{"rendered":"<div>\n<p>\u00a0<\/p>\n<p>Can someone help me with this?<\/p>\n<p>\u200b\u200b\u200b\u200b\u200b\u200b\u200b<img loading=\"lazy\" decoding=\"async\" alt=\"Points: 100 Topics: MaxHeap, array resizing For this assignment you will: - represent a heap using the struct defined at the\" src=\"https:\/\/media.cheggcdn.com\/media\/149\/14913f3b-2e6d-4887-b4ef-dddac6eafdf6\/phpZ4NRXh\" width=\"1883\" height=\"817\"\/><img loading=\"lazy\" decoding=\"async\" alt=\"Format of test files: where the first 2 lines specify an array of ( mathrm{N} ) integers and the next 2 lines specify ( \" src=\"https:\/\/media.cheggcdn.com\/media\/405\/4053f180-1b05-4ed1-8c91-1d21da220b8a\/phpMqkxEZ\" width=\"1601\" height=\"877\"\/><img loading=\"lazy\" decoding=\"async\" alt=\"1. Write your name at the top of each .c file you submit and use good coding style: indentation, variable names. Points will\" src=\"https:\/\/media.cheggcdn.com\/media\/b2d\/b2d424c4-e047-4f49-a0f6-c7a014619190\/phpxH7Lm6\" width=\"1895\" height=\"601\"\/><\/p>\n<pre><code>heap.h<br\/>#ifndef HEAP_H<br\/>#define\tHEAP_H<p>struct heap_struct {<br\/>int* items;<br\/>int N; \u00a0\/\/ current size<br\/>int capacity; \/\/ array capacity<br\/>};<\/p><p>\/\/ max-heap operations<\/p><p>struct heap_struct make_heap_empty(int cap);<\/p><p>\/\/ assumes arr was dynamically allocated. <br\/>struct heap_struct make_heap(int N, int * arr); \/\/ makes a max-heap from arr. Asssumes both size and capacity are N.<\/p><p>\/\/ Will free the heap array.<br\/>void destroy(struct heap_struct * heapP);<\/p><p>void print_heap(struct heap_struct heapS);<\/p><p>void sink_down(int i, int N, int * arr);<br\/>void swim_up(int idx, int * arr);<\/p><p>int peek(struct heap_struct heapS);<br\/>int poll(struct heap_struct * heapP);<br\/>void add(struct heap_struct * heapP, int new_item);\/\/ will resize the heap if needed<\/p><p>#endif\t\/* HEAP_H *\/<\/p><\/code><\/pre>\n<pre><code><br\/>heap_calls.c<p>\/* compile: <br\/>gcc -g heap_calls.c heap.c<br\/>run:<br\/>.\/a.out <\/p><p>Valgrind:<br\/>valgrind --leak-check=full .\/a.out <br\/>* <br\/>*\/<\/p><p>#include &lt;stdlib.h&gt;<br\/>#include &lt;stdio.h&gt;<br\/>#include &lt;string.h&gt;<\/p><p>#include \"heap.h\" \u00a0<\/p><p>int main() \u00a0\u00a0{<br\/>int N,k,i;<br\/>char fname[501];<br\/>int debug = 0;<br\/>struct heap_struct heapS;<br\/>printf(\"This program will call the heap functions.n \"); \u00a0\u00a0<br\/>\u00a0\u00a0<\/p><p>N = 3;<br\/>int *arr = (int*) calloc(N, sizeof(int) );<br\/>arr[0] = 10;<br\/>arr[1] = 20;<br\/>arr[2] = 43;<\/p><p>heapS = make_heap(N, arr); \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<br\/>print_heap(heapS);<\/p><p>printf(\"removed: %6dn\", poll(&amp;heapS) );\t<br\/>print_heap(heapS);<\/p><p>printf(\"peek: \u00a0\u00a0\u00a0%6dn\", peek(heapS) );<br\/>print_heap(heapS);<\/p><p>printf(\"add: \u00a0\u00a0\u00a0\u00a0%6dn\", 17);\t<br\/>add(&amp;heapS, 17);<br\/>print_heap(heapS);<\/p><p>printf(\"removed: %6dn\", poll(&amp;heapS) );\t<br\/>print_heap(heapS);<\/p><p>printf(\"removed: %6dn\", poll(&amp;heapS) );\t<br\/>print_heap(heapS);<br\/>\u00a0\u00a0<br\/>destroy(&amp;heapS); \u00a0\u00a0<br\/>printf(\"After call to destroy (1)n\");<br\/>print_heap(heapS);<br\/>\u00a0\u00a0<br\/>heapS = make_heap_empty(11);<br\/>printf(\"Created empty heap: n\");<br\/>print_heap(heapS);<\/p><p>printf(\"add: \u00a0\u00a0\u00a0\u00a0%6dn\", 204);\t<br\/>add(&amp;heapS, 204);<br\/>print_heap(heapS);\t<\/p><p>destroy(&amp;heapS); \u00a0\u00a0<br\/>printf(\"After call to destroy(2)n\");<br\/>print_heap(heapS);<\/p><p>destroy(&amp;heapS); \u00a0\u00a0<br\/>printf(\"After call to destroy(3)n\");<br\/>print_heap(heapS);<\/p><p>return 0;<br\/>}<\/p><\/code><\/pre>\n<pre><code>heap_calls.c heap.c<br\/>gcc -g heap_calls.c heap.c<br\/>valgrind --leak-check=full .\/a.out<br\/>==185== Memcheck, a memory error detector<br\/>==185== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.<br\/>==185== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info<br\/>==185== Command: .\/a.out<br\/>==185==<br\/>This program will call the heap functions.<br\/>in function make_heap, in DEBUG MODE, printing array BEFORE it gets turned into a heap :<br\/>Heap: \u00a0size: 3, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a043,<p>in function make_heap, in DEBUG MODE, printing array after sink_down at index 0.<br\/>Heap: \u00a0size: 3, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a043, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010,<\/p><p>Heap: \u00a0size: 3, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a043, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010,<\/p><p>removed: \u00a0\u00a0\u00a0\u00a043<br\/>Heap: \u00a0size: 2, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010,<\/p><p>peek: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a020<br\/>Heap: \u00a0size: 2, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010,<\/p><p>add: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a017<br\/>Heap: \u00a0size: 3, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a017,<\/p><p>removed: \u00a0\u00a0\u00a0\u00a020<br\/>Heap: \u00a0size: 2, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a017, \u00a0\u00a0\u00a0\u00a010,<\/p><p>removed: \u00a0\u00a0\u00a0\u00a017<br\/>Heap: \u00a0size: 1, capacity : 3<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a010,<\/p><p>After call to destroy (1)<br\/>Heap: \u00a0size: 0, capacity : 0<br\/>indexes:<br\/>values:<\/p><p>Created empty heap:<br\/>Heap: \u00a0size: 0, capacity : 11<br\/>indexes:<br\/>values:<\/p><p>add: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0204<br\/>Heap: \u00a0size: 1, capacity : 11<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0204,<\/p><p>After call to destroy(2)<br\/>Heap: \u00a0size: 0, capacity : 0<br\/>indexes:<br\/>values:<\/p><p>After call to destroy(3)<br\/>Heap: \u00a0size: 0, capacity : 0<br\/>indexes:<br\/>values:<\/p><p>==185==<br\/>==185== HEAP SUMMARY:<br\/>==185== \u00a0\u00a0\u00a0\u00a0in use at exit: 0 bytes in 0 blocks<br\/>==185== \u00a0\u00a0total heap usage: 3 allocs, 3 frees, 1,080 bytes allocated<br\/>==185==<br\/>==185== All heap blocks were freed -- no leaks are possible<br\/>==185==<br\/>==185== For lists of detected and suppressed errors, rerun with: -s<br\/>==185== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)<\/p><\/code><\/pre>\n<pre><code>heap.c<br\/>\u200b\u200b\u200b\u200b\u200b\u200b\u200b#include &lt;stdlib.h&gt;<br\/>#include &lt;stdio.h&gt;<p>#include \"heap.h\" \u00a0<\/p><p>#define DEBUG 1<\/p><p>\/*<br\/>struct heap_struct make_heap_empty(int cap){<br\/>}<\/p><p>struct heap_struct make_heap(int N, int * arr){<br\/>}<\/p><p>void destroy(struct heap_struct * heapP){<br\/>}<\/p><p>void print_heap(struct heap_struct heapS){<br\/>}<\/p><p>void swim_up(int idx, int * arr){<br\/>}<\/p><p>void sink_down(int i, int N, int * arr){<br\/>}<\/p><p>void add(struct heap_struct * heapP, int new_item){<br\/>}<\/p><p>int peek(struct heap_struct heapS){<br\/>}<\/p><p>int poll(struct heap_struct * heapP){<br\/>}<\/p><p>*\/<\/p><\/code><\/pre>\n<p>all_opt.txt<\/p>\n<pre><code>5<br\/>10 40 20 50 90<br\/>6<br\/>13 * 82 p P *<\/code><\/pre>\n<p>empty.txt<\/p>\n<pre><code>2<br\/>10 40<br\/>10<br\/>* * * * 12 * 85 39 * *<\/code><\/pre>\n<p>resize.txt<\/p>\n<pre><code>2<br\/>10 40<br\/>9<br\/>5 -6 85 1 2 3 4 5 6\u00a0<\/code><\/pre>\n<p>\/\/ run all_opt.txt example<\/p>\n<pre><code>gcc -g run_test.c heap.c<br\/>valgrind --leak-check=full .\/a.out<br\/>==170== Memcheck, a memory error detector<br\/>==170== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.<br\/>==170== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info<br\/>==170== Command: .\/a.out<br\/>==170==<br\/>This program will create a max-heap and perform operations on it based on data from a file.<p>Enter the filename: all_ops.txt<br\/>in function make_heap, in DEBUG MODE, printing array BEFORE it gets turned into a heap :<br\/>Heap: \u00a0size: 5, capacity : 5<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a090,<\/p><p>in function make_heap, in DEBUG MODE, printing array after sink_down at index 1.<br\/>Heap: \u00a0size: 5, capacity : 5<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a090, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a040,<\/p><p>in function make_heap, in DEBUG MODE, printing array after sink_down at index 0.<br\/>Heap: \u00a0size: 5, capacity : 5<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a090, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a040,<\/p><p>Heap: \u00a0size: 5, capacity : 5<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a090, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a040,<\/p><p>Operation number 1, string: 13<br\/>add: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a013<\/p><p>resizing<br\/>Heap: \u00a0size: 6, capacity : 10<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04, \u00a0\u00a0\u00a0\u00a0\u00a05,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a090, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a013,<\/p><p>Operation number 2, string: *<br\/>removed: \u00a0\u00a0\u00a0\u00a090<br\/>Heap: \u00a0size: 5, capacity : 10<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a013,<\/p><p>Operation number 3, string: 82<br\/>add: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a082<br\/>Heap: \u00a0size: 6, capacity : 10<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04, \u00a0\u00a0\u00a0\u00a0\u00a05,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a082, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a013, \u00a0\u00a0\u00a0\u00a020,<\/p><p>Operation number 4, string: p<br\/>peek: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a082<br\/>Heap: \u00a0size: 6, capacity : 10<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04, \u00a0\u00a0\u00a0\u00a0\u00a05,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a082, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a013, \u00a0\u00a0\u00a0\u00a020,<\/p><p>Operation number 5, string: P<br\/>peek: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a082<br\/>Heap: \u00a0size: 6, capacity : 10<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04, \u00a0\u00a0\u00a0\u00a0\u00a05,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a082, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a013, \u00a0\u00a0\u00a0\u00a020,<\/p><p>Operation number 6, string: *<br\/>removed: \u00a0\u00a0\u00a0\u00a082<br\/>Heap: \u00a0size: 5, capacity : 10<br\/>indexes: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00, \u00a0\u00a0\u00a0\u00a0\u00a01, \u00a0\u00a0\u00a0\u00a0\u00a02, \u00a0\u00a0\u00a0\u00a0\u00a03, \u00a0\u00a0\u00a0\u00a0\u00a04,<br\/>values: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a050, \u00a0\u00a0\u00a0\u00a040, \u00a0\u00a0\u00a0\u00a020, \u00a0\u00a0\u00a0\u00a010, \u00a0\u00a0\u00a0\u00a013,<\/p><p>==170==<br\/>==170== HEAP SUMMARY:<br\/>==170== \u00a0\u00a0\u00a0\u00a0in use at exit: 0 bytes in 0 blocks<br\/>==170== \u00a0\u00a0total heap usage: 6 allocs, 6 frees, 6,676 bytes allocated<br\/>==170==<br\/>==170== All heap blocks were freed -- no leaks are possible<br\/>==170==<br\/>==170== For lists of detected and suppressed errors, rerun with: -s<br\/>==170== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)<\/p><\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 Can someone help me with this? \u200b\u200b\u200b\u200b\u200b\u200b\u200b heap.h#ifndef HEAP_H#define HEAP_Hstruct heap_struct {int* items;int N; \u00a0\/\/ current sizeint capacity; \/\/ array capacity};\/\/ max-heap operationsstruct heap_struct make_heap_empty(int cap);\/\/ assumes arr was dynamically allocated. struct heap_struct make_heap(int N, int * arr); \/\/ makes a max-heap from arr. Asssumes both size and capacity are N.\/\/ Will free the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-99312","post","type-post","status-publish","format-standard","hentry","category-education"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/99312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=99312"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/99312\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=99312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=99312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=99312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}