Тёмный

AVL Tree: Background & Python Code 

Подписаться
Просмотров 45 тыс.
% 712

Code below… In this much-requested video we’ll take a look at the AVL tree data structure, which, at the most basic level, is simply a self-balancing Binary Search Tree. As always, in the first half of the video we’ll cover some background (including the main differences between an AVL and BST), and in the second half we’ll open up our coding editor and actually implement an AVL tree class using the Python coding language.
(PYTHON 2)
► Code we start with (BST): github.com/bfaure/Python_Data_Structures/blob/master/Binary_Search_Tree/main.py
► Final Code (AVL): github.com/bfaure/Python_Data_Structures/blob/master/AVL_Tree/main.py
(PYTHON 3)
► Code we start with (BST): github.com/bfaure/Python3_Data_Structures/blob/master/Binary_Search_Tree/main.py
► Final Code (AVL): github.com/bfaure/Python3_Data_Structures/blob/master/AVL_Tree/main.py
****
► Python Data Structures: tinyurl.com/y9yoh2x2
► Python Algorithms: tinyurl.com/y8y4oks2
► GUI development in Python (WIP): tinyurl.com/ybgnmwxf
References:
[1] en.wikipedia.org/wiki/AVL_tree
[2] ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-FNeL18KsWPc.html
[3] www.geeksforgeeks.org/avl-tree-set-1-insertion/
[4] www.geeksforgeeks.org/avl-tree-set-2-deletion/
[5] professor.ufabc.edu.br/~jesus.mena/courses/mc3305-2q-2015/AED2-10-avl-paper.pdf
[6] www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Trees/AVL-delete.html
End song is “Wonder Cycle” by Chris Zabriskie

Опубликовано:

 

21 фев 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 57   
@idontneedthis56
@idontneedthis56 5 лет назад
That is hands down the best videos about avl tree I have ever seen.. Especially the repr function to print the tree after every insertion/deletion reinforces the concept of rebalancing.. Great work!!!
@BrianFaure1
@BrianFaure1 5 лет назад
Thanks! I'm glad it helped you!
@Momo-bb2fn
@Momo-bb2fn 3 года назад
as a matter of fact, it's one of the only ones and it's really, really freaking good
@khailai5204
@khailai5204 5 лет назад
This video explains better than a 12 page chapter in my book! Thank you!
@lalitvavdara5841
@lalitvavdara5841 3 года назад
The code you wrote is well commented and easy to understand thanks for that....great work
@shantanusharma5617
@shantanusharma5617 6 лет назад
Woah! You listened to my request. Thanks a lot, man. Keep making these videos. You're the best. :D
@BrianFaure1
@BrianFaure1 6 лет назад
No problem, thanks for watchin!
@gayathrigirishnair7405
@gayathrigirishnair7405 4 года назад
Great video! Explained a complex concept in a simple and efficient way. Suggestion: The speech could have been a little louder. Please make more videos on more topics using python. Very much appreciate the code being available in both python 2 and 3.
@aspatil1
@aspatil1 6 лет назад
Amazing Videos Dude! Something I want to learn ( Heaps, Priority Queues and TRIE). It would be great if you can add any of the above topics.
@bhanupratap3345
@bhanupratap3345 5 лет назад
ur vids are really helpful! amazing explanation it made it feel so easy
@BrianFaure1
@BrianFaure1 5 лет назад
Thanks Bhanu, glad to hear the vid helped you!
@davidporter1190
@davidporter1190 5 лет назад
@ 16:03 - It's worth noting that you don't call inspect delete again because the 3rd case does not need to adjust height or rebalance from the original target delete node because it's simply replacing values. But it will traverse and rebalance the tree from the lower node that was used to replace the original target node because that replacement node will never contain two children and will hit cases 1 or 2 which lead to the height+1/rebalance part.
@tanmaysharma2742
@tanmaysharma2742 4 года назад
love the explanation, only things missing from these playlists are ques , stacks and hash maps... i know it might seem selfish but can you pls add those as well?
@PATHAKROHIT08
@PATHAKROHIT08 5 лет назад
Hey Brian, Thanks for the video. Can you also make videos on Graph Theory covering (BFS,DFS, Dijkstra, Bellman Ford, Floyd Warshall).
@yiuyiufung
@yiuyiufung 5 лет назад
01:26 caught me offguard lol thanks dude
@ernestalexanderkasper5109
@ernestalexanderkasper5109 4 года назад
I got 2 say this is the best AVL tree video many ways. Thanks Brian. I have a question. How can i make a Fibonacci Tree aka. Worst balanced AVL Tree with 1.44log2(n)? Do I have to make always left rotations? Would love an answer. Have a great day and keep you content up. You're smart and have a great way to explain things.
@AnilYadav-pb2hd
@AnilYadav-pb2hd 6 лет назад
Great..can you please also do a video on Depth First and Breadth First Search? Thanks!
@69k_gold
@69k_gold Год назад
Nice content
@gallilos
@gallilos 6 лет назад
perfect!! i would say somthing more about why T1 =T2....
@SarcasticJokerr
@SarcasticJokerr 3 года назад
just curious, how would this change if we initialized the self.height to 0 instead of 1 in the Node class?
@philipdimeski5188
@philipdimeski5188 4 года назад
I'm a bit confused with determining the height. My thought of height is that: "the height of a node is the number of edges on the longest downward path between that node and a leaf." In the images on 2.45 (1st image) you said the height of the root node is 2 but going of that statement I mentioned above wouldn't it be 1?
@mistermomo2904
@mistermomo2904 4 года назад
Like many things in code, it seems to not be a universal rule. The height of a leaf node can be 1 or 0 as long as you use it accordingly. 'One advantage of using a node count rather than an edge count is that it distinguishes the empty case (zero nodes, and node level) from the minimal case (one node, and a node level of one).' - supercat stackoverflow.com/questions/4065439/height-of-a-tree-with-only-one-node#:~:text=According%20to%20Wikipedia%2C,of%20zero%20(or%20one).
@navsiv11
@navsiv11 6 лет назад
respected sir... i really like your videos and content, the way you explain is awesome. you explain with pseudo code first and write the actual code and compare with other algos and explain big0 notation which is too good. i hardly find any videos similar to your content. NOTE: YOU EXPLAINS VERY FAST THOUGH GOOD BUT SOMETIMES NOT UNDERSTANDABLE SIR. YOUR CODING SPEED ALSO VERY FAST WHICH IS HARD TO GRASP IT. THANK YOU SO MUCH FOR YOUR EFFORTS AND KEEP IT UP SIR.
@BrianFaure1
@BrianFaure1 6 лет назад
Hi Siva! Thanks so much! I'll try to slow down parts of the coding in my new videos, this one was just so long already that I tried to speed up the coding portion a bit.
@matthiaskoerber6047
@matthiaskoerber6047 6 лет назад
Nice video, thank you! I like your pace very much. As a small minor suggestion, you could consider to normalize your audio track.
@BrianFaure1
@BrianFaure1 6 лет назад
Thanks Matthias! Do you have any tips on how to normalize the audio? I use Adobe premiere pro and I've tried to apply some different audio effects to smooth it out but it hasn't turned out that great so far.
@matthiaskoerber6047
@matthiaskoerber6047 6 лет назад
I do not know premiere but when you google for "adobe premiere normalize audio" you will find tutorials on that topic. However, you can also achieve this with ffmpeg after finishing your work with premiere. There is a GitHub project called ffmpeg-normalize to assist you with ffmpeg. Hope it works for you!
@BrianFaure1
@BrianFaure1 6 лет назад
Oh awesome, thanks for the info! I'll check out that GitHub project.
@bubblesgrappling736
@bubblesgrappling736 5 лет назад
really great video, but would you use letters instead of numerical values for your examples? it really makes it a lot harder to understand, i dont understand why x has a higher value than z. Is it alphabetical?
@tyqiangz
@tyqiangz 3 года назад
The amount of methods/functions defined at 14:55 scares me a bit ngl
@jhyw_
@jhyw_ 6 лет назад
wonder if you could do up a left leaning red black tree version of balancing tree? still, this is very informational! thanks a lot!
@BrianFaure1
@BrianFaure1 6 лет назад
I'll add it to the queue, thanks!
@arham5313
@arham5313 3 года назад
ur typing speed scares me
@Blasphemian
@Blasphemian 4 года назад
Good content, but please use PEP8 next time
@cookiimonst3r
@cookiimonst3r 6 лет назад
Can you do stacks and queues and tries please??
@SaamZanessa
@SaamZanessa 4 года назад
Tries would be amazing!!!
@tttiiimmm0192
@tttiiimmm0192 6 лет назад
rully gud veedio
@BrianFaure1
@BrianFaure1 6 лет назад
thx mayne
@kevinzebb
@kevinzebb 8 месяцев назад
My nigga, good stuff
@swapnilingle4435
@swapnilingle4435 4 года назад
Coding begins at 12:50
@artourbabaev4927
@artourbabaev4927 6 лет назад
hey nice videos you should post more. (last upload 1 month ago, followed by 4 months ago) could you do a video on dijkstra's algorithm? Thanks
@BrianFaure1
@BrianFaure1 6 лет назад
What's up Artour! Sorry I haven't been posting a lot I've actually accepted a new job recently so I've still been getting adjusted to the time restraints on developing videos. There're still a bunch in the pipeline I've been working on so I'll throw Dijkstra's on top. Thanks for the feedback and for watching!
@rahulkumargupta9565
@rahulkumargupta9565 6 лет назад
repr is not working, but thank you for the really nice video...and help if you can :)
@BrianFaure1
@BrianFaure1 6 лет назад
What's up Rahul, if you throw your code in here repl.it/repls/HospitableImaginativeViruses I can take a look for ya. Thanks for the nice words!
@rahulkumargupta9565
@rahulkumargupta9565 6 лет назад
sorry for the delay, here is the code # repl.it/@RAHULKUMAR11/VastReasonableDeals
@BrianFaure1
@BrianFaure1 6 лет назад
Looks like it's working now repl.it/repls/MediumpurpleThinDebugmonitor , inside of the __insert_ function you had the two calls to rebalance_node commented out so none of the height values (inside the node class) were correct, causing the __repr__ function to print out some garbage that looked nothing like the actual tree.
@rahulkumargupta9565
@rahulkumargupta9565 6 лет назад
thanks a lot... it works sexy
@anomalous5048
@anomalous5048 Год назад
@12:50
@nisargsheth9841
@nisargsheth9841 4 года назад
typing speed 999 :0
@shawnruby7011
@shawnruby7011 6 лет назад
Come back fam, make more videos
@BrianFaure1
@BrianFaure1 6 лет назад
Don't worry my man i'll be back, I've just been busy lately and adjusting to a new schedule. I really appreciate the comment.
@shawnruby7011
@shawnruby7011 6 лет назад
you do you, we need more python ai
@moisesacero4995
@moisesacero4995 4 года назад
5:04 10:13 13:30 left 21:35
@eytchde
@eytchde 6 лет назад
મહાન સામગ્રી અપલોડ રાખવા
@VictorTennysonpresident
@VictorTennysonpresident 5 лет назад
Great content. A little more enthusiasm and intonation would help make it interesting to listen, focus and understand!
@aghiadalzein3069
@aghiadalzein3069 5 лет назад
Why are you speaking so fast ,there are people who are not native English speaker ,who are trying to learn.
@BrianFaure1
@BrianFaure1 5 лет назад
Apologies Aghiad, wasn't aware I was speaking quickly. It may help if you turn on the video captions, they seem to be fairly correct :)