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

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 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🤗

  • @fatmabatmaz2
    @fatmabatmaz2 ปีที่แล้ว

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

  • @ranad2037
    @ranad2037 2 ปีที่แล้ว

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

  • @adithyavarma758
    @adithyavarma758 3 ปีที่แล้ว

    Thank you mam

  • @samvidhaansingh1453
    @samvidhaansingh1453 ปีที่แล้ว

    tysm

  • @pradhoshss1640
    @pradhoshss1640 3 ปีที่แล้ว

    Best. Keep going :)

  • @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

  • @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

  • @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.

  • @zooomba62
    @zooomba62 ปีที่แล้ว

    O(n)🙃