DSA Project
DSA Project
➢ Team members:
Rajvi Patel-1741078
Krushna Shah-1741086
Kalagee Anjaria-1741052
● Brief Description:
Our main objective in this project is to create a library management
system wherein students can issue books and the admin or librarian
can update/delete the record of books kept in the library.
So we have the system into two parts : from user’s perspective and
from admin’s perspective.
First of all, the admin must login to handle the accounts where the
username and password are already set. After he has logged in
successfully, he can add, delete and update the books. He can add
any new book in the already existing list of books. Similarly he can
also delete any existing book. In the update option, the admin can
update the quantity of books as well as the name of the book. As
and when the admin adds the books, a binary search tree will be
created where the nodes contain the name of books and are put in
sorted order.
2) Hash-map:
Generally Hash-map, maps keys to values such that no
duplicate keys are generated. So, in our project, unique
keys are generated using hash map and it is assigned to
every book such that using this keys we can store and
fetch records of books in 2-D array.
3) 2-D array
Here, we have used 2-D array to store the record of each book
where rows indicate unique value for particular book which
hash-map returns and columns indicate total quantity of books
and availbale quantity of books.
Insertion:
We are using insertion operation to add books in the binary
search tree. And the tree will contain the name of the added
books.
Deletion:
We use deletion operation to delete the node of that particular
book from the binary search tree. After the node is deleted, the
remaining elements are again rearranged in the tree.
Updation:
The librarian can upate the quantity of already existing set of
books which is stored in the 2D array.
List or print all the values:
There is also an option where all the details of the books are
printed. Name of the book, available quantity of the books that
can be issued and total number of books that library has.
Filename: finaldsa.java
Source codes:
Insertion:
return root;
}
Deletion:
//If book name < root then search it at left side and delete
if (key.compareTo(root.key)<0)
root.left = deleteRec(root.left, key);
//If book name > root then search it at right side and delete
else if (key.compareTo(root.key)<0)
root.right = deleteRec(root.right, key);
else
{
if (root.left == null)
return root.right;
else if (root.right == null)
return root.left;
root.key = minValue(root.right);
return root;
}
String minValue(Node root)
{
String minv = root.key;
while (root.left != null)
{
minv = root.left.key;
root = root.left;
}
return minv;
}
Updation:
void printTree()
{
root = printTreeRec(root, 0);
}
space += 5;
printTreeRec(t.right ,space);
System.out.println();
Print in-order:
printInorder(node.left);
printInorder(node.right);
}
void printInorder()
{
printInorder(root);
}
void inorder()
{
inorderRec(root);
}
void inorderRec(Node root)
{
if (root != null)
{
inorderRec(root.left);
System.out.println(root.key);
inorderRec(root.right);
}
}
1) Add book
Input data
Enter name of the book:
Enter quantity of book:
Output generated
Book added successfully...
2) Delete book
Input data
Enter name of the book:
Enter quantity of book:
Output generated
Book deleted successfully...
2) Update book
Input data
Enter name of book:
Enter quantity of book to add more:
Output generated
Successfully updated...
4) Print book details
Output generated
All the details of book will be printed
Output generated
The list of all books will be printed in ascending order of their
names as it is balanced binary search tree (Balanced BST).
6) Print tree
Output generated
Balanced binary search tree is printed
Input data
Enter your university ID:
Enter name of book:
Output generated
Book issued successfully!!
Current date time:
Due date and time:
8) Return book:
Input data
Enter your university ID:
Enter name of book:
Output generated
Book returned successfully!!
Current date time:
Return date and time:
References: