This assignment is for you to gain hands-on experiences of our weekly (week 9) covered topics including Queue, Heap, and Priority Queue. In this assignment, you need to write Java programs that meet the following requirements:
=== Basic Requirements (100 ‘pts) ===
1) (50 ‘pts) Implement a MyQueue class that supports the following interfaces within O(1) time:
1.1) int size(); //return the total number of stored elements
1.2) boolean isEmpty(); //return if the queue is empty
1.3) void offer(E val); //enqueue an element val for generic type E
1.4) E poll(); //remove head and return the removed value, return null if isEmpty()
1.5) E peek(); //return head, return null if isEmpty()
2) (50 ‘pts) Based on our class demonstration of MinHeap implementation, write a MaxHeap class that at least supports all the queue interfaces stated above as in 1).
=== Bonus (20 ‘pts) ===
a) (10 ‘pts) In the above requirement 2) MaxHeap, can you implement a class method: heapify(E[] arr) that takes in an array input, and transfer that array into a max heap?
b) (10 ‘pts) Inspired by the above practices, now revisite Leetcode 912. Sort An Array, this time use heap sort to conquer this coding challenge. Make sure your submission passes all Leetcode test cases.
Object oriented with java
Our Service Charter
1. Professional & Expert Writers: Topnotch Essay only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.
2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.
3. Plagiarism-Free Papers: All papers provided byTopnotch Essay are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.
4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Topnotch Essay is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.
5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.
6. 24/7 Customer Support: At Topnotch Essay, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.
Topnotchessay.org ©2025 All rights reserved. Terms of use | Privacy Policy

Recent Comments