PriorityQueue<TElement, TPriority>.Remove
method violates min-heap invariant
#107292
Labels
Milestone
PriorityQueue<TElement, TPriority>.Remove
method violates min-heap invariant
#107292
Description
The newly added
Remove
method inPriorityQueue<TElement, TPriority>
violates the invariant of the internal min-heap structure. The current implementation pops the last element and performs a sift-down operation from the index of the removed element. However, it fails to handle scenarios where the last element should be sifted upwards, resulting in incorrect ordering in the priority queue.Reproduction Steps
Expected behavior
The code should print numbers from 0 to 19 in ascending order, except for 10.
Actual behavior
It prints 2 between 8 and 9
0
1
3
4
5
6
7
8
2
9
11
12
13
14
15
16
17
18
19
Regression?
No response
Known Workarounds
No response
Configuration
.NET version: 9.0 preview
Other information
No response
The text was updated successfully, but these errors were encountered: