Search A Maze For Any Path - Depth First Search Fundamentals (Similar To "The Maze" on Leetcode)

Поделиться
HTML-код
  • Опубликовано: 18 янв 2019
  • Free 5-Day Mini-Course: backtobackswe.com
    Try Our Full Platform: backtobackswe.com/pricing
    📹 Intuitive Video Explanations
    🏃 Run Code As You Learn
    💾 Save Progress
    ❓New Unseen Questions
    🔎 Get All Solutions
    Question: Given a 2D array of black and white entries representing a maze with designated entrance and exit points, find a path from the entrance to the exit, if one exists.
    Graph search methodologies apply well to problems that have an aspect of a spatial relationship.
    Approach 1 (Brute Force)
    We could try to enumerate all possible paths in the maze from the start to the finish and then check all paths to see if any of them are valid (have all white squares, aka do not run over a wall).
    This is both naive and extremely costly in terms of time.
    Approach 2 (Graph BFS or DFS)
    We will imagine each cell as a vertex and each adjacent relationship as the edges connecting nodes.
    Do we use DFS or BFS?
    If we use BFS we know that the path that we find will be the shortest path because of how it searches (wide, going out layer by layer).
    If we use DFS we can have the call stack remember the path making things easier to implement.
    If we hit the end cell, then we will know that every call below in the call stack has a node apart of the answer path.
    Since the problem just wants any path then we will use DFS since it is more straight-forward.
    Complexities
    Time: O( | V | + | E | )
    The standard time complexity for DFS
    Space: O( | V | )
    We will at maximum the length of the path on the call stack through our recursion
    Note: The problem on Leetcode requires BFS to pass because DFS will not always find the shortest path, but I did DFS in this video just for teaching purposes.
    ++++++++++++++++++++++++++++++++++++++++++++++++++
    HackerRank: / @hackerrankofficial
    Tuschar Roy: / tusharroy2525
    GeeksForGeeks: / @geeksforgeeksvideos
    Jarvis Johnson: / vsympathyv
    Success In Tech: / @successintech
    ++++++++++++++++++++++++++++++++++++++++++++++++++
    This question is number 19.1 in "Elements of Programming Interviews" by Adnan Aziz, Tsung-Hsien Lee, and Amit Prakash.
  • НаукаНаука

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

  • @BackToBackSWE
    @BackToBackSWE  5 лет назад +41

    Table of Contents:
    Leave The Library Plz 0:00 - 0:17
    The Problem Introduction 0:17 - 2:50
    Our Fundamental Operations 2:50 - 3:50
    Beginning The Depth-First Search 3:50 - 7:26
    We Hit Dead End #1 7:26 - 9:50
    We Get Back On Track 9:50 - 12:03
    We Hit Dead End #2 12:03 - 13:27
    We Get Back On Track Again 13:27 - 14:31
    We Reach Our Target: The End 14:31 - 15:00
    Returning Back Upwards With The Path 15:00 - 15:28
    The Top Level Caller Gets The Path 15:28 - 15:59
    Time Complexity 15:59 - 16:42
    Space Complexity 16:42 - 17:09
    Wrap Up 17:09 - 17:30
    The code for this problem is in the description. Fully commented for teaching purposes.

    • @amirmohideen99
      @amirmohideen99 4 года назад +11

      code is missing

    • @BackToBackSWE
      @BackToBackSWE  4 года назад +2

      The repository is deprecated - we only maintain backtobackswe.com now

    • @punitpawar4231
      @punitpawar4231 4 года назад +9

      @@BackToBackSWE Is it possible for you to share the link to this code ?

    • @Thadnill
      @Thadnill 4 года назад +1

      @@punitpawar4231 I wonder this as well

    • @UECDishaKhattri
      @UECDishaKhattri 4 года назад

      yes it would be wonderful if you just provide the code link

  • @frogspawn8
    @frogspawn8 5 лет назад +78

    Bruh, your lectures are WAY clearer and more concise than some of the “best” professors I’ve encountered.
    Kudos to you!

    • @BackToBackSWE
      @BackToBackSWE  5 лет назад +1

      thx

    • @ers-br
      @ers-br 2 года назад

      I thought he was a professor ... and he's just a student. Really good explanations.

  • @FrancoMunizAR
    @FrancoMunizAR 3 года назад +35

    You and Abdul Bari are the kings of explaining algorithms and problem solving. Thanks a LOT for everything you do!

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

      Damn true

    • @jst8922
      @jst8922 18 дней назад

      NeetCode, DEEPTI TALESRA, Jenny's Lectures CS IT, Tushar Roy - Coding Made Simple, Nikhil Lohia too.

  • @lmnefg121
    @lmnefg121 4 года назад +10

    I really like that you explain things in such a simple way and teaches the most fundamental method. As a matter of fact, it is always most difficult to learn the most fundamental stuff.

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

    Man, you are an excellent teacher. I stumbled onto one of your videos earlier and immediately started up another, right after. I'm about five videos in, now.
    I've got books upon books about algorithms, I've read articles, related papers, tutorials, pseudo-code implementations, and public code-bases on software repo's, but this is the first time I've gained a simple, clear intuition for some of these concepts. Thank you so much for taking the time to make these videos. I'll refer people to your content any chance I get.

  • @TJ-rf1xl
    @TJ-rf1xl 4 года назад +39

    Best explanation I've seen of DFS so far. I wish my professors explained things this way. I likely would have dropped out of my MSc if it wasn't for your channel!

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

    Big thanks to you! Currently I am a bit angry that my university is not capable of explaining such stuff in a nice way, but you did it in less time and in a much clearer way!

  • @darkhorse621
    @darkhorse621 4 года назад +2

    Best Explanation for DFS I've come across so far. Thanks a lot !!!
    Keep up the good work guys.

  • @qiuyangshen3569
    @qiuyangshen3569 3 года назад +16

    The call stack is a state! So brilliant words!

  • @Dunig2
    @Dunig2 4 года назад +4

    This is so clear to me, I’m amazed at how easy you make this to understand

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

    I saw the BFS & DFS (15 min) video followed by the maze problem. Wow! It clears out when and where to chose BFS over DFS. Thanks a LOT!

  • @darod6098
    @darod6098 5 лет назад +15

    Just amazing. I'm really grateful for your work

    • @BackToBackSWE
      @BackToBackSWE  5 лет назад +2

      long way to go...very very very very long way

    • @xxbighotshotxx
      @xxbighotshotxx 5 лет назад

      @@BackToBackSWE Don't forget to enjoy the journey :)

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

    This was fantastic. Thank you so much for such a clear, effective explanation of recursive DFS algorithms for maze traversal!

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

    Till now, your video is still saving lives. I finally completed my damn maze assignment after your explanation. Wherever you are bro, THANK YOU!!!

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

    Thanks so much for the video! This makes so much more sense now

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

    This dude is a brilliant tutor. Never have i ever understood an algorithm this clearly, Juss did.

  • @Hav0c1000
    @Hav0c1000 4 года назад +6

    Hey man, after listening to your excellent explanation, I was able to go and code this up! Thanks! You are a really good teacher!

  • @julianbullmagic
    @julianbullmagic 4 года назад +1

    keep posting videos, I would love to see more of this

  • @ceek79
    @ceek79 5 лет назад +175

    Honestly, you sitting in front of a computer would be a waste of talent! Take advantage of your skill to explain complex stuff the easy way and make a business out of it.

    • @BackToBackSWE
      @BackToBackSWE  5 лет назад +23

      👀👀💰💸💰

    • @jonathandaniel7321
      @jonathandaniel7321 4 года назад +10

      @@BackToBackSWE start a university with only you as teacher

    • @BackToBackSWE
      @BackToBackSWE  4 года назад +21

      @@jonathandaniel7321 I do not want to do that.

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

    Awesome explanation! Very clear and the right amount of details

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

    Great information 💪🏽💯 I appreciate it

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

    the visualizations are really fantastic. awesome work ben :)

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

    Brilliant - clear and concise!

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

    The way you explain is simply amazing sir!

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

    Dude thanks for thee constant repition. Really helped cement how depth first search works

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

      Glad to hear that! explore our 5 day free mini course for some cool content - backtobackswe.com/

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

    Beautiful video, you just earned a subscriber. I really admire your content!!!

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

    How did you convert the maze to adjacency matrix to apply DFS? Doesn't it seem difficult? Actually, do you have a cpp code for that? Thanks in advance

  • @kyawn5115
    @kyawn5115 4 года назад +1

    Great content! Keep up the good work!!

  • @psn999100
    @psn999100 5 лет назад +6

    WOW. best explanation so far. After this I am gonna do Maze I, II and III on Leetcode. I got asked this for Amazon OA and i screwed up cuz my fundamentals were not good. thanks

  • @ramraut180
    @ramraut180 4 года назад +2

    The great video. Thank you so much for your contribution. Keep continuing making this type of video. Thumbs up !

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

    I'm currently having a problem with implementing DFS in ruby, and have had it for a week now. Is there a way to get the code out of this video anymore?

  • @maharshidave4472
    @maharshidave4472 4 года назад +26

    Hello, sir you have high degree of patience to expain each and every minute detail. And I wish you will soon reach your traget of 100K subscribers and keep it up.😀

  • @chrisliu5403
    @chrisliu5403 5 лет назад +2

    appreciate it man, well explained.

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

    you explained so well, thank you!

  • @jkim5118
    @jkim5118 5 лет назад +4

    What's the main pros and cons of doing this in BFS and DFS? I thought DFS would be better, but it seems like only BFS is accepted on Leetcode. What are your thoughts? Also, do you think we should also know how to do Dijkstra for these kinds of search questions but with weights?

    • @BackToBackSWE
      @BackToBackSWE  5 лет назад +5

      BFS always finds the shortest path. The reason DFS times out is because it will get really far from the answer and waste time.
      BFS will find the object faster...generally...think about it...BFS goes out level by level and doesn't go deep into anything. This is good and bad.
      Ponder on these things.

  • @jeffreyslominsky7656
    @jeffreyslominsky7656 4 года назад +1

    Thank you, your explanations are great!

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

    Your patience is admirable

  • @richardaguilar7692
    @richardaguilar7692 4 года назад +1

    Thank you so much for this! Very clear and concise explanation of DFS.

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

    Hey can you explain why the time complexity is V+E. We are checking 4 (i.e. E) edges for each vertices(V). So shouldn't the complexity be 4V i.e. V.E?

  • @siddhantrai7529
    @siddhantrai7529 5 лет назад +2

    One of the best explanation of maze problem... Beautiful

  • @drizle9231
    @drizle9231 4 года назад +1

    That was a very clear explaination.Keep it up ! 😊

  • @sidb8066
    @sidb8066 4 года назад +1

    Hey! Great video! What;s the difference between DFS and Backtracking on this problem? Cant both be used and wont both work the same way?

    • @BackToBackSWE
      @BackToBackSWE  4 года назад +1

      DFS is a search methodology.
      Backtracking entails looking at candidate solutions in an exhaustive way (often following a search path) and "backtracking" to abandon partial solutions once they can't lead to a final solution.
      Both can happen at the same time. Example: "Search a graph for paths from the start to the end with cost < 100, no nodes have a negative cost." If I am on a path and my cost hits 140 I could be deep into a path (if I am using DFS) but I'd backtrack to the previous node I was at since I can't recover (i shouldn't have stepped on the next node in the first place but you get the idea).

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

    Thank you for saving us!

  • @anssha2643
    @anssha2643 4 года назад +1

    Best explanation of DFS. Thanks a lot. God bless you

  • @rubaiyathussain3124
    @rubaiyathussain3124 4 года назад +2

    Thank you. i fully grasp it.

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

    Great work!

  • @algorithmimplementer415
    @algorithmimplementer415 4 года назад +1

    May I ask, if you are given an adjacency matrix of m x m, in that case what would be the time complexity of DFS path finding algorithm? Could you also explain?

    • @BackToBackSWE
      @BackToBackSWE  4 года назад

      Sure, this search should give you what you need: www.google.com/search?q=DFS+with+adjacency+matrix+time+complexity&oq=DFS+with+adjacency+matrix+time+complexity&aqs=chrome..69i57j0l5.7645j1j7&sourceid=chrome&ie=UTF-8

  • @_see_u_in_next_game_8630
    @_see_u_in_next_game_8630 8 месяцев назад

    Could this algorithm change the numbers in the array on the way it finds?

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

    So amazing! Thanks!

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

    "Can I go up, yes I can!" is going to be looping in my head for a week after this video

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

    Your vids are brilliant.

  • @user-qq6ij6zl7d
    @user-qq6ij6zl7d 2 года назад

    Thanks! this is useful, im currently making a game which npc will randomly trigger travel event, but i need the npc to calculate the clear path to the end and avoid crash into
    rock and hill 😂

  • @ravitanwar9537
    @ravitanwar9537 5 лет назад +2

    hey man , i'm the one who asked for minimum window substring on leetcode . just wanna tell you that you doing a pretty good job and this channel HAS the potential. keep coming up with these videos and if possible with python language .
    cheers!

    • @BackToBackSWE
      @BackToBackSWE  5 лет назад

      hmmmm, yeah, good idea. I need to brush up on my Python though. My languages in order of strength: Java, Typescript (a superset of course), Javascript ...then some experience with C, C#, Ruby

    • @ravitanwar9537
      @ravitanwar9537 5 лет назад +1

      @@BackToBackSWE n i think it'll also be a good idea if you specify the difficulty level before the video . for eg :- easy , medium , hard on leetcode ,

    • @BackToBackSWE
      @BackToBackSWE  5 лет назад

      @@ravitanwar9537 Every video has badges of the difficulty.

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

    Where is the code for the DFS approach

  • @Thadnill
    @Thadnill 4 года назад +1

    If I want to use the DFS to generate a maze in C++, and not necessarily solve it, how should I think and start out?
    Thanks for the great video!

  • @dongshuowu3454
    @dongshuowu3454 5 лет назад +2

    Amazing as usual.

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

    Subscribed the channel, Liked the video, it deserves it.

  • @xinchen7702
    @xinchen7702 5 лет назад +2

    thanks a lot man

  • @shubhamk840
    @shubhamk840 4 года назад +2

    you have an amazing skill of teaching, even 10 years old can understand your explanation.

  • @francescopiazza4882
    @francescopiazza4882 7 месяцев назад

    Very good, thanks !

  • @SouravGhosh-pb5nm
    @SouravGhosh-pb5nm 2 года назад

    Thanks bro!

  • @vrdash
    @vrdash 4 года назад +2

    The video goes in-Depth of the topic literally and thus my search for DFS is complete :p

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

    this is amazingly amazing explanation. thnx buddy

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

    Doing the lords work with these videos! Thank you!! Lol

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

    If I'm not mistaken, this approach is backtracking, right? And its complexity is to the exponential order of 2^(n*m) where n*m is the order of the matrix, but for a vanilla DFS we should have linear complexity, O(m*n)

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

    Big Thanx

  • @PushpendraKumar-ck8op
    @PushpendraKumar-ck8op 5 лет назад +1

    thanks for this great video.

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

    Is the code available for this dfs?

  • @kirillzlobin7135
    @kirillzlobin7135 9 месяцев назад

    Maaan, you are the legend. Thank you for your brilliant explanation!!!

    • @BackToBackSWE
      @BackToBackSWE  9 месяцев назад

      Happy Halloween 🎃 Thank you from one legend to another, kirillzlobin! You get some extraaa treats - 50% Off our exclusive lifetime membership use the code SPOOKY50 - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=SPOOKY50

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

    Amazing explanation, but not able to find the code in the description.

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

    The best explanation on the internet.

  • @rakibhossain2536
    @rakibhossain2536 5 лет назад +2

    Excellent,,tnxx for this good video

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

    I have a question , i am making a micromouse but how will it know the end ?? Does i have to pre program the final destination and the maze size??

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

      I think there are three ends! How will my mouse knows which one is the final end??

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

    Awesome explanation

  • @augischadiegils.5109
    @augischadiegils.5109 3 года назад +1

    Thanks man

  • @goldfishbrainjohn2462
    @goldfishbrainjohn2462 4 года назад +1

    This helped me a lot!! I love the way you teach. Thanks. Subscribed immediately
    Edit: The code below is my version of DFS for a maze problem and the concept is based on this video. Appreciate it.
    function solve(lines) {
    let wAndH = lines.shift();
    wAndH = wAndH.split(' ');
    let [w, h] = wAndH;
    w = Number(w);
    h = Number(h);
    let nestedArr = lines.map(item => {
    let a = [];
    a.push(item);
    return a;
    })
    nestedArr = nestedArr.map(item => {
    return item[0].split("");
    })
    let blockStart = [];
    let blockEnd = [];
    for(let i = 0; i < w; i++){
    blockStart.push('#');
    blockEnd.push('#');
    }
    nestedArr.splice(0, 0, blockStart)
    nestedArr.splice(h+1, 0, blockEnd);
    nestedArr.forEach(item => {
    item.unshift('#');
    item.push('#');
    })
    let roadCoordinates = [];
    function findRoad(arr = [], h = 0, w = 0, road) {
    const checkUp = (arr, h, w) => {
    if(arr[h-1][w] === '.') {
    return true;
    } else {
    return false;
    }
    }
    const checkRight = (arr, h, w) => {
    if(arr[h][w+1] === '.') {
    return true;
    } else {
    return false;
    }
    }
    const checkDown = (arr, h, w) => {
    if(arr[h+1][w] === '.') {
    return true;
    } else {
    return false;
    }
    }
    const checkLeft = (arr, h, w) => {
    if(arr[h][w-1] === '.') {
    return true;
    } else {
    return false;
    }
    }
    if(arr[h] != 'undefined') {
    if(arr[h][w] === '.') {
    if(checkUp(arr, h, w)) {
    arr[h][w] = '1';
    road.push([w,h])
    findRoad(arr, h-1, w, road);
    } else if(checkRight(arr, h, w)) {
    arr[h][w] = '1'
    road.push([w,h])
    findRoad(arr, h, w+1, road);
    } else if(checkDown(arr, h, w)) {
    arr[h][w] = '1'
    road.push([w,h])
    findRoad(arr, h+1, w, road);
    } else if(checkLeft(arr, h, w)) {
    arr[h][w] = '1'
    road.push([w,h])
    findRoad(arr, h, w-1, road);
    } else if(arr[h][w] === '.') {
    arr[h][w] ='1';
    road.push([w,h])
    }

    } else {
    console.log('Wrong')
    }
    }
    }
    findRoad(nestedArr, 1, 1, roadCoordinates)
    nestedArr.pop();
    nestedArr.shift()
    nestedArr.forEach(item => {
    item.pop();
    item.shift()
    })
    roadCoordinates.pop();
    console.log(roadCoordinates.length)
    }

  • @mohdashraf3903
    @mohdashraf3903 4 года назад +1

    I really liked your video +1 Subscribed!!

  • @c.danielpremkumar8495
    @c.danielpremkumar8495 4 года назад +1

    Excellent !

  • @toyadavrahul
    @toyadavrahul 5 лет назад +2

    Great Explanation!! would be better with some pseudo code!! Else found it really helpful. Thanks!!

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

    U hv given a greatest explanation i ever had on RUclips..but implementation is also important right..plz do explain codes as well

  • @multichannellk1966
    @multichannellk1966 4 года назад +2

    Where is the solution code please give me the link

    • @BackToBackSWE
      @BackToBackSWE  4 года назад

      The respository is deprecated - we only maintain backtobackswe.com now.

  • @lawlietnao_music
    @lawlietnao_music 4 года назад +1

    dude I hecking love you, if I get the offer I'll definitely donate the shit out of u

  • @guptapaaras
    @guptapaaras 4 года назад +1

    Best explanation !!

  • @MultiSilverbolt
    @MultiSilverbolt 4 года назад +1

    Is the code posted applicable for both BFS and DFS approach?

  • @prometheu5393
    @prometheu5393 4 года назад +1

    thank you

  • @ebiigweze3384
    @ebiigweze3384 4 года назад +2

    "AND NOW WE ARE THIS CELL" ........that is a drinking game right there...number of times that was said, man would be wasted in no time...cool tutorial bro .. keep it up

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

    I want to ask how did you decide the order of the operations "up","right","left",down" , is it because you compared the starting cell and the goal/end cell and found out you should prioritize "up" and "right" operations ? so thats why they are at the top of the order of the operations and you check on them first?

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

      and can you please provide me the of the code that corresponds to this problem

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

    wow thanks so much this helped

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

      appreciate the comment 😄 Would love to hear your thoughts about our FREE DSA course at backtobackswe.com/ 💯

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

    Your delivery and presentation is just on POINT. I don't like it, I LOVE IT. You helped me tackle a PACMAN PROBLEM USING THE UNIFORM-COST SEARCH BY JUST WATCHING THIS VIDEO

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

    Sir,In some cases time limit exceeded, how to overcome it ?

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

    thanks bro

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

    I don't usually leave likes on videos but you deserve it my guy.

  • @gulshankataria77
    @gulshankataria77 4 года назад +1

    Awesome explanation sir!!!

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

    Best explanation🖤

  • @erichlf
    @erichlf 5 лет назад +20

    Amazon asked me this in the phone interview and even though I knew it I promptly fucked it up.

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

    Where is the code?

  • @Thadnill
    @Thadnill 4 года назад +2

    Woa, you just got my sub!
    P.S do you have the code available? I can't find it

    • @BackToBackSWE
      @BackToBackSWE  4 года назад

      Thanks, and the code repository is deprecated - we only maintain backtobackswe.com now.

  • @jason17493
    @jason17493 4 года назад +2

    clear explanation

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

    Is there a way I could see the code? Do you have a repo by any chance?

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

      We only maintain code samples on backtobackswe.com

  • @biboswanroy6699
    @biboswanroy6699 4 года назад +1

    For a maze where we also have a given start point. Isn't dfs time complexity O(V) and not O(V+E) here ?

    • @BackToBackSWE
      @BackToBackSWE  4 года назад

      It is always O(V+E) even given the start