Размер видео: 1280 X 720853 X 480640 X 360
Показать панель управления
Автовоспроизведение
Автоповтор
If insertion into a heap is log n and if we insert n elements into the heap wouldn't it be n log n instead to create the heap?
If you started from a separate empty heap and inserted each element one by one, yes. But heapifying an array in-place can be done in O(n)
The simplest way in python is to use the sort function on the list and to find the max number is length of list - 1.
is python sort O(n)? I think it's O(nlogn). Also, you can sort with a reversed key, so, could also be biggest to smallest
If insertion into a heap is log n and if we insert n elements into the heap wouldn't it be n log n instead to create the heap?
If you started from a separate empty heap and inserted each element one by one, yes. But heapifying an array in-place can be done in O(n)
The simplest way in python is to use the sort function on the list and to find the max number is length of list - 1.
is python sort O(n)? I think it's O(nlogn). Also, you can sort with a reversed key, so, could also be biggest to smallest