Now i can sleep peacefully knowing that how backtracking thing is working in my code for making different combinations.
@MohammedAmiralaa2 ай бұрын
NICE VIDEO, you explain it very easily
@Towhidchannel3 ай бұрын
I can't apply the dispatcher function logic for the problem statement "Remove duplicates in a string". Someone please help.
@TimV-t8x3 ай бұрын
3:55 Approaches
@nolongerkai3 ай бұрын
Stumbled upon this puzzle in one of my drawers today and was curious how you could solve it using code. This is a very elegant and sturdy solution you have here! Now if I understood C++ I’d be able to track how it works. May attempt my own version in JavaScript one day. ¯\_(ツ)_/¯ Great video!
@igniteyourdesire3 ай бұрын
I wish i had your videos 11 years ago. I would have learned programming so much better. Thank you. I was told in college after I asked how you know what to do with problems. They told me you either understand it, or you dont, and since I didn't, I gave up.
@alissabrave4244 ай бұрын
thank you, for your efforts for beginner programmers
@Towhidchannel4 ай бұрын
Sir, thanks a lot for this. If I am cracking that interview, much credit will be given to you.
@kishorpustake66824 ай бұрын
1:28
@xinluchen23134 ай бұрын
Super helpful! Thank you!
@vantonspraul4 ай бұрын
Glad it was helpful!
@Zeke-v7z4 ай бұрын
Here's how I think of it: Backtracking = recursive brute-force Backtracking is a type of recursion, that's meant for brute-force It's called "backtracking" because when a wrong answer is found, the program has to return back to each recursive call until some original call is made, and then try another possible answer You say backtracking can be iterative rather than recursive, but I believe most people refer to it as recursive, so it believe it was defined to be recursive Top-down dynamic programming = memoized backtracking Top-down dynamic programming = memoized recursion, as well, which includes memoized backtracking
@madanmohan81344 ай бұрын
@vantonspraul, You have not used backtracking by removing last integer from the path in recursive solution. Are you sure it is working ?
@mixtli19755 ай бұрын
One thing to note is that you only need to keep track of visited because there may be cycles. In his example there are no cycles, so the maze is essentially a tree. There is no possibility of hitting a previously visited node. However, if there was no wall between 2 and 5, keeping track of visited becomes important. I mention this because someone might be looking at the maze and thinking they don't actually need visited, but in the general case, you do.
@vantonspraul4 ай бұрын
True and a good point. And this is true of a lot of search problems; if there are no cycles, you can get away with just using a stack so you can backtrack, but if there are cycles, you need to a way to track visited nodes.
@nettion5 ай бұрын
Amazing explanation 🙏🏼
@vantonspraul4 ай бұрын
Glad you found it helpful, thanks!
@vidyatheerthan5 ай бұрын
This algorithm help solve the last puzzle in building my spaceship. Thnx
@vantonspraul5 ай бұрын
Glad to help. Best wishes on your flight.
@Blackdiamond929_6 ай бұрын
Becoming a programmer is first recognising you have a great need for this type of thinking . It’s like my brain need to lift som weight before I can flex and solve these problems
@nullied7 ай бұрын
i was able to solve both problems nearly immediately but i still struggle with problem solving in general, and i already apply these concepts 😔
@tg8iq9548 ай бұрын
I have been stuck on the topic of recursion for several days, and now it has finally clicked.
@johnnosek7319 ай бұрын
dude - this was the video that actually unlocked the concept of backtracking for me, in a way that I can now start to understand problems going forward. Huge props. I will have to check out your library of videos and i'm not sure if you're still making them but if so I'd love to hear you explain some more concepts. Thanks for making the effort, its much appreciated
@kishorpustake668210 ай бұрын
6:10
@mdmusaddique_cse745810 ай бұрын
Splendid explanation!
@CestChauddz11 ай бұрын
one of the best books i've ever read
@vantonspraul11 ай бұрын
Wow! So nice, thank you!
@nuiben7579 Жыл бұрын
Dear KZbin Algorithm, please give me more of these practical SWE videos and less tech influencer garbage
@vantonspraul Жыл бұрын
Oh, if only we could talk directly to the algorithm...anyway, glad you found it helpful.
@hisrafi Жыл бұрын
okay iam now in my 40s! Getting my popcorn!
@vantonspraul Жыл бұрын
Never too late to learn something new!
@yohanesliong4818 Жыл бұрын
Thanks for making this informative review.
@tanhnguyen2025 Жыл бұрын
i have a question. how could u make the while loop with conditions iter and foundoutlet terminates because i didn't see anything to trigger its termination here?
@sodakk17 Жыл бұрын
I can't believe you're making this available for free. Dude, thank you very, very much.
@vantonspraul Жыл бұрын
Hey, you're welcome. Glad it is helpful content.
@sharan9993 Жыл бұрын
Isnt using a map or dictionary or hash data structure to store better than using an array?
@drewwilson8756 Жыл бұрын
Something about the aesthetics of that robot remind me of the ISpy books. Thanks for the fun video. It puts the fun in functional.
@Tyler-jd3ex Жыл бұрын
I haven't finished the video but right now, I keep thinking about all of the different paths that you can go down, keep thinking about the recursion... and then once you return you go up the path until you can make another decision based off of where you end up but it's just very... complex when you think about it... I mean the base cases do make a lot of sense but the way I'm thinking about it right now is too hard to grasp, it's almost mind bending.
@christineberkemeier47 Жыл бұрын
Thank you for explaining everything a lot more into detail you made it a lot more easier to understand how to line it up I was trying to explain to my 13 year old son and he could not get it I showed him your video and now he understands the game and he love the game so much now thank you so much!!!!
@heteroerectus Жыл бұрын
An even better approach is just to make all the right decisions the first time around. Then you never have to backtrack.
@vantonspraul Жыл бұрын
Ha! For that you'll need a non-deterministic computer. You still don't make only right decisions, but because you make all possible decisions simultaneously, you can pick the one that ends up at the exit.
@jamalparker4487 Жыл бұрын
Could you show how the list<int> sample_maze is being generated and called in main? When I called the backtrack function sample_maze[9] is empty.
@onemanenclave Жыл бұрын
this is great but i wish you could explain the same thing on python :(
@onemanenclave Жыл бұрын
would be nice if you used a dark or black background too
@ArthurCousseau Жыл бұрын
Really great video, thanks for giving a non-recursive solution, it helps putting things back in perspective. I'm wondering if this can apply to problems that search for a min/max value? For example, the classic "bag" problem which is traditionally solved using more "combinatory-oriented" approaches. (bag can carry at most N kilos and you have many items worth different values and weights, and you want to find the combination of a minimum items that are worth the maximum amount of gold)
@vantonspraul Жыл бұрын
Thanks! Yes, you could use recursion to solve that problem, which I know as the knapsack problem. The function could have two parameters: a maximum weight (maxWeight), and a list or other structure with all the items (AllItems), each with a weight and value. Also suppose there is an easy way to make a copy of that list without its first item (AllButFirst). The logic would then be, which of these has greater value? A. the recursive call with (maxWeight, AllButFirst) B. the recursive call with (maxWeight - weight of first item in AllItems, AllButFirst) + value of the first item in AllItems The recursion would stop when AllItems has zero items. Something like that.
@pradpradprad1 Жыл бұрын
I was looking for videos on backtracking.. i did not want to waste my time.. so i scrolled many times before i found a video title that talked about "thinking" about backtracking.. well done sir!!
@peterfarrell66 Жыл бұрын
Was sent here by Sweigart's recursion book!
@fmaylinch Жыл бұрын
I think that for problem solving it's also very important to know what actions you can do. For example, in the water problem you can pour from one container to the other. In programming you also need to know what instructions you can do, what commands are available, what APIs you can call, and in general what components/pieces/actions are involved/possible in the problem.
@vantonspraul Жыл бұрын
Yes! In the book, I use the example of the fox, goose, and corn puzzle, which has the same issue. If you define your available actions as, "the boat can take the farmer and one item from the west side of the river to the east side," the problem isn't solvable. If you define the actions as, "I have a boat that can travel from one side of the river to the other, and at either end I can embark or disembark so long as I am only carrying one item at a time," the problem is solvable.
@okereaforkelvin Жыл бұрын
Still didn't get it...😒
@bsal5347 Жыл бұрын
I need some serious help. I can understand how this works but I cant come up with a code by myself.
@saymatasnim59126 ай бұрын
Same here!!!
@kirataki94373 ай бұрын
@@saymatasnim5912 Practice is the key!
@shivajireddy59592 ай бұрын
Did you end up figuring it out?
@sadiazalmay5316Ай бұрын
Keep practicing and drawing the backtrack of recursion. Your mind will get use to how to think for recursive cases and you can figure out alot of problems. Its one thing that practicing and drawing it and understanding many questions of it will help ur brain to find solutions for other questions😉
@CreativeSam-cw9sh Жыл бұрын
New programmers? Sir, I've been writing code for over 20 years. I flunked this module at college. I even had the book at the time, but I was preoccupied with partying. I always struggled to take what was in my head and put it into a plan. I'd always jump straight in and write a bunch of tests and work from there. It worked sometimes.
@doublesushi5990 Жыл бұрын
so it is true.. if c0llege loans get forgiven, the g0v is basically just forgiving so more students can party it up.
@vishnuks6252 Жыл бұрын
Sir,Do you have any online courses?So that anyone can learn in person from you
@Jerret17 Жыл бұрын
widce
@bobth60952 жыл бұрын
Goofy ah Mersenne Twister
@vidpulse42672 жыл бұрын
this is one of the best explanations I've ever seen. I wish you to keep going on to brush up more information
@caiquemoa2 жыл бұрын
its normal to be more depressed after watching this playlist?
@vantonspraul2 жыл бұрын
I certainly hope my videos do not induce depression.
@caiquemoa2 жыл бұрын
@@vantonspraul your videos are not the peoblem i'm just to dumb to understand then
@vantonspraul2 жыл бұрын
@@caiquemoa Oh, come on. If any of the concepts seem too advanced, just find a simpler place to start. If there's anything in particular that you have questions on, let me know.
@viveksuman96002 жыл бұрын
I will just write empty iterative functions and assume it solves the problem for my own satisfaction because I still can't trust recursion. lol. This video helped alot. Thanks!
@sparklinglatte12 жыл бұрын
great to know that there is no little gnome throw the dice in my pc btw what is the game name at 1:14
@vantonspraul2 жыл бұрын
That is The Secret World, a horror MMO that I was really into at the time. It has since been reborn as the free-to-play Secret World Legends. I don't like the progression system in the new version as much, but honestly the storytelling is the reason to play it anyway.