Sample | Sample Final Exam | COMP2521 |
In this question you need to implement the following function, called isHeap. The function isHeap accepts one argument, that is a complete binary tree t, and returns 1 if the given complete binary tree t is a heap (max-heap), 0 otherwise.
int isHeap(BTree t);
Like in your lab exams, the required supporting files will be provided for such a question in the exam. For this practice question, you can assume that the following Btree.h file is available:
// Btree.h : Binary Tree ADT ... #include#include #include #define data(tree) ((tree)->data) #define left(tree) ((tree)->left) #define right(tree) ((tree)->right) typedef struct Node *BTree; typedef struct Node { int data; BTree left, right; } Node;