python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Find the Kth smallest element in a matrix of sorted rows
This is an interview question.
Find the Kth smallest element in a matrix of sorted rows, but NOT sorted columns and no relations between the rows. (the first row and nth row have no relation between t...
s_jack_frost
Votes: 0
Answers: 6
Performance improvement for Dijkstra algorithm using heaps in python?
Below is my implementation for Dijkstra's algorithm using heaps (for undirected graphs).
This works just fine for reasonably sized graphs however I am not satisfied by my code for recalculating greedy...
tim_76
Votes: 0
Answers: 1
Why does the Python heapq _siftup(...) call _siftdown(...) at the end?
The code for_siftup at github - python/cpython/Lib/heapq.py has a final call to _siftdown:
def _siftup(heap, pos):
endpos = len(heap)
startpos = pos
newitem = heap[pos]
# Bubble up th...
aksg87
Votes: 0
Answers: 1
Inserting a node in a min-heap with a null value at the end
I got a sorted min-heap array: 2,3,4,5,NULL
I'd like to insert the value 1 in it, how would the first step be dealt with?
2 2
/ \ / \
3 4 ...
student
Votes: 0
Answers: 1