Тёмный

Binary search tree - Implementation in C/C++ 

mycodeschool
Подписаться 759 тыс.
Просмотров 1,3 млн
50% 1

See complete series on data structures here:
• Data structures
In this lesson, we have implemented binary search tree in C/C++. We have written a simple program to create a binary search tree of integers and search an element in it.
See source code here:
gist.github.com/mycodeschool/...
Lesson on dynamic memory allocation:
• Pointers and dynamic m...
For practice problems and more, visit: www.mycodeschool.com
Like us on Facebook: / mycodeschool
Follow us on twitter: / mycodeschool

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

 

3 фев 2014

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 606   
@ahmeddeghady4510
@ahmeddeghady4510 4 года назад
I'm a simple man, I see recursive function, I panic.
@savitar8183
@savitar8183 4 года назад
lol me too
@fawadmirza.
@fawadmirza. 4 года назад
I thought you were a simple cat
@piyushnandurdikar9234
@piyushnandurdikar9234 4 года назад
haha.. epic
@adityasahu96
@adityasahu96 4 года назад
I hope you don't mind me putting this as my status
@palashbundele535
@palashbundele535 4 года назад
xDDDD
@HollowPiero
@HollowPiero 10 лет назад
You make me understand in 18 min what my teacher couldn't in 2 hours. Very Good.
@mycodeschool
@mycodeschool 10 лет назад
Thanks :)
@pradeepkumaryadav9641
@pradeepkumaryadav9641 7 лет назад
yes this videos are brilliant
@chaudharyadityakumar6149
@chaudharyadityakumar6149 6 лет назад
bro your r awesome.Why your not making new videos.I am in graduation and I am studying programming from 9 class ..I have come across many teachers but you are amazing. You can be one of the best programming teachers on youtube.
@zacharyhe5719
@zacharyhe5719 6 лет назад
that's the real thing
@chaudharyadityakumar6149
@chaudharyadityakumar6149 6 лет назад
bro i recently find out that the guy is dead
@simpleffective186
@simpleffective186 5 лет назад
this guy is the best teacher ever and you can't even find his name on the channel. Thank you for your work, humble Animesh Nayan.
@Panaxis
@Panaxis 6 лет назад
In 18 minutes I just learned way more than I did in class since January. Thank you so much! I cant wait to watch your other videos!
@nguaial8490
@nguaial8490 8 лет назад
You are much better than most of cocky PhD professors who needs to learn how to write neatly and speak slowly. Most of professors are trying to show off how smart they are. So arrogant ...
@AliRazaiamaliraza
@AliRazaiamaliraza 7 лет назад
You should respect your teachers, no matter how they are and what they do... -_-
@elvisdurmishi9893
@elvisdurmishi9893 7 лет назад
Ali Raza no you shouldnt,respect is earned,if they don't know how to teach then they should just quit and stop wasting everyones time
@daliamohamed2858
@daliamohamed2858 7 лет назад
why should i ? i paid money to learn if they r bad they should quit and stop wasting my time ! or to do researching staff far away from teaching n wasting time !
@sujoymitra1012
@sujoymitra1012 5 лет назад
Ali Raza u r right, u should respect ur teachers, no matter what they know or teach, and most importantly how they teach but in some cases if a teacher boasts about his knowledge in collg and that doesn't quite seem nice off course, that may be wrong on the teacher's part irrespective of whether the knowledge the teacher has is right or wrong.
@TheseEyesSeeDarknessClearly
@TheseEyesSeeDarknessClearly 5 лет назад
Idiot. @@AliRazaiamaliraza
@solomonleo3025
@solomonleo3025 3 года назад
7 years later.... Teachers at clg:- Still sucks at DSA mycodeschool:- Still rules at DSA
@abdellatif.x8127
@abdellatif.x8127 2 года назад
XD
@shivachandrachary
@shivachandrachary 10 лет назад
Omg!, I couldn't have asked for a better explanation. It felt like I coded the whole algorithm myself. Thanks!!
@chuanyu8813
@chuanyu8813 4 года назад
The best video I have seen until now for explaining data structures and algorithms. Fantastic! Clean and concise!
@MikeAllaway
@MikeAllaway 10 лет назад
Your videos are brilliant. Very clearly explained and thorough. They will help many people and you should be proud of your great work
@mycodeschool
@mycodeschool 10 лет назад
Mike Allaway Thanks a lot :)
@robinfr93
@robinfr93 10 лет назад
I second what Mike said!!
@GGlearn
@GGlearn 11 месяцев назад
best teacher ever
@veereshranjan3519
@veereshranjan3519 5 лет назад
The explanation about BST was splendid but this is a master piece because you not only made the concept clear but also implementation in the actual program.. hats off
@inclinedscorpio
@inclinedscorpio 5 лет назад
*Could you please teach my teacher ?????*
@gauravchatterjee4313
@gauravchatterjee4313 4 года назад
LOL HAHAHAHA
@phuckhoinguyen6938
@phuckhoinguyen6938 4 года назад
Best comment =))))
@abhi_pandit16
@abhi_pandit16 4 года назад
Bro,,He is no more 😢
@ninja-gh
@ninja-gh 4 года назад
@@abhi_pandit16 Bro what are you telling?
@tanishqsaxena597
@tanishqsaxena597 4 года назад
@@abhi_pandit16 seriously ???
@modguy9894
@modguy9894 Год назад
8 years gone by and it still is more valuable than the class lectures
@jonathanlim2269
@jonathanlim2269 9 лет назад
Great explanation, clear, concise with good linking to previously learnt concepts both as a reinforcer as well as a reminder for those who have lost touch them them
@VaLeEBP
@VaLeEBP 8 лет назад
I really appreciate your work mister, you help me out on many of my programming problems with this videos, thank you so much :) Saludos desde Tijuana B.C. México
@madjayhawk
@madjayhawk 6 лет назад
You are an excellent teacher. Very organized with perfect graphics.
@austinbvi
@austinbvi 5 лет назад
You're an angel! I'm binging the entire playlist prepping for an interview.
@shivamdhir640
@shivamdhir640 3 года назад
how did the interview go ?
@austinbvi
@austinbvi 3 года назад
@@shivamdhir640hmm I did a few that season and don’t remember which that comment was referencing but overall went like 4 for 6 offer-wise-this playlist is great, I’d crank out leetcode problems related to the topic alongside the videos
@abhishiekmahajan9103
@abhishiekmahajan9103 5 лет назад
You make it so interesting ,this 18 minutes were shortest in my life.
@LaTiNScOrPiOn33
@LaTiNScOrPiOn33 9 лет назад
I haven't even started this video and I already know it will be amazing due to your previous videos. Thanks for the helpful video!
@abhijeetjain8591
@abhijeetjain8591 7 лет назад
rather than just saying "thank you" in comments , we should also turn off adblocker while watching these awesome videos !
@gericapo8739
@gericapo8739 5 лет назад
Fair
@shyam5631
@shyam5631 4 года назад
He is dead.
@ekashto
@ekashto 4 года назад
@@shyam5631 How do you know?
@shyam5631
@shyam5631 4 года назад
@@ekashto he was a popular person and also he was a red coder.
@vighneshk509
@vighneshk509 4 года назад
@@shyam5631 dude his partner passed away not him there were two guys
@AngoraKat11
@AngoraKat11 7 лет назад
I am glad I stumble upon this video to understand BST. Thank you and keep up the good work!
@BrianFaure1
@BrianFaure1 6 лет назад
For anyone interested in a Python version, check out my recent lesson: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-f5dU3xoE6ms.html
@pkj6962
@pkj6962 3 года назад
He had a great sense in making videos. He made video in the way students who just search the keyword and don't follow the data structures courses.
@pallavivanarse1685
@pallavivanarse1685 3 года назад
Very good explanation with good clarity of binary search tree implementation ...I never see such good explanation anywhere ... I really appreciate the person behind this channel .. thanks for providing such nice videos
@digitalproductsbusiness226
@digitalproductsbusiness226 Год назад
sir awesome i didnot understand the recursion from last 2 months in trees but your video is just miracle for me now i understand how the recursion is work in tree step by step keep it up sir
@nick1f
@nick1f 6 лет назад
You make incredibly good tutorials, thank you so much for sharing them with us.
@pcpardon
@pcpardon 2 месяца назад
Even though, You are long gone, your work and legacy still inspires me. Even today, when I wanted have quick refresh on my basics, I would still visit here. May you attain nibbana.
@TheGamer720x
@TheGamer720x 9 лет назад
The most amazing explanation with proper example+animation. Cheers !! Helped a lot !! Thanx !
@LetTheWritersWrite
@LetTheWritersWrite 6 лет назад
Fantastic lesson. I just want to point out that the addressing can be simplified so much by making a class instead in C++ that will save the pain of referencing addresses and whatnot.
@tannerbarcelos6880
@tannerbarcelos6880 5 лет назад
super good explanation! I was like "what the heack is a pointer reference' but now i get it. the new node being dynamically created is basically a pointer to a node so when calling insert privately, that is the pointer passed in as reference. Makes more sense after thinking about it more.
@wilacademy8916
@wilacademy8916 8 месяцев назад
Sir, a thousand of thankyou. i love you sir. i'm now preparing for my next term in computer engineering major. i'm so very happy now im study with the best code channel.
@1234CDAB
@1234CDAB 8 лет назад
You are such a great presenter. Thank you, keep up the good work
@rohankumarshah5679
@rohankumarshah5679 2 года назад
the idea of pause and play in recursion is lit, great job!!
@priyabalakrishnan4093
@priyabalakrishnan4093 10 лет назад
Had been waiting for this implementation video!!! Thank you!!!
@johnhurley8918
@johnhurley8918 7 лет назад
Thanks to this playlist, I've been reviewing the content of an entire college coarse so far in one day. Pay attention kids. I need to know these concepts for my job interview tomorrow.
@vidzpk5144
@vidzpk5144 7 лет назад
I know it's late but did you get the job? and did they ask about Data Structures?
@edwarddeitner3006
@edwarddeitner3006 6 лет назад
Unbelievable, I am really bad in English but I understand almost everything what you explain in this language, which is pretty strange for me. It is like Einstein said: If you cant explain it easy enough you do not understand it well enough. And you understand it absolutely, so your explanations get great!
@SuperBhavanishankar
@SuperBhavanishankar 8 лет назад
great to have a class on this, that benefited me, which my college can't provide. thanx a lot!
@elvegaalberto
@elvegaalberto 8 лет назад
Your tutorials are so easy to understand. Great job :] and Thanks :)
@squirrelgaming4028
@squirrelgaming4028 7 лет назад
thx for everything you've made everything much simplier to understand ,you're brilliant sir
@usufarif
@usufarif 6 лет назад
Excellent discussion on Data Structures, great detail and crisp content. Thanks. Yusuf Arif
@kikakky
@kikakky 8 лет назад
It's really helpful for my final exam!! Thanks for your hard work! ;)
@jonathonvandergriff2299
@jonathonvandergriff2299 10 лет назад
Excellent coverage -- this is better than I had back in college.
@manishkanyal4003
@manishkanyal4003 5 лет назад
Video is great and explained every concept clearly. This video is helping ne for preparing for my exams.Thanku codeschool for making such an awesome video tutorials.
@manojpandey7517
@manojpandey7517 4 года назад
3:08 A self-note; Any object created in dynamic memory/heap can only be accessed through pointers.
@vojvoda-draza
@vojvoda-draza 3 года назад
yup
@manushreev6573
@manushreev6573 4 месяца назад
A very clear and precise video lecture. I was searching for this type of video. Thank you
@ab3l588
@ab3l588 3 года назад
Great explanation- the play and pause symbols really help! Thanks a lot :)
@stealurwife2489
@stealurwife2489 2 года назад
im here 8 years later and i cant thank you enough
@_captainfalc0n
@_captainfalc0n 9 лет назад
That was soo clearly explained. Thank You.
@user-oy5yj7ic5h
@user-oy5yj7ic5h 4 года назад
Haven't learned C/C++ before but got it thoroughly. Thanks !!!!!!!
@MisterNorthernCanuck
@MisterNorthernCanuck 8 лет назад
You make so much more sense then my teacher, many thanks
@Saradomin65
@Saradomin65 7 лет назад
You're a great teacher tbh. My teacher teaches us only how to do the BST tree and just leaves us to do the codes on our own without using the internet :(
@offchan
@offchan 9 лет назад
9:45 You could pass pointer by reference and that would do the job best. void insert(BstNode*& root) is the best way to pass a pointer that you want to changes its actual address. Normally, if you use BstNode*, you are passing pointer by value which means you can change the dereferenced data the pointer is pointing to but you are actually copying the address of the pointer so changing the address of the root inside function won't affect the actual address of root in main. Summary: Pass pointer by reference *& so you don't need to return the changed address to the caller. Passing pointer as a form of pointer like you do also does the job but I think it's too confusing and look superfluous.
@andrethomazjr.1845
@andrethomazjr.1845 5 лет назад
thanks man... I love you
@aditya6542
@aditya6542 4 года назад
But wouldn't it require to create a temporary pointer variable because the function is changing the address in root. I know this reply is far apart, 5 years to be precise. I am currently studying this, read your comment wondered about it
@offchan
@offchan 4 года назад
@@aditya6542 BstNode*& internally works similar to BstNode**. It means that it should consume the same memory. It's just that the syntax is easier to understand. Here's how to use it: BstNode* root = NULL; Insert(root,15); void Insert(BstNode*& root, int data) { if (root == NULL) { root = GetNewNode(data); } } I don't remember the syntax quite well because I haven't written in C++ for long now. But it should be something along that line.
@aditya6542
@aditya6542 4 года назад
@@offchan Thanks a lot for taking time to explain me. I just tried call by reference method suggested by you and it worked like a charm and the code is now even more readable.
@mohammedjakhirhussain8699
@mohammedjakhirhussain8699 4 года назад
@@offchan hey I tried code and works very well but, I have another doubt in this code, if you notice at 16:16 the root is currently pointing to address 500. but what if we want to insert 21 at left side of 20(address 300).please help I am so confused.
@mawsn
@mawsn 3 года назад
I wish I could like this video more than once, pure gold!
@ChandraShekhar-by3cd
@ChandraShekhar-by3cd 5 лет назад
Perfect Video Ever On BST...Such a GlassClear Explanation...Just wanted to add here that instead of using a separate function GetNode we can manage the node creation in struct itself as below : struct Node { int data; Node* left , *rigth; Node(int data){ this->data = data; left = right = NULL; } }; So instead of calling method we need to do simply new Node(data);
@abkedare
@abkedare 6 лет назад
Best data structure tutorial I have ever seen
@unsaturated8482
@unsaturated8482 7 лет назад
you're videos always helped me thank you. very much
@mohammad9934faizan
@mohammad9934faizan 8 лет назад
Hey there , thanx for uploading videos. They help our group very much in understanding the complex concepts in a very easy manner. And we want a complete playlist on algorithms like the playlist of data structure that you have made.. can you please help us??
@justcallmeRISHI
@justcallmeRISHI 5 месяцев назад
Great work Sir, RIP legend, still revising this material.
@muhammadsaadjr9215
@muhammadsaadjr9215 Месяц назад
what happen to him?
@JJLiu920
@JJLiu920 3 года назад
hey i just found you, and this is crazy, but here's my like and my subscribe, because i have a feeling that you are going to save my entire module.
@yashasvibajpai4702
@yashasvibajpai4702 5 лет назад
Sad to feel that this legend is no more in this world!!!! He will still remain eternal on RU-vid and help everyone forever!!!!
@souravsingh763
@souravsingh763 5 лет назад
What??
@yashasvibajpai4702
@yashasvibajpai4702 5 лет назад
@@souravsingh763 yup bro...He succumbed to his injuries.
@sagar1287
@sagar1287 4 года назад
dil khush ho gya bhai aapki video dekhkar dil se thankyou
@mashable8759
@mashable8759 7 лет назад
BEST EXPLANATION, Better than all the teachers :)
@ismughal38
@ismughal38 5 лет назад
we learn it here in minutes because our teachers spent hours to make base for this............very good video
@ashishkumarg5
@ashishkumarg5 9 лет назад
very lucid, concise and clear... (:thumbs up:) ... Great work
@abexoxo
@abexoxo 7 месяцев назад
Thank you sir. You have a very clear step-by-step manner explanation of the BST design. [prayer]
@backdoorguy1
@backdoorguy1 5 лет назад
Sir, you are doing an excellent job........ kudos to you
@narayananrenganathan765
@narayananrenganathan765 5 лет назад
Great, you make me understand my basic doubts.
@denysehuezo4364
@denysehuezo4364 8 лет назад
You are an amazing teacher ! thank you soo much!
@Mari22R
@Mari22R 7 лет назад
Thank you so much!! You are the best professor
@mariyamamreen439
@mariyamamreen439 2 года назад
Thnkuu so much sir ❣️😍😍😍method of teaching is brilliant I have seen many videos on topic trees but even any single video not help me like ur video 💞💞💞again thankuu so much GOd bless uh
@asadanees781
@asadanees781 4 года назад
Really Great explanation better than my professor. Awesome
@poorvikaithal3380
@poorvikaithal3380 6 лет назад
Your videos are very helpful.Thank you so much sir.
@gyf0406
@gyf0406 9 лет назад
Thank you very much for making this video. It helps me a lot during learning binary tree. Really great tutorial for a self learner like me! I read several books but only became clear after your video. In the main function, are the root = insert (root, vals) necessary, except the val = 15, which is the first one? I think the following insert function don't modify the root. Please correct me if I'm wrong (I'm a completely newbie to programming).
@RajaSekharpraveen
@RajaSekharpraveen 10 лет назад
haw....... what a video remove all confusions in mind in single shot with in 20mins u rocks good video
@Renan-st1zb
@Renan-st1zb 8 лет назад
You are AMAZING! MANY Thanks! from Brazil :)
@mumtahinaparvin7668
@mumtahinaparvin7668 3 года назад
your implementation is better than my University teacher,thank you
@jaded3404
@jaded3404 4 года назад
there should be a button for salutation. like is not enough to express my gratitude
@saraswatirathore3933
@saraswatirathore3933 3 года назад
Sir I really appreciate you effort to make us clarified
@ShahidNihal
@ShahidNihal 6 лет назад
The best video I've found on bst. God, I was stuck at the "pointer-to-pointer" code, but your code with a single pointer made my life easy. Thanks a lot!!
@neiwarecruz3519
@neiwarecruz3519 Год назад
Thanks for your great effort. Great teacher!!
@ashutoshkhairnar
@ashutoshkhairnar Год назад
Thank you so much for your detail explanation.
@coldsummersky69
@coldsummersky69 8 лет назад
This was beautiful, thank you very much
@techblog1491
@techblog1491 4 года назад
A lot of love brother...You are very brilliant
@suchonprasert5857
@suchonprasert5857 3 года назад
IN 2020, You still the best teacher bro,ur teach so good
@prasadmoghe1702
@prasadmoghe1702 8 лет назад
Your videos and explanation are simply fabulous. It can make even a layman the best programmer in this world. Best wishes for the fantastic job you are doing without any consideration. It's very rare to see this quality. I have a quick question on this tutorial. In the main function the root variable is being used to call the Insert function. by calling subsequent Inserts and then coming back How come root will always remain at memory address 200. I believe it will always move to the next node. When you are calling search how come root is at the beginning i.e 200 without initializing it to starting address. Thank you in advance.
@MrOpxr
@MrOpxr 9 лет назад
Very very good explanation. i finally figured it out.
@muhammadasif9904
@muhammadasif9904 7 лет назад
You did it very well.. just loved your way of teaching.... (y) haha i learnt Tree in almost 1 or 2 hours what i couldn't in my whole semester though it was my fault..
@ediccartman7252
@ediccartman7252 8 лет назад
Thanks a lot for the clear and detailed explanations and let me correct you a little bit. You always say, that in C we can't write, say , , but always . And the point is that you can. You have to write just once - in your definition of struct. And then after closing curly brace just write BSTNode and semicolone at the end. Since then you can write a short form - just BSTNode....blabla
@vidhansharma6650
@vidhansharma6650 Год назад
Lovely lesson..... very clearly explained thankyou
@Napkinholdin
@Napkinholdin 2 года назад
Nicely explained, thanks for sharing!
@TheGrimReaper0101
@TheGrimReaper0101 10 лет назад
these videos teach me so much in so little time .. :) thanks a lot mycodeschool
@daoanhtuandao8106
@daoanhtuandao8106 7 лет назад
your video is very useful . very clearly explained . I hope everybody seeing too .
@jessiehopper
@jessiehopper 3 года назад
Great video! You touched on using malloc and new interchangeably. I think for CPP it's best to use new only, since it works together with the delete keyword. delete also calls the corresponding destructors of objects created with new, while the free function (used in C to deallocate memory) does not. Or do you have another reason that I don't know of talking about the use of malloc in CPP.
@lituhalder
@lituhalder Год назад
i could not leave this vedio without giving thanks to you
@evilordxw
@evilordxw 8 лет назад
I'd just like to say LOVED IT. THAXXXXXX
@dimitardzorlev6283
@dimitardzorlev6283 7 лет назад
rest in peace. you are the best. You teach great.
@atulsharma8726
@atulsharma8726 5 лет назад
thanks, finally i can say i understand recursion stuff in trees
@robertp2552
@robertp2552 2 года назад
Thank you so much :( I was looking at an example that answers my homework exactly and just sitting there like what,? I feel so bad at this still and I've almost got my associates. I understand what this video is talking about and I really like how it shows many different ways of writing the same thing. Even though this video is 18ish minutes I spent an hour going over it. Thank you thank you x.x :(
@wojciechkus3010
@wojciechkus3010 Год назад
10:23 double pointer part saved me thank you so much
@arihant951
@arihant951 9 лет назад
Please keep up this good work, you are making my engineering easy and intresting
@radmehrvosoughi
@radmehrvosoughi 6 месяцев назад
How simple man, thanks god we have India
Далее
Delete a node from Binary Search Tree
18:27
Просмотров 1,1 млн
🛑 до конца!
00:12
Просмотров 26 тыс.
Doubly Linked List - Implementation in C/C++
15:21
Просмотров 583 тыс.
Binary tree traversal: Preorder, Inorder, Postorder
14:29
Pointers and dynamic memory - stack vs heap
17:26
Просмотров 1,4 млн
Data structures: Binary Search Tree
19:28
Просмотров 1,3 млн
Learn Binary search trees in 20 minutes 🔍
20:25
Просмотров 151 тыс.