Power of Heap

Поделиться
HTML-код
  • Опубликовано: 6 сен 2024
  • This video explains why we should care about heap data structure.In this video, I have shown the usefulness of heap by comparing it to other available data structures like an array (sorted + unsorted) and linked list (sorted + unsorted).Heap out-performs if we need to perform a lot of find-min and find-max operations with delete-min, delete-max and insert operations.All the operations can be done in maximum of logN time and minimum of O(1) time.So, heap is a very powerful data structure if we need these common operations.
    🧡 HELP us by donating on patreon: / techdose
    CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ========================================================================
    Join this channel to get access to perks:
    / @techdose4u
    INSTAGRAM : / surya.pratap.k
    SUPPORT OUR WORK: / techdose
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithT...
    TELEGRAM Group LINK: t.me/joinchat/...
    =======================================================================
    USEFUL LINKS:
    🟠Must do TIPS to ACE Virtual Interview: • 🔴Must do Tips to ACE y...
    🟢Best strategy to excel your coding interview: • 🔴Best strategy to exce...
    🟡Get your dream job in 1 month: • 🔴Get your dream job in...
    🔵How to crack dream job in just 2 months: • How to crack dream job...
    🟣7 Days DSA plan: techdose.co.in...
    RELATED LINKS:
    Website:
    Implement stack using heap: • Implement stack using ...
    #heap #heapcourse #techdose

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

  • @jironymojirolamus913
    @jironymojirolamus913 11 месяцев назад +7

    Good video, thanks. However, searching in a sorted linked list is O(n) still, as far as I understand.

  • @aditya234567
    @aditya234567 3 года назад +9

    Sir nice video but I feel even sorted linked list searching takes 0(N ) time not logN 7:00

    • @techdose4u
      @techdose4u  3 года назад +1

      If you can't have random access then it should. You may improve complexity if Linked List is implemented using nodepool.

  • @charlesopuoro5295
    @charlesopuoro5295 12 дней назад

    Thank you very much for this comparisons as it lends perspective.

  • @AJPUJARITHRINADHSAI
    @AJPUJARITHRINADHSAI 11 месяцев назад +3

    I wonder how one can apply binary search on linked list?!

    • @sharafmakk2936
      @sharafmakk2936 5 месяцев назад +1

      We can't, there is no possible way to guess the position of the half of linked list in memory

  • @salihedneer8975
    @salihedneer8975 7 месяцев назад +3

    Sir searching in heap will only take logn right ? Since we dont need to search everything

    • @techdose4u
      @techdose4u  Месяц назад

      No, searching a random element will be linear.

  • @yhimanshu22
    @yhimanshu22 Месяц назад

    your explanations are great.

  • @md.mehedihasan2343
    @md.mehedihasan2343 3 года назад +7

    How can you binary search on a sorted linked list? is it possible ?

    • @famueduyou
      @famueduyou Месяц назад

      Please feel free to correct me :)
      Imagine you assign each of the reference in the linked list a specific index/order and create a separate out of place array for them, O(n) for both space and time.
      Then do binary search on that new array, and refer back to the respective node in the linked list.
      That's just my idea, but I can be wrong.

    • @techdose4u
      @techdose4u  Месяц назад

      directly it may not be possible but while insertion you can take extra space to save the UID_address in a sorted set to apply bounded search.
      If you wanna remove something then the map balances itself (self balancing BST).
      If you wanna add something anywhere you will have access to adjacent node and you need to get another UID_address which fits in between the adjacent keys.
      Ordering is taken care by self-balancing BST.
      Since its non-trivial and requires usage of other Data Structures, hence we limit ourself to say binary search is not directly possible but saying its not possible no matter what would be an over-statement.
      Hope you got it.

  • @kunalsoni7681
    @kunalsoni7681 3 года назад +8

    Really very informative ❤️ video 😊😊
    Thank you so much sir 💕😊

  • @ankitverma1790
    @ankitverma1790 Год назад +1

    How searching in a sorted LL can be O(logN) ? you need to find the middle node which will be O(N)

    • @AJPUJARITHRINADHSAI
      @AJPUJARITHRINADHSAI 11 месяцев назад +2

      exactly!

    • @techdose4u
      @techdose4u  Месяц назад

      directly it may not be possible but while insertion you can take extra space to save the UID_address in a sorted set to apply bounded search.
      If you wanna remove something then the map balances itself (self balancing BST).
      If you wanna add something anywhere you will have access to adjacent node and you need to get another UID_address which fits in between the adjacent keys.
      Ordering is taken care by self-balancing BST.
      Since its non-trivial and requires usage of other Data Structures, hence we limit ourself to say binary search is not directly possible but saying its not possible no matter what would be an over-statement.
      Hope you got it.

  • @ramkumartr1501
    @ramkumartr1501 6 месяцев назад

    A great chain of help for student community bro. Hats off ✨

  • @youssefelamrani7905
    @youssefelamrani7905 3 года назад +6

    damn your way of explaining is so nice

  • @pddivin
    @pddivin Месяц назад

    Are we able to apply BS on the linked list? We can not access it by index. I wonder how?

  • @davngo
    @davngo 3 года назад +6

    At 4:02 it’s incorrect. Inserting into a sorted array is O(logn) not O(N). Since it’s sorted you can use binary search to figure out where to do the insertion.

    • @techdose4u
      @techdose4u  3 года назад +11

      But after insertion you need to shift all the elements on one end by 1 position :)

    • @davngo
      @davngo 3 года назад +4

      @@techdose4u oh yes, your correct. Thank you sir.

    • @techdose4u
      @techdose4u  3 года назад +1

      @@davngo no problem :)

  • @lasbutious116
    @lasbutious116 3 года назад +5

    Sir, Using a sorted linked list, finding the min and deleting min will both have O(1) complexity. Only the insertion will have 0(n) time complexity.
    So, there will be draw O(1) between heap n sorted linked list while finding min.
    deletion of min value will be faster in linked list
    only downside of linked list will be the insertion
    is it worth to use a new data structure heap just for faster insertion ??
    I am new to DSA. Please help me understand it

    • @panavkumar9009
      @panavkumar9009 2 года назад

      Yes it is totally worth it. Firstly because when you will be making big software then the amount of data that needs to be stored will reach in many GBs or maybe TBs also. So, any thing that would improve the time taken even if slightly must be done. Secondly, even though the time taken by Linked List appears to be same yet another big factor is the space that we need to use to form a linked list. In formation of a linked list we need an int data type and also a pointer that will store the address of the next block. So, this worsens the space complexity.

  • @badrulhussain5545
    @badrulhussain5545 3 года назад +3

    Can you do a video on Big O?

    • @techdose4u
      @techdose4u  3 года назад +1

      I already did. Please watch it in time complexity playlist.

  • @anupama1381
    @anupama1381 2 года назад +1

    Thanks

  • @famueduyou
    @famueduyou Месяц назад

    1:06 Can someone pls explain how is this n+n = n, but not n*n = n^2? 1:54. Thanks in advance :)

  • @tonyz2203
    @tonyz2203 2 года назад +2

    i love you, you made me feel like I can code

  • @supernova7870
    @supernova7870 3 года назад +1

    Sir, why searching takes O(N) time in heap , it's similar to BST there it take log(N) times to search ?

    • @techdose4u
      @techdose4u  3 года назад +1

      BST has a special property of storing values. We can make decision at any node which way to search. But heap has a different property, so we need linear search.

    • @supernova7870
      @supernova7870 3 года назад

      @@techdose4u Sir , got it. Thanks :)

  • @krishind99
    @krishind99 3 года назад

    Great info. Much appreciated

  • @syamprasadupputalla8233
    @syamprasadupputalla8233 Год назад

    thank you

  • @anonymous9217w2
    @anonymous9217w2 Год назад +1

    god level!

  • @revarevanth1800
    @revarevanth1800 3 года назад +1

    For creating an array to min heap takes nlogn

  • @poojitharavuri2943
    @poojitharavuri2943 3 года назад +2

    Thanks sir. Till now i thought we cant apply binary search on linkedlist. Now I got to know abt skip list. I will learn it. But the time complexity is same o(n) but u have written o(log n).

    • @techdose4u
      @techdose4u  3 года назад

      For which part are you suggesting ?

    • @poojitharavuri2943
      @poojitharavuri2943 3 года назад +1

      @@techdose4u in sorted linkedlist, u said that for searching it takes o(log n). But in gfg they said it is o(n)

    • @pallavirawat7128
      @pallavirawat7128 3 года назад

      @@poojitharavuri2943 that is through binary search

  • @pottalokesh2039
    @pottalokesh2039 3 года назад +1

    Really good sir .

  • @dharmeshupadhyay4778
    @dharmeshupadhyay4778 3 года назад +1

    sir you are loocking awesome

  • @JohnDoe-lf1jz
    @JohnDoe-lf1jz Год назад

    high quality content

  • @chaitanyamallick1949
    @chaitanyamallick1949 3 года назад

    ty sir ,ty very much

  • @varshneyshuchi
    @varshneyshuchi 3 года назад +1

    Prerequisite?

    • @techdose4u
      @techdose4u  3 года назад +1

      No prerequisite for this. It's the 1st video. You will understand the entire concepts once you complete all the videos starting from the next one.

  • @hymnish_you
    @hymnish_you 3 года назад +1

    Thanks Sir, I have a question.Can we apply binary search in sorted ll? 6:43

    • @aashimakansal3171
      @aashimakansal3171 3 года назад +2

      I dont think we can apply binary search in a linked list

    • @hymnish_you
      @hymnish_you 3 года назад

      @@aashimakansal3171 Yes

    • @techdose4u
      @techdose4u  3 года назад +2

      Main problem for applying Binary Search is to access any element randomly in O(1). You can use skip list for searching in optimized time in LL.

    • @hymnish_you
      @hymnish_you 3 года назад

      @@techdose4u Thanks sir, I have never heard about the skip list before.

    • @saiyaswanthammineni3885
      @saiyaswanthammineni3885 2 года назад +1

      @@techdose4u but binary search on ll takes O(n) time complexity , isn't it , but ya sure skip list data structure take O(logn)

  • @tejashreesalvi
    @tejashreesalvi 3 года назад +1

    Nice Videos

  • @nextgen2006
    @nextgen2006 3 года назад

    How do u get this black background and bright colors ?

  • @thinkverse94
    @thinkverse94 3 года назад +3

    Hi Suriya bro,
    I've one doubt. Can you please clarify for me?
    Last 3 years I'm working as a manual and automation tester in Embedded Networking, somehow I entered into this domain, but I've been self-interested in coding & want to be a developer. but, in the developer interview, I don't have an experience of dev to show. I'm not getting interested to work on testing, my minds want to be a developer but not able to do. It's internally hurting me a lot. what to do? Need your suggestion, please.

    • @techdose4u
      @techdose4u  3 года назад

      You should learn and do some personal projects.

  • @tushar8998
    @tushar8998 2 года назад +2

    How can you apply binary search on a sorted link list? You can't index a list. Please don't give out wrong information to students.

    • @techdose4u
      @techdose4u  Месяц назад

      directly it may not be possible but while insertion you can take extra space to save the UID_address in a sorted set to apply bounded search.
      If you wanna remove something then the map balances itself (self balancing BST).
      If you wanna add something anywhere you will have access to adjacent node and you need to get another UID_address which fits in between the adjacent keys.
      Ordering is taken care by self-balancing BST.
      Since its non-trivial and requires usage of other Data Structures, hence we limit ourself to say binary search is not directly possible but saying its not possible no matter what would be an over-statement.
      Hope you got it.

  • @zr0724
    @zr0724 Месяц назад

    even if the linked list is sorted , it will take O(n) time to search. its the nature of linked list , you are wrong.

    • @techdose4u
      @techdose4u  Месяц назад

      directly it may not be possible but while insertion you can take extra space to save the UID_address in a sorted set to apply bounded search.
      If you wanna remove something then the map balances itself (self balancing BST).
      If you wanna add something anywhere you will have access to adjacent node and you need to get another UID_address which fits in between the adjacent keys.
      Ordering is taken care by self-balancing BST.
      Since its non-trivial and requires usage of other Data Structures, hence we limit ourself to say binary search is not directly possible but saying its not possible no matter what would be an over-statement.
      Hope you got it.

    • @zr0724
      @zr0724 Месяц назад

      @@techdose4u Since you did not mentioned that we need help from some other datastructure (BST), so i was confused.

  • @baskars1342
    @baskars1342 3 года назад

    Sir are you software at google

  • @tsunningwah3471
    @tsunningwah3471 6 месяцев назад

    Vd

  • @vishnuvarma2120
    @vishnuvarma2120 3 года назад +1

    nice to see ur face for first time

  • @StoryGicRohit
    @StoryGicRohit 3 года назад +3

    The Only thing missing here is Interaction with students in between explaining

  • @tsunningwah3471
    @tsunningwah3471 6 месяцев назад

    Hjbb

  • @tsunningwah3471
    @tsunningwah3471 6 месяцев назад

    Bbbbbbb😂😂😂😂😂😂