Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The main issue I am having with the assignment is creating the class, (the .h an

ID: 3658857 • Letter: T

Question

The main issue I am having with the assignment is creating the class, (the .h and .cpp file for the Binary Tree), supposedly I have to pass in pointers from my link list to be stored as data in my tree, however I do not know where to begin. The assignment is below so you can get a better idea of what I must do. In this assignment you are going to create indices for your Catalog of Books for the library. 1. Create a base class to represent a Binary Search Tree a. The objects to be stored are pointers to Books (so that you do not duplicate Books) b. You should have only one add method that adds a book to a tree and specifies a sort order c. You should have different comparison methods for comparing books by: i. Primary: Author / Secondary: Title, Language Year ii. Primary: Title / Secondary: Author, Year iii. Primary: Language / Secondary: Year, Author, Title d. You should have a print function to print out the tree in ascending order e. You should have a check balance function to estimate how well your tree is balanced (basically compares the depth of and number of node in the right and left subtrees) three indices for your Catalog using your BST class 2. Create a. One each by Author, Title, Language 3. In your main a. Read the file and create the Catalog and indices b. Print out your catalog c. Print out each of your indices in ascending order d. Demonstrate each of your search routines

Explanation / Answer

class Node { Node *prev, *next; int value; } void listToTree(Node * head) { if (head == null) return; if (head->next == head) { head->prev = null; head->next = null; return head; } if (head->next->next == head) { head->prev = null; head->next->next = null; head->next->prev = null; return head; } Node *p1 = head, *p2 = head->prev; while (p1->value next, p2 = p2->prev; Node * root = p1; root->prev->next = head; root->next->prev = head->prev; root->prev = listToTree(head); root->next = listToTree(root->next); return root; }