Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Give an O (n lg k)-time algorithm to merge k sorted lists into one sorted list

Analysis: It takes O(k) to build the heap; for every element, it takes O(lg k) to DeleteMin
and O(lg k) to insert the next one from the same list. In total it takes O(k + n lg k) =
O(n lg k).
Source by www.bowdoin.edu #
 
PREVIOUS NEXT
Tagged: #Give #O #lg #algorithm #merge #sorted #lists #sorted #list
ADD COMMENT
Topic
Name
6+1 =