Heap Sort

Поделиться
HTML-код
  • Опубликовано: 15 дек 2024

Комментарии • 4

  • @adityaanuragi6916
    @adityaanuragi6916 23 часа назад +9

    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?

    • @_ghostman
      @_ghostman 23 часа назад +7

      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)

  • @nb5549
    @nb5549 15 часов назад +2

    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.

    • @vorkutavorkutlag
      @vorkutavorkutlag 26 минут назад

      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