Time complexity of Bubble Sort | In depth Analysis - Best case, Worst case and Average case

Поділитися
Вставка
  • Опубліковано 5 вер 2024

КОМЕНТАРІ • 18

  • @cstalksbylee4434
    @cstalksbylee4434  2 роки тому +1

    Hi all,
    If you have any doubt or query, feel free to write a comment ✍️ to clarify it.

  • @fairuzalaila2308
    @fairuzalaila2308 Рік тому +1

    I have started watching your videos recently. You teach step by step and in an orderly manner. From this point of view, I can say that if you continue, you have potential to convert this channel in the top list of the youtube channels for learning CS concepts. Best of luck!

  • @Jo-ce6gd
    @Jo-ce6gd 3 роки тому +17

    The best case time complexity will be O(n), it is when the list is already sorted.

    • @user-iz2pn7tm8d
      @user-iz2pn7tm8d 2 роки тому

      It is actually O(n^2) because it is a nested loop regardless of a swap.

    • @vamsikrishnagannamaneni912
      @vamsikrishnagannamaneni912 Рік тому

      its n ^ 2, in optimised buble, if you maintain a extra flag to check if swaps are made after initial iteration and it is equal to 0 you stop the algo to achieve O(n2)

  • @codefreak3836
    @codefreak3836 3 роки тому

    underated channel. great videos as usual! keep up the good work

  • @adityak1547
    @adityak1547 3 роки тому +1

    great explanation

  • @rishipollai5646
    @rishipollai5646 3 роки тому +1

    Keep doing these amazing videos🤗

  • @ranad2037
    @ranad2037 2 роки тому

    Thanks A LOT!! I thought that the best case time complexity is O(n)

  • @fatmabatmaz2
    @fatmabatmaz2 Рік тому

    I was so confused about why the n was divided by 2 now i get it

  • @anilmantrabuddi6041
    @anilmantrabuddi6041 Рік тому

    The best case running time of bubble sort
    O(n) or 0(n^2)
    This question given in previous examination
    I am so confused

  • @KandhaMaaran-10
    @KandhaMaaran-10 2 роки тому

    Mam in optimised code worst case , n=5 total comparisons=10 can we consider (2n ) is the worst case for that.. bcoz 2n =2(5)=10

  • @adithyavarma758
    @adithyavarma758 3 роки тому

    Thank you mam

  • @pradhoshss1640
    @pradhoshss1640 3 роки тому

    Best. Keep going :)

  • @samvidhaansingh1453
    @samvidhaansingh1453 Рік тому

    tysm

  • @SAHI-MUSLIM
    @SAHI-MUSLIM 2 роки тому +1

    I think j

    • @cstalksbylee4434
      @cstalksbylee4434  2 роки тому

      Yeah, That I have shown in the optimized code at 4.44, watch it fully.

  • @lucy2003-d8p
    @lucy2003-d8p Рік тому

    O(n)🙃