Why do we say that the time complexity of a sorted array depends on the sorting but in binary heap we say it takes place in O(1) space, it will also depend on what type of heap we have right?
Time complexity of sorted array vs binary heap? (get)
hi @Ayush-Kokande-2816457821730452 , if you mean time complexity of get operation in binary heap and in a sorted array then if the array is sorted according to priority than the time complexity of get operation is O(1) as arr[0] will be the highest priority element and in binary heap the time complexity is again O(1) as highest priority element is in the top of tree . when space complexity is concerned then both array and heap has space complexity of o(n)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.