This project implements a priority queue based on a linked list to manage and sort House objects by their value. The priority queue allows for adding houses, retrieving and removing the most expensive house, and testing various functionalities such as deep copying and queue length.
src/main/java/org/education/House.java: Defines theHouseclass with attributes for owner and value, including constructors, getters/setters, and methods for deep copying and equality checks.PriorityQueue.java: Interface defining the priority queue operations.PriorityQueueList.java: Implements thePriorityQueueinterface using a custom linked list.Main.java: The main class for executing the program, reading from an input file, populating the priority queue, and demonstrating various functionalities.
houses.txt: The input file containing data for 1000 houses. Each house entry consists of an owner and a value on separate lines.README.md: This file.
- Priority Queue Implementation: A linked list-based priority queue for managing
Houseobjects. - Dynamic Data Handling: Reads house data from an input file and populates the queue.
- Data Retrieval: Removes and displays houses in descending order of their value.
- Copy and Deep Copy: Demonstrates the use of copy constructors and deep copy methods.
-
Ensure JDK 21+ is Installed: This project requires JDK 21 or higher.
-
Build the Project:
- Use Maven or your preferred build tool to compile the project.
-
Run the Main Class:
- Execute the
Mainclass to see the priority queue in action.
- Execute the
- The
houses_input.txtfile should follow this format: - Each house entry consists of an owner and a value, with each pair of lines corresponding to a single house.
The Main class performs the following tests:
- Initialization: Loads data from the
houses.txtfile and populates the priority queue. - Queue Operations: Retrieves and removes houses in descending order of value.
- Copy Operations: Demonstrates the use of copy constructors and deep copy methods.
- Queue Management: Displays the queue length before and after removing all items.
Nav Singh GitHub Profile