mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-02-02 19:46:13 +08:00
chore: fix typos in src/main/java/com/thealgorithms/datastructures/queues/PriorityQueues.java (#7028)
Fix typos in src/main/java/com/thealgorithms/datastructures/queues/PriorityQueues.java Co-authored-by: a <19151554+alxkm@users.noreply.github.com>
This commit is contained in:
@@ -9,7 +9,7 @@ package com.thealgorithms.datastructures.queues;
|
||||
* give numbers that are bigger, a higher priority. Queues in theory have no
|
||||
* fixed size but when using an array implementation it does.
|
||||
* <p>
|
||||
* Additional contibutions made by: PuneetTri(https://github.com/PuneetTri)
|
||||
* Additional contributions made by: PuneetTri(https://github.com/PuneetTri)
|
||||
*/
|
||||
class PriorityQueue {
|
||||
|
||||
@@ -32,8 +32,8 @@ class PriorityQueue {
|
||||
|
||||
PriorityQueue() {
|
||||
/* If capacity is not defined, default size of 11 would be used
|
||||
* capacity=max+1 because we cant access 0th element of PQ, and to
|
||||
* accomodate (max)th elements we need capacity to be max+1.
|
||||
* capacity=max+1 because we can't access 0th element of PQ, and to
|
||||
* accommodate (max)th elements we need capacity to be max+1.
|
||||
* Parent is at position k, child at position (k*2,k*2+1), if we
|
||||
* use position 0 in our queue, its child would be at:
|
||||
* (0*2, 0*2+1) -> (0,0). This is why we start at position 1
|
||||
@@ -127,7 +127,7 @@ class PriorityQueue {
|
||||
if (isEmpty()) {
|
||||
throw new RuntimeException("Queue is Empty");
|
||||
} else {
|
||||
int max = queueArray[1]; // By defintion of our max-heap, value at queueArray[1] pos is
|
||||
int max = queueArray[1]; // By definition of our max-heap, value at queueArray[1] pos is
|
||||
// the greatest
|
||||
|
||||
// Swap max and last element
|
||||
|
||||
Reference in New Issue
Block a user