Sample Sample Final Exam COMP2521
[Instructions] [C language]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8]

Question 2

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  ... 


#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;