A binary tree is a data structure where each node has at most two child nodes. The following defines a binary tree where each node stores a book record. The left-child of a node stores a book with an earlier publishing year while the right-child of a node stores a book with a later publishing year. struct book { char* name; int year; } typedef struct tnode { struct book *aBook; struct tnode *left; struct tnode *right; } BTree; Implement the following C functions: • BTree* addBook (BTree* nodeP, char* name, int year): It creates a new BTree if it is empty. Otherwise, it adds the book record to the correct position in the BTree. • void freeBTree (BTree* books). It frees the memory space being allocated for the passed BTree argument. • void printBooks (BTree* books). It prints the books stored in the passed BTree argument in year. Use the following 4 books to test your code: • The C Programming Language, 1990. • JavaScript: The Good Parts, 2008. • Accelerated C++: Practical Programming by Example, 2000. • Scala for the Impatient, 2012

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
A binary tree is a data structure where each node has at most two child
nodes. The following defines a binary tree where each node stores a book
record. The left-child of a node stores a book with an earlier publishing year
while the right-child of a node stores a book with a later publishing year.
struct book {
char* name;
int year;
}
typedef struct tnode {
struct book *aBook;
struct tnode *left;
struct tnode *right;
} BTree;
Implement the following C functions:
• BTree* addBook (BTree* nodeP, char* name, int year): It creates
a new BTree if it is empty. Otherwise, it adds the book record to the
correct position in the BTree.
• void freeBTree (BTree* books). It frees the memory space being
allocated for the passed BTree argument.
• void printBooks (BTree* books). It prints the books stored in the
passed BTree argument in year.
Use the following 4 books to test your code:
• The C Programming Language, 1990.
• JavaScript: The Good Parts, 2008.
• Accelerated C++: Practical Programming by Example, 2000.
• Scala for the Impatient, 2012
Transcribed Image Text:A binary tree is a data structure where each node has at most two child nodes. The following defines a binary tree where each node stores a book record. The left-child of a node stores a book with an earlier publishing year while the right-child of a node stores a book with a later publishing year. struct book { char* name; int year; } typedef struct tnode { struct book *aBook; struct tnode *left; struct tnode *right; } BTree; Implement the following C functions: • BTree* addBook (BTree* nodeP, char* name, int year): It creates a new BTree if it is empty. Otherwise, it adds the book record to the correct position in the BTree. • void freeBTree (BTree* books). It frees the memory space being allocated for the passed BTree argument. • void printBooks (BTree* books). It prints the books stored in the passed BTree argument in year. Use the following 4 books to test your code: • The C Programming Language, 1990. • JavaScript: The Good Parts, 2008. • Accelerated C++: Practical Programming by Example, 2000. • Scala for the Impatient, 2012
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY