0% found this document useful (0 votes)
156 views

Assignment 2 Algorithms and Data Types

The document discusses using different data structures for a library reminder system in Java. 1) A singly linked list (SLL) is proposed to store reminder items, with the ability to insert nodes at the beginning of the list or after a given node. 2) An array-based queue is described to send book reminders when they are due, with reminders added to the back of the queue. 3) A binary search tree (BST) could store library items, with the root node at the top connecting to left and right child nodes to efficiently search for items. The Java code provided tests inserting and searching nodes in the BST.

Uploaded by

Arash Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views

Assignment 2 Algorithms and Data Types

The document discusses using different data structures for a library reminder system in Java. 1) A singly linked list (SLL) is proposed to store reminder items, with the ability to insert nodes at the beginning of the list or after a given node. 2) An array-based queue is described to send book reminders when they are due, with reminders added to the back of the queue. 3) A binary search tree (BST) could store library items, with the root node at the top connecting to left and right child nodes to efficiently search for items. The Java code provided tests inserting and searching nodes in the BST.

Uploaded by

Arash Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Algorithms and Data Types

In this assignment, I am going to create a Library using java, the system will comprise of a way of
reminding people that they borrowed certain books and they are due in 14 days.]

Q.1 Create a (SLL) data type to store reminders.

i) At the beginning of the list.

ii)After a given reminder node.

Write a java application to test your algorithm

The Reminder class may implement the following interface type:

Public interface ReminderItem {

Public void setDescprition (String value);

Public String getDescpription ();

Public int getId ();

Public void setId ();

Public Date get Reminder Date ();

Public void setReminderDate (Date);

}
Header First Node Second Node

Link list is how items can be stored in a sequence if connected through a header and nodes.
SLL (Singly-Linked List

Creating SLL, beginning with an empty node constructor, this can allow me to insert, print and delete
any giving elements of the projects.

Java implementation

New node creation

New insert node,presdecessor to the node.

Testing Application
Q>2

As part of the Information System for the Library, it is required to send reminders for books not returned
when time is due. Write an Array based queue for storing reminders. Write a Java application to test the
queue.

For this part of the project I am required to use the query concepts for the reminders so that the
reminder would flow one other each other.

Queue

Queue Array would work constructed on the beginning for each element which can only added to the
back of the queue.

Testing the Application

Q3

Explain how a Binary Search Tree may be used as a part of an Information System for the Library. As part
of your answer, illustrate how such a tree may be populated.

Binary Search Tree {BST}

Binary Search Tree is a link which comprises a header and other elements which are linked through a
root node which lead to nodes.

BST populated.
Java Application Test

Explanation of the codes>

Creation of BST with the Private Root setting and only accessed within the class.
BST Node search

BST Node contains two parameters comparable and the expected aim,To begain the
eelement;the array will set a element roots position,so it can contiune with the statement to
find the required element by the checking the correct element.

Insert BST
This aslo comprise of the parameters comparable for the the target being searched for,form the sart of
the element in the array and BST equal null parent.The new element is inserted as a new node while
checking the current BST link tree if it is empty, if any element is available this will make it decide
wheather to go left or right of the node within the node.

The Algorithm set the direction beign compared to the current element

Bst node Class

Shows the class,which will enable the delation of the Left most and Get most within the BST class.

You might also like