We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
So, what's the time complexity of inserting a element to an array?
Normally, it's O(N), because you need to move other elements, and binary search can not help with that. While a heap can do this in O(logN).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Heaps: Find the Running Median
You are viewing a single comment's thread. Return to all comments →
So, what's the time complexity of inserting a element to an array? Normally, it's O(N), because you need to move other elements, and binary search can not help with that. While a heap can do this in O(logN).