R2. 2-3 Trees and B-Trees

Sdílet
Vložit
  • čas přidán 3. 03. 2016
  • MIT 6.046J Design and Analysis of Algorithms, Spring 2015
    View the complete course: ocw.mit.edu/6-046JS15
    Instructor: Amartya Shankha Biswas
    In this recitation, problems related to 2-3 Trees and B-Trees are discussed.
    License: Creative Commons BY-NC-SA
    More information at ocw.mit.edu/terms
    More courses at ocw.mit.edu

Komentáře • 205

  • @MyLowFlow
    @MyLowFlow Před 6 lety +170

    that's the cleanest blackboard i've ever seen

    • @a4addel
      @a4addel Před 5 měsíci

      5 years later and I agree,
      and I hope you are still alive and in a good health

  • @hak4fak
    @hak4fak Před 7 lety +160

    INSERTION STARTS AT 18:20

  • @luisgraterolpalumbo3200
    @luisgraterolpalumbo3200 Před 7 lety +65

    DELETION STARTS AT 21:30

    • @marcuskim1989
      @marcuskim1989 Před 6 lety +2

      THANK WHICHEVER GOD MADE YOU. I MEAN IT. I AM NOT JOKING

  • @rohitnikam3780
    @rohitnikam3780 Před 5 lety +28

    INSERTION STARTS AT 18:20
    DELETION STARTS AT 21:30

  • @Abhishek-ig9nu
    @Abhishek-ig9nu Před 3 lety +6

    In the Cormen textbook, section 18.1, it is written that if a node has 2*B-1 keys then it is called "full node" and once the # keys become 2*B then split occurs. But in this lecture, split occurs at 2*B-1 itself as here max # keys should be strictly less than 2*B-1. So practically which one to prefer is the confusion here 🤔

  • @Rohit-tz6gs
    @Rohit-tz6gs Před 3 lety +14

    What a clear xplanation @ this age!!. It gave me goosebumps to have knowledge like this rather than for passing just exams.

  • @kenniolsen181
    @kenniolsen181 Před 8 lety +65

    Great lecture - the passion shines through and the motivation rubs off!

  • @rahuldeshpande3516
    @rahuldeshpande3516 Před 6 lety +26

    2-3 Tree: Atmost 2 keys, at most 3 children

  • @guillermoalcantaragonzalez6532

    Somebody should have told Amartya that he does really well here. He is knowledgeable about the subject, has good material, illustrations and it's clear with his explanations.

    • @mauinisikawa1808
      @mauinisikawa1808 Před rokem

      if we are here watching his lectures, there's no way we can get into mit:(

  • @akshaysalunkhe2534
    @akshaysalunkhe2534 Před 6 lety +2

    It was best solution on b tree i had ever seen on CZcams. Thanks

  • @sachinpal2424
    @sachinpal2424 Před 5 lety +4

    What a passionate teacher !

  • @ria7941
    @ria7941 Před 6 lety +1

    Thank you so much! This helped me a lot! Keep going with such wonderful videos!

  • @bc9477
    @bc9477 Před 7 lety +120

    That's some seriously young professor.

    • @sob4655
      @sob4655 Před 7 lety +73

      I don't believe he is a professor; a graduate student, teaching for some credit (Teaching Assistant), perhaps. That's because he is terrible at teaching.

    • @skippycavanaugh3148
      @skippycavanaugh3148 Před 6 lety +8

      He was in his 3rd while teaching.

    • @zondaken
      @zondaken Před 6 lety

      +1

    • @idobooks909
      @idobooks909 Před 5 lety +59

      I don't see how "he is terrible at teaching" makes him a not professor ;)

    • @hasibulalam3367
      @hasibulalam3367 Před 5 lety +7

      its a recitation. they are always conducted by TA.

  • @vatsalgujarati1100
    @vatsalgujarati1100 Před 5 lety +5

    it is a good lecture for clearing the concept of B tree.
    But I have a doubt that value of maximum keys in a node is less than 2*B-1 or less or equal to 2*B-1 @MIT OpenCourseWare.

  • @wesdaaawg
    @wesdaaawg Před 5 lety +7

    I really enjoyed this. Instructor is great at explaining everything. Thank you!

  • @kabirkanha
    @kabirkanha Před 6 lety +3

    Amazing explanation. Thank you.

  • @timothymagsino
    @timothymagsino Před rokem

    Such a passionate guy. Respect!

  • @theflubba
    @theflubba Před 4 lety

    The way this guy explains things is unreal

  • @somerandomguy8361
    @somerandomguy8361 Před 3 lety +4

    The literature on B-trees is not uniform in its terminology
    Bayer and McCreight (1972) define the order of B-tree
    as the 'minimum number of keys' in a non-root node.
    terminology is ambiguous because the maximum number of keys is not clear
    : An order 3 B-tree might hold a maximum of 6 keys or a maximum of 7 keys
    (4 minimum children holds a maximum of 7 or 8 children)
    Knuth (1998) avoids the problem by defining the order to be the 'maximum number of children'
    order 3 B-tree : 2-3 tree
    order 4 B-tree : 2-3-4 tree (2-4 tree)

  • @jamesreed4735
    @jamesreed4735 Před 8 lety +18

    "Cache line size" is the phrase you're looking for

    • @danielkurniadi8805
      @danielkurniadi8805 Před 3 lety

      Ah yes. I think that's the phrase. Another question though, so do we tune the size of each node (which consists of M # of children) to fit (a) RAM line size or (b) Disk block size?

    • @seungchullee4222
      @seungchullee4222 Před 3 lety +1

      It depends on the location where the B-tree stay. If a B-tree lives in a memory, then cache line size is appropriate. If a B-tree lives in a storage, then disk block size is appropriate.

  • @sidog6444
    @sidog6444 Před 3 lety

    Thanks for this video, this helps a lot during the pandemic!

  • @rancoxu
    @rancoxu Před 5 lety

    can someone explain why in the last bit we chose to rotate 17 on the left over 30 on the right? thxxxxx in advance!

    • @juanbecerra5073
      @juanbecerra5073 Před 5 lety +1

      I believe that it's an arbitrary decision and both are viable operations. Like in deletion, we can choose to propagate the left-most element of the right child OR the right-most element of the left child. Take what I say with a grain of salt, I'm also trying to learn B-Trees lol

  • @ghazalfaris8796
    @ghazalfaris8796 Před 2 lety

    Structure Preserve invariance (Rep Invariant)
    Common Issue:
    One of your nodes will (become) overFull, & Overflow
    24:04

  • @user-kq7cw2vf7j
    @user-kq7cw2vf7j Před 8 lety

    Thank you for good lecture about deletion op.

  • @somerandomguy8361
    @somerandomguy8361 Před 3 lety +5

    he is really good at juggling chalks

  • @tsupeichen693
    @tsupeichen693 Před 7 lety +1

    Great lecture!

  • @MendaSpain
    @MendaSpain Před 6 lety +14

    10:18 a wild runner appears

  • @user-ev9kf9fy3u
    @user-ev9kf9fy3u Před 6 lety +1

    Great Lecture thanks.

  • @andrealaw2291
    @andrealaw2291 Před 6 lety

    Insertion explained at 13:50

  • @sunny10528
    @sunny10528 Před 6 lety +25

    He is a grad student of MIT (2017 passout) , currently working at Twitter

    • @asadullahfarooqi254
      @asadullahfarooqi254 Před 5 lety +15

      who cares he is a terrible teacher....

    • @7xr1e20ln8
      @7xr1e20ln8 Před 4 lety +22

      @@asadullahfarooqi254 you are a terrible student. Its perfectly understandable.

    • @prathamyadav3105
      @prathamyadav3105 Před 4 lety +6

      @@asadullahfarooqi254 Why so much hate? Are you pakistani?

    • @asadullahfarooqi254
      @asadullahfarooqi254 Před 4 lety +10

      Sorry guys @Int 0x80 @Pratham Yadav, I shouldn’t have said that 😔 I take back my words. my sincere apologies. One more thing @Pratham Yadav That was wrong but not political.

    • @hil449
      @hil449 Před 2 lety

      @@7xr1e20ln8 isnt his definition wrong though? in CLRS 3rd edition page 489 the definition for internal nodes of degree t is: t

  • @tinyanarchy836
    @tinyanarchy836 Před 4 lety +13

    the professor is adept at dancing, it seems

  • @mrkingdom75
    @mrkingdom75 Před 4 lety

    This is an excellent education video, thanks a lot. I would like to clarify is B-Tree B is really stands for Branching? Thanks

    • @lucha6262
      @lucha6262 Před 4 lety +1

      I believe it stands for balanced

  • @shershahdrimighdelih
    @shershahdrimighdelih Před 3 lety +1

    When I know something that I have to teach to a junior but am not completely prepared for it, that's how I teach. Good recitation though

  • @Sliekas99
    @Sliekas99 Před 6 lety

    Great explanation.

  • @timothylang356
    @timothylang356 Před 8 lety

    Amazing lecture!

  • @kevinoliveira8576
    @kevinoliveira8576 Před 7 lety +1

    Thank you, this was helpful to me when i was implementing a b-tree in C ;

  • @rinkirathore6502
    @rinkirathore6502 Před 5 lety

    Deletion very beautifully explained

  • @MrSelcukBak
    @MrSelcukBak Před 6 lety

    Thanks a lot mate!

  • @karansah9506
    @karansah9506 Před rokem

    Great lecture, thanks!

  • @ashu7pathak
    @ashu7pathak Před 4 lety +2

    Man, once I hit play, I couldn't stop till the end, except for just this comment! ❤✌🇮🇳🇮🇳🇮🇳

  • @cecekoko9080
    @cecekoko9080 Před 4 lety

    I have to watch 2 time to understand it. Thanks sir

  • @tomlynd8836
    @tomlynd8836 Před 7 lety +1

    Where can I access the notes he said he would provide?

    • @jsarvesh
      @jsarvesh Před 7 lety +1

      ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2015/recitation-notes/MIT6_046JS15_Recitation2.pdf

    • @samiere
      @samiere Před 6 lety

      ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2015/recitation-notes/MIT6_046JS15_Recitation2.pdf

  • @Balouk
    @Balouk Před 2 lety

    What is the meaning of the R in the playlist? Is R1 available?

    • @mitocw
      @mitocw  Před 2 lety +1

      The R means Recitation. It is a session that allows students to ask questions from materials presented in the lectures and to get help if they are stuck on a specific problem or concept. R1 was not recorded.

  • @anmol9096
    @anmol9096 Před 8 lety +1

    Complexity of delete operation?

  • @hemantjoshi8388
    @hemantjoshi8388 Před 6 lety

    how is the order of B tree related to the branching factor? Also how do you find the branching factor?

    • @samiere
      @samiere Před 6 lety

      B is defined as the branching factor. By definition, this establishes a bound on the number of children: [B,2B) and hence a bound on the number of keys: [B-1, 2B-1]. You can what B is by taking the floor of lg(# of children in any branch)....(correct me if im wrong here...)

    • @bharat_arora
      @bharat_arora Před 6 lety

      2B-1 = order of the tree (which means the maximum number of branches a node can have )
      and B= minimum number of Branches a node can have.
      and you don't need to find the branching factor, whatever you wish you can take depending on your max height constraints

  • @asadullahfarooqi254
    @asadullahfarooqi254 Před 5 lety

    he is just dancing can anyone tell me what beat is that .?? because google just failed to find such a beat..

    • @ishwarraghu2463
      @ishwarraghu2463 Před 5 lety +1

      dud dud dud dud. du du dud dud dud.. dudu dud dud dudd dududd dud dud...

  • @chinmaydas4053
    @chinmaydas4053 Před 3 lety +1

    Sir what is the best programming language for design and analysis of data structures and algorithms??.. please reply me sir 🙏🙏

  • @thinhnguyenvan7003
    @thinhnguyenvan7003 Před 2 lety

    oh this guy is so energetic. I like that!

  • @rbrtchng
    @rbrtchng Před 7 lety

    in the end, what if you delete 3?

    • @deepakkumarprajapati8823
      @deepakkumarprajapati8823 Před 7 lety +4

      Good qus!
      After deleting 3, we marge 2 and 7 make it a single node but this node has empty parent then 10 will come down and take it's parent node now 10 will only left node( containing two key 2 and 7) and it's right node is empty. There is one more problem the root node is also empty. Now we are combine 14 and 17 and make the left node/child of 30 and 16 goes up and take's the root place but still 10 doesn't have the right child now 10 will ask to it's sibling 30 help me but 30 say i am bierley full but sibling left child say hay i am eligible to help him, now sibling (30) of left child of right element goes up and combine with 30(now the parent node contain two key 17 and 30) now there will be rotation as well as shifting now 17 goes up now the root node has two key (16 and 17) and 16 come down to 17's left child 10 and there will be two key (i.e 10 and 16) and finally 16 will come down and became the right child of 10.now everything is kk..

  • @Speed4Runs
    @Speed4Runs Před 6 lety +5

    so cute awww

  •  Před 6 lety

    This guy's pretty good (thumbs up)

  • @jessicahassibi8516
    @jessicahassibi8516 Před 4 lety

    Have a question... The nodes are not supposed to have more than b-1 keys.. But in his example (26:16 m) he got 5 keys in one leaf... how is that right?

    • @jessicahassibi8516
      @jessicahassibi8516 Před 4 lety

      And b = 4

    • @marshalryan5049
      @marshalryan5049 Před 2 lety

      I believe that you've mistaken the maximum bound of keys in a node to not be more than b-1 when the correct one is suppose to be less than 2b-1

  • @rajeshdansena
    @rajeshdansena Před 7 lety +7

    There is something wrong while explaining Number of Keys. The correction will be :
    B-1

    • @h8pathak
      @h8pathak Před 7 lety +4

      Yes. There are two mistakes.
      B

    • @patrickdornellesdasilvavie937
      @patrickdornellesdasilvavie937 Před 7 lety +4

      actually the teacher and you are right, there are two concepts, for Bayer e McCreight(the creators), b ai the minimal number of keys, and Knuth use the minimal number of childrens.

    • @hil449
      @hil449 Před 2 lety

      @@patrickdornellesdasilvavie937 i dont think so. From what i've read both bayer and CLRS use b as the minimal number of children and knuth uses b as the maximum number of children

    • @hil449
      @hil449 Před 2 lety +1

      @@h8pathak yes, in CLRS 3rd edition page 489 the definition for internal nodes of degree t is: t

  • @KarenMartikyan
    @KarenMartikyan Před 4 lety

    Guys, the b-tree in 20:08 is not valid, isn't it? We are having problems with the root node

    • @marshalryan5049
      @marshalryan5049 Před 2 lety

      I think that in a programming recursive point of view, a root node can be subjective as in every node is a root node, even the ones on the very end of the branch have also a left and right node equivalent to NULL. Thus why as long as its in the lower minimum degree and upper order bound then it's completely valid to the B-Tree's properties.

  • @blueninja42069
    @blueninja42069 Před 5 lety +3

    make an ASMR video just with chalk sounds

  • @AsmaaMohamed-kr1dm
    @AsmaaMohamed-kr1dm Před 2 lety

    Smart explanation

  • @bashaarshah2974
    @bashaarshah2974 Před 6 lety

    That's a very nice coat.

  •  Před 5 lety +2

    Every time I check subtitles for sth I don't understand subtitles help me a lot with this answer: "inaudible"

  • @teaMmMate
    @teaMmMate Před 7 lety +6

    Amazing lesson, you have my gratitude.

  • @davidalexander9633
    @davidalexander9633 Před 4 lety

    thanks you sir

  • @alpacino3989
    @alpacino3989 Před 7 lety +1

    wow, good vid.....this guy has got a bronze medal in IOI twice.

  • @saurabhtiwaririshi
    @saurabhtiwaririshi Před 7 lety

    Why log n? shouldn't it be log n base 3

    • @seungchullee4222
      @seungchullee4222 Před 3 lety

      Base doesn't matter. By change of base formula of log function. i.e., log_3(x) = Constant * log_10(x). You can pick any base for asymptotic analysis.

  • @NoOneIsHereRightNow
    @NoOneIsHereRightNow Před 3 lety

    I am in love with this teacher

    • @achyutambharatam2116
      @achyutambharatam2116 Před 2 lety

      Do You Code B-tree by yourself?Understanding this and implementing it makes a huge difference

    • @hil449
      @hil449 Před 2 lety +1

      youre cute lol pretty eyes

  • @pavankumardittakavi5325

    I could not follow quite well when he said why use B Trees over BSTs. Can someone please help me understand it?.

    • @seungchullee4222
      @seungchullee4222 Před 3 lety

      Memory access time cost is much expensive than CPU compare(

    • @seungchullee4222
      @seungchullee4222 Před 3 lety

      If single node's memory size is bigger than cache line, then single node visiting makes caching at most twice. Therefore it seems good to make node's memory size to fit into cache line size.

  • @saurabhtiwaririshi
    @saurabhtiwaririshi Před 7 lety

    Hi MIT! this lecture doesn't seem to be well connected. Can we have another one?

  • @bishwendrachoudhary2281

    excuse me sir , your deletion of 41 is wrong , why should you bring 30 down ?

    • @DenisG631
      @DenisG631 Před 7 lety

      in order to have same height for every leaf

    • @bishwendrachoudhary2281
      @bishwendrachoudhary2281 Před 7 lety

      no , actually it is beacuse of 30 's both children has only one number so, merging and then 41 also has one children in both side so merging again.height does n't matter yr

  • @omerashraf_
    @omerashraf_ Před 2 lety

    half an hour worth more than Whole semester in my collage

  • @monukumar-xb5cc
    @monukumar-xb5cc Před 6 lety

    Any one please explain how its no of children B

    • @monukumar-xb5cc
      @monukumar-xb5cc Před 6 lety

      so how can it adjust 19 children in it there

    • @hil449
      @hil449 Před 2 lety

      i think he's wrong, in CLRS 3rd edition page 489 the definition is: t

  • @AtticusFinch65
    @AtticusFinch65 Před 6 lety +5

    the way this guys flips his chalk after every sentence pisses me off

  • @peterzeng1243
    @peterzeng1243 Před 3 lety

    I like this handsome Indian TA. No Indian accent at all.

    • @hypernova54
      @hypernova54 Před 11 měsíci

      North Indian accent is just like this
      ....
      You bastards have stereotyped Indian accent with South Indian accent

  • @tyyyuuuhunngra618
    @tyyyuuuhunngra618 Před 2 lety +1

    He is from our school in india

  • @rohandalvi6476
    @rohandalvi6476 Před 3 lety +3

    weird that an MIT prof has never implemented B tree but my college need me to do it without plagurism

    • @vinayak186f3
      @vinayak186f3 Před 3 lety

      Incredible India 🔥

    • @achyutambharatam2116
      @achyutambharatam2116 Před 2 lety

      Buddy I Also strucked on Implementation.. It's implementation is really very tough on coding point of view 🥴

    • @rohandalvi6476
      @rohandalvi6476 Před 2 lety

      @@achyutambharatam2116 yes, took me hours. And is kinda stupid coz libraries exist for all this stuff already

    • @achyutambharatam2116
      @achyutambharatam2116 Před 2 lety

      @@rohandalvi6476 Really? Libraries are there! But this is complex type of Dta structure... Sometimes I strucked for week for making their code understand.. Do u also face this?

    • @rohandalvi6476
      @rohandalvi6476 Před 2 lety

      @@achyutambharatam2116 ofc i do, it was last to last semester

  • @user-df1sk3ct2o
    @user-df1sk3ct2o Před 4 lety

    Cool guy

  • @AAZinvicto
    @AAZinvicto Před 5 lety +2

    2:35 to 5:32 will change your life :D

  • @bubeshp
    @bubeshp Před 6 lety

    4:30

  • @DehXable
    @DehXable Před 7 lety

    tweakin

  • @ummonk
    @ummonk Před 6 lety +1

    1:32 Is no one in the class paying attention? It isn't at all clear why the depth is logN.
    8:04 Finally mentioned that all the leaves are at the same depth, and only then do you know that the depth is actually logN and the tree is balanced.

    • @hamzaktk18
      @hamzaktk18 Před 5 lety

      probably everybody knew? its MIT

    • @aviralrastogi
      @aviralrastogi Před 4 lety +1

      They supposedly studied Binary Search Trees last time. It should be obvious then. And if it isn't clear to you then you are studying in wrong order. Study BST first.

  • @KULDEEPSINGH-rh3go
    @KULDEEPSINGH-rh3go Před 7 lety +11

    I can bet, this faculty is from India.

  • @user-wr4ke3qw4m
    @user-wr4ke3qw4m Před 4 lety +1

    He reminds me Tedd Mozbi from How i met your mom? NO??

  • @gutierreznunezdavidisrael2511

    Awesome! Greetings from Mexico.

  • @hunting4ever389
    @hunting4ever389 Před 7 lety

    cool

  • @achrafBadiry
    @achrafBadiry Před měsícem

    why is he speaking at 1.25 speed lol. I had to check my settings for a second

  • @coderopes2983
    @coderopes2983 Před 5 lety +1

    Why he is in hurry

    • @kofiill2509
      @kofiill2509 Před 5 lety +1

      Perhaps to rush for his next fix?

  • @AbdulWahab-ms6bn
    @AbdulWahab-ms6bn Před 5 měsíci

    guys while your watching the vid write awesome!🤣

  • @tuffgonggbUNCTION
    @tuffgonggbUNCTION Před 5 lety

    MARANATHA KYMRY

  • @TheThunderSpirit
    @TheThunderSpirit Před 7 lety +17

    too smart.. didn't understand shit.

  • @bradleyfallon6847
    @bradleyfallon6847 Před 5 lety

    I think the reason to use these trees is balancing!
    Near the beginning, he asks "Why use B-trees over Binary Search Trees". He then explains something about avoiding reading memory from disk. This is not the reason I was taught in my class. The reason I was taught, is that these trees will stay balanced. With a Binary Search Tree, the algorithm of insert could result in the tree being extremely deep on one branch and very shallow on others. This means you will not actually get log(n) performance, since most of the data is in longer branches.

    • @thenightspoofed
      @thenightspoofed Před 5 lety +1

      I believe that b-trees are to be used when accessing a disk location takes a larger amount of time and thus it is more efficient to have more keys stored in each location.

    • @pharoah327
      @pharoah327 Před 4 lety

      Why can't it be both? Both better caching and a balanced tree. Most data structures have not one, but several pros and cons over other data structures.

    • @hil449
      @hil449 Před 2 lety +1

      You're wrong. AVL trees also stay balanced and are way easier to implement, but they only hold 1 key for a given node and each node has only up to 2 children. The reason for using B trees is the one presented in the video

    • @hil449
      @hil449 Před 2 lety

      @@pharoah327 because there are avl trees and red-black trees which are also balanced and way easier to implement but wouldnt work for disk access

  • @6puritans9
    @6puritans9 Před 2 měsíci

    this is insane

  • @omerashraf_
    @omerashraf_ Před 2 lety

    13:30 I know this fake laughs its widely used in my univirsty

  • @abbbb5625
    @abbbb5625 Před 2 lety

    ADHD very chaotic - hard to follow - jumping all over the place and at the end the result is quite confusing.

  • @andrearomanic1803
    @andrearomanic1803 Před 3 lety

  • @manishkumarparmar412
    @manishkumarparmar412 Před 4 lety +1

    He is Shahrukh Khan

  • @kumararun5318
    @kumararun5318 Před 4 lety

    I think ravindrababu ravula has taught it better than this MIT teacher

  • @bonbonpony
    @bonbonpony Před 5 lety

    When watching this lecture, I can't help but think that this dude is scamming me right now :q

  • @fastrhythms6051
    @fastrhythms6051 Před 3 lety

    :)

  • @pajeetsingh
    @pajeetsingh Před 3 lety

    He wants to dance

  • @badalgupta3518
    @badalgupta3518 Před 7 lety +8

    Searching In BST is O(n) worst case not log(n)

    • @artun97
      @artun97 Před 6 lety +2

      He said B-trees needed to be balanced

  • @ankurdhuriya
    @ankurdhuriya Před 5 lety +1

    maybe he is impersonating SRK

  • @dallasphillips91
    @dallasphillips91 Před 3 lety +1

    He is pretty spazy and needs to slow it down a bit. So far the better videos on BTree's for sure, just needs to clean up his lecture and be a bit more prepared.

  • @numbtubeyou
    @numbtubeyou Před 10 měsíci +1

    he is too impatient and he has to correct himself way too often. I am so glad I never had such lecturers.