CSC248 Lab Assignment 7 – Binary Search Tree solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

1. Given the following Book, TreeNode and bookRecord ADTs:
class Book
{
private int serialNum;
private String title;
private String author;
private char code;

private String publisher;
private int year;
public Book()
{ }
public setData(int sn,String t,String a,char c,String p, int y)
{
//method definition
}
public int getSerialNum() { return serialNum; }
public String getTitle() { return title; }
public String getAuthor() { return author; }
public char getCode() { return code; }
public String getPublisher() { return publisher; }
public int getYear() { return year; }
}

class TreeNode
{
// data declaration
public TreeNode(object elem)
{
//method definition
}
public void insert(object elem)
{
//method definition
}
}

public class bookRecord
{
private TreeNode root;
public bookRecord(){ } //constructor
public void countBookCode() //to count the number of books for
//every code
{
//method definition
}
public void searchBook(int) //to search a book based on
//searching index
{
//method definition
}
public void displayAll() //display book information
{
//method definition
}
………
………
}

The information to be stored in the bookRecord are serial number, book title, author,
publisher, year of the book published. For example, you are given the following data.

SerialNum Title Author Code Publisher Year
1217 Bunga Dedap Daud Kamal A Sejana 1998
1324 Fizik Prof. Bun Tat C Mc Graw 2000
1001 Kimia Prof. Kamarul C Anderson 2001
1009 Botani Puan Salmah E Mutiara 1999
0781 Komputer Dr Abu D Deitel 2001
4320 Sosial Dr Kamariah B Mutiara 1998
2700 Ilmu Alam Dr Kamarudin A Mutiara 1999
1243 Sejarah Puan Kalsom B Tamadun 1989

a) Write a complete program for above classes to make the binary search tree can be
implemented. Then. Store some data in the binary search tree based on SerialNum.
b) Write the definition for countBookCode to count and return the number of book for book
code A, B, C and D in the tree.

c) Write the definition for searchBook to display the book information based on the
SerialNum.
d) Write the definition for displayAll to display all the book information in BST.

2. By referring to the Final Assessment Paper (FEBRUARY 2023), QUESTION 3 (b). Write a
complete Java program.

3. By referring to the Final Assessment Paper (JULY 2023), QUESTION 3 (b). Write a
complete Java program.