Commit 32c6411
committed
feat: add PriorityQueueBasedOnNaturalOrdering demonstrating Java PriorityQueue behavior
Implemented PriorityQueueBasedOnNaturalOrdering.java to showcase natural ordering
(min-heap) behavior of PriorityQueue. Demonstrates insertion, polling, and iteration
order, explaining that elements are ordered by natural order (lowest first for numbers)
and can be customized using comparators. Includes notes on internal heap structure
and O(log n) insertion complexity.
Signed-off-by: https://github.com/Someshdiwan <someshdiwan369@gmail.com>1 parent 143f0d6 commit 32c6411
1 file changed
Lines changed: 13 additions & 7 deletions
File tree
- Section 25 Collections Frameworks/Queue Interface/Priority Queue/src
Lines changed: 13 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | | - | |
24 | 28 | | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
29 | | - | |
| 35 | + | |
0 commit comments