Anonymous user
Dijkstra's algorithm: Difference between revisions
→{{header|Perl}}: binary search to push onto the priority queue
(Add Perl section) |
(→{{header|Perl}}: binary search to push onto the priority queue) |
||
Line 1,928:
sub push_priority {
my ($a, $v) = @_;
while ($i <= $j) {
my $k = int(($i + $j) / 2);
if ($a[$k] >= $v) {
$j = $k - 1;
}
else {
$i = $k + 1;
}
}
splice @$a, $i, 0, $v;
}
|