N Queen Problem Using Backtracking Algorithm

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

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

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

    Awesome explanation. You inspired me to make my own version of this video for explanation.

  • @cappuccinuo8588
    @cappuccinuo8588 6 лет назад

    Great video man!

  • @julianpow96
    @julianpow96 6 лет назад +3

    Is Rajesh Koothrappali ur bro?

  • @pb6785-k3m
    @pb6785-k3m 7 лет назад

    Which of the following data structures is used in backtracking algorithm?
    A: Queue
    B: Stack
    C: AVL Tree
    D: Skip List

  • @imyudi09
    @imyudi09 7 лет назад

    Row 0 Column Thoo

  • @samaryadav7208
    @samaryadav7208 7 лет назад +12

    just my opinion: 95% of Indian engineering students waste average 6 hours per day in colleges learning shit. We can easily understand actual concepts on youtube in 2 hours and through books for extra. Shit and lazy ass professors and money making colleges. Don't want to hurt anyone's sentiments but IT's THE F TRUTH. Thanks Tushar bhai. I am grateful to you.

    • @MrSupernova111
      @MrSupernova111 7 лет назад

      I give you thumbs up because the same can be said for any field of study. But no employer is going to hire you to an engineering position without a degree. So the paper degree has its value.

    • @jaimeogrady6843
      @jaimeogrady6843 7 лет назад +1

      I agree with you at some point. But college its also important because there professors guide students threw the most important subjects. If many people didnt go to college, this videos wouldnt be watched by the same amount of people.

  • @chiraggupta2472
    @chiraggupta2472 5 лет назад +37

    I have never written comment on any video whether it is good or not, But your videos force me to write comment, By heart you are Genius man !!!
    Legend of Computer Science!!!!!

    • @shresthmishra9329
      @shresthmishra9329 4 года назад +8

      thanks for writing the comment for the first time.Now i can die peacefully.

  • @darraghosullivan274
    @darraghosullivan274 4 года назад +8

    Tushar, these videos are phenomenal. It's very apparent that you have spent a lot of time preparing this material - your explanations and examples are incredibly clear. Thanks!!!

  • @hrishikeshwaikar251
    @hrishikeshwaikar251 7 лет назад +11

    Great Explaination Tushar. Kindly consider doing the Graph Coloring problem using backtracking as well!

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

    I can't put into words how much these videos help me and my friends understand the subject you cover!
    No way in a million years that my professor will go that deep into the explanation of the all the little (but very important) details you do explain.
    Please, please cover more topics in the future! :)

  • @remusik04
    @remusik04 7 лет назад +8

    For the diagonal condition there is an alternate. Given two cells with the coordinates (i1, j1) and (i2, j2) , you can say they are on the same diagonal if | i1 - i2 | = | j1 - j2 | . You can validate this by calculating with values, or you can deduce it from the two formulas you have stated. This way you only need a single formula to validate if the queens attack on diagonal.

    • @RishabhVerma
      @RishabhVerma 6 лет назад

      Totally agreed. Taking absolute of " |X2 - X1| == |Y2 - Y1| " is better conditional statement for checking if the queen is safe or not.

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

      You can deduce this with the slope of the line formula
      Y2 - Y1/X2-X1 = +1 or - 1 implies that the angle is either 45 or 135 degrees and hence is a diagonal

  • @DineshYadav1988
    @DineshYadav1988 7 лет назад +73

    I have seen most of your videos and just wants to say a big thanks. you are a role model for many young people coming out and wants to achieve something big in their life....

  • @rockonyo100
    @rockonyo100 7 лет назад +30

    Thanks.. A Suggestion- You could simply check if mod(row1-row2)== mod(col1-col2) to check for the diagonal attacking position rather than using 2 separate formulas for 2 diagonals.

  • @ashiqimran2852
    @ashiqimran2852 8 лет назад +5

    Isn't the time complexity O(n!)??

  • @jamesmitchell8909
    @jamesmitchell8909 7 лет назад +7

    Best explanation I have seen yet. Thank you!

  • @BhawaniSelva
    @BhawaniSelva 7 лет назад +1

    What is the time complexity of this problem?

  • @AshiksTechVlog
    @AshiksTechVlog 7 лет назад +1

    wow. clear as water.

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

    The legend of Computer Science. Yesterday I had lots of problems regarding coding a solution for this problem, now I don't have any. Brilliant video!

  • @abhilashraipally5665
    @abhilashraipally5665 6 лет назад +1

    Hey, which part of you code does backtrack? I think somewhere you have to remove the elements from position when its not safe. I can't get that part in your code. Can you explain

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

      I got the same doubt and tried to understand that piece of logic. Looks like, the elements won't get removed as such from Positions, they rather get replaced/updated by a new element in the next iteration.

  • @praveenlakhotia
    @praveenlakhotia 7 лет назад +4

    was wondering if someone could elaborate on time complexity of algorithm

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

    Any trick to make this code to get all possible solutions?

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

    best video available for the N queen problem using backtracking .

  • @yashkenia7422
    @yashkenia7422 7 лет назад +1

    A big thaanks dude!!!!!!

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

    hey i don't know about of number of views people have got in their video for explaining N queens problem. But i tell you people this is the best explanation. NOBODY by far can teach in such a simpler way as he has done. You have any tutorials for all this Tushar, i would love to join it.

  • @Lens_lores
    @Lens_lores 6 лет назад

    This is an awesome explanation. Helped me understand backtracking. And all the people telling you that your english is horrible do not deserve your attention. Fuck 'em

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

    I've written a small article to explain this topic. Hope you find it useful! @ www.thecodenote.com/2017/05/beginners-guide-to-solving-n-queens.html

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

    Is it easy or difficult to find one pattern (one solution) of 2500 or 5000 queens with Backtracking Algorithms?

  • @shreyaashtekar
    @shreyaashtekar 8 лет назад +3

    Very helpful! Thanks for sharing

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

    very good by far the best explanation for this problem the explanation of index of attacks was very very helpful

  • @amitgp2007
    @amitgp2007 8 лет назад +1

    Thanks sir..Its very good explaination. One problem : when we are backtracking we should delete element from position array.
    if(solveutil)
    return true;
    else
    delete pos;
    ......
    return false;

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

    you alright bro? you got the thousand algorithm stare goin

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

    Good Explanation. Helped me to understand the problem easily. Thank You.

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

    Tushar roy : How Does a Queen Attack?
    Me : By Marriage
    😂😂😂😂

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

    Thoroughly explained! I love this! Thank you for your video!

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

    Greatest explanation (for me). Thank you so much

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

    Here's a more elegant explenation:
    ruclips.net/video/R8bM6pxlrLY/видео.html&feature=share&fbclid=IwAR3Sl96wOacXpuifjl3syZJv8foyH4z_TENM-Q6k75SPTSvEybSb6n9KrG8

  • @ArminaKanus
    @ArminaKanus 23 дня назад

    Garcia Brian Gonzalez Mary Walker Jeffrey

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

    can you link to the chessboard visualizer?

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

    thanks Tushar Roy, your videos are really helpful

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

    can you explain how backtracking is happening here

  • @dimkinbel
    @dimkinbel 8 лет назад +1

    Great video , again !

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

    Could anyone tell me what is the visualization tool he is using?

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

    Hi thank you. Can you explain with bishop?

  • @hariprasad3882
    @hariprasad3882 4 месяца назад

    Anyone who's watching in 2024!

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

    Great Explanation. the best one on n-queen problem.

  • @leavexu
    @leavexu 7 лет назад +2

    Thanks very much!!!

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

    Thanks for the videos, they are great! Keep up the good work!!
    I went through this code which says it is of Time: O(n*n) but actually, it's of Time: O(n*n*n) because you fix rows (Time: O(n)), increment col for every row (Time: O(n)) and check for positions for every col which again is another Time: O(n). All of this adds up to Time: O(n*n*n). Please check and correct it.

  • @maxzriver
    @maxzriver 6 лет назад

    If they gave me a problem in real time I can solve it with the basic serial and according to the family that belongs to the board.
    This is only for cases of an empty board. For the case of a board with a queen on the board, I can solve all the prime boards in the position that the queen is indicated, be of the size that is from n = 5, 7,11,13,17,19,23. ........ 61, ..... etc

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

    You are a hero at explaining things.WELL DONE SIR.THANK YOU SOOOOOO MUCH.

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

    I noticed that in the code example you have the space complexity as O(n*n), however, isn't it O(n) where n represents the total number of queens we have?

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

    The tree visual was fantastic. It allowed me to visualize how the algorithm was eliminating possibilities and backtracking to the first level to start over.

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

    Thank you Tushar! Your explanation is really clear and makes sense. It saves me tons of time and makes my day! I hope you can continue to upload more videos.

  • @chetak2
    @chetak2 8 лет назад

    Hi Tushar, In your N-queen video, you said the time complexity is exponential but your github comment has time complexity as n2.

  • @learnwithmanu5655
    @learnwithmanu5655 8 лет назад

    Very clear cut explanation of n Queen problem. Thanx a lot Sir. Please upload the videos on bellman ford with directed graph with algorithm. Sir it is very hard to understand. Please Sir help me In this.

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

    goob expolntn love frm pakistan

  • @sunilmaurya1572
    @sunilmaurya1572 8 лет назад

    sir plz explain about GRAPH COLORING using backtrack

  • @israamousa6587
    @israamousa6587 7 лет назад +1

    can you write an implementation of mazes game using c language

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

    I've watched 3 videos prior to yours' on this topic and so far you've done the best job explaining it. Thanks.

  • @nicksunny
    @nicksunny 7 лет назад

    There are a lot of obviously unnecessary check that could be avoided: the four squares around each queen are for sure not safe so why even try it? I would create N square object with a queen property that holds the queen id if attacking it. After each queen position iteration I would jump to a square that is not already attacked by a queen and place the queen and register her id to all squares it attacks. So after each iteration the number of available unattacked squares will reduce and makes the the algorithm finish much faster.

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

    The best explanation for backtracking..........!!!!! thanks tushar... :D

  • @hanzhang2020
    @hanzhang2020 8 лет назад

    Awesome video, thank you so much.
    If I may suggest, it might be better if you can also use a mic for the white board explanation since the sound quality will be much better.

  • @shivrajghatkar3099
    @shivrajghatkar3099 7 лет назад

    When we backtrack shouldnt we clear the previously set foundSafe position in the positions array?

  • @aditi8953
    @aditi8953 8 лет назад

    it is very helpful sir...can please explain global parallel genetic algorithm for solving n queen problem n also naive algorithm for n queen

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

    This is the best explanation I got yet.

  • @nikhilsunriders5203
    @nikhilsunriders5203 8 лет назад

    can you tell me 6 Queen's problem?

  • @roh9934
    @roh9934 7 лет назад

    Can you please make a video on "How to make recursion tree" and thinking of solving it recursively, i often confuses when i see two or more functions calling to same functions again and again.

  • @skootergofast123
    @skootergofast123 6 лет назад

    Thank you for making me understand Recursion.....What I have got from your explanations is something very valuable....I got to learn the concept of Recursion, Back Tracking and Dynamic programming. After understanding the concept, I am able to code it myself. Thank you

  • @jaballahmourad590
    @jaballahmourad590 6 лет назад

    can you help me ; i have an exercice ; last letter first letter problem ; i dont understand how i use backtracking thanks

  • @himanshuganapavarapu3219
    @himanshuganapavarapu3219 6 лет назад

    Only if Engineering Colleges in India hired teachers like you, we would not have to watch this video.

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

    You are amazing. I code in python but the way you explain your code is so good. Thanks : )

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

    Agree with others. Your explanation made so much sense. Great job.

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

    Your explaination is always clear and easy to understand! Thanks for your videos!

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

    If anyone's struggling with the indices for the diagnols think of straight line equations but this array is in the 4th quadrant

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

    what if i fixed 2 queens in 8 queen problem , then how many solutions exists in 8 queen problem?

  • @RohitKumar-uj4ho
    @RohitKumar-uj4ho 7 лет назад

    Great Work, a neat and simple solution,
    is there any other solution possible for Nqueen problem with lesser timeComplexity.

  • @ashefshahrior5437
    @ashefshahrior5437 7 лет назад

    big thanks for making such amazing videos. It'd be of great help if you do a video on GRAPH COLORING (Using Backtracking). Please. Thanks in advance. :)

  • @richa6695
    @richa6695 7 лет назад

    Can anyone tell me why Tushar has taken 1 box for row 0, 2 for row1, 3 for row 3 and again two for the last row?

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

    May 2021 LC challenge anyone?

  • @webberwang6520
    @webberwang6520 6 лет назад

    What if don’t know how many queens can fit on the board? Or is it assumed as part of the problem

  • @Crossf4de
    @Crossf4de 7 лет назад

    Awesome video, very well explained. I think that I would now be able to solve this exercise even a little later in the future, as I have understood the principle and the rules to determine a valid placement for a queen.
    One question regarding the backtracking step though: If a callee function return false to the caller, that's to say a deeper level of recursion can't find a valid place for a queen, the calling function continues to look for a valid place one column ahead where it stopped before. However, the previously placed queen in the array is never cleared and remains there. Doesn't that cause problems? On the right hand side you always remove the notes but you don't do it in the code.
    WOuldn't you have to add an else statement after the if(foundSafe) block to remove an falsly placed queen?

  • @manoranjith472
    @manoranjith472 7 лет назад

    I would be nice if coding is explained a bit clearer. Thanks anyway.

  • @AtulSingh-qx6jn
    @AtulSingh-qx6jn 6 лет назад

    Can you zoom the algorithm section? . it would be much helpful

  • @gauravsharma7555
    @gauravsharma7555 7 лет назад

    sir could u also.make videos on graph coloring and hamiltonian problems

  • @anupamashoktiwari5709
    @anupamashoktiwari5709 6 лет назад

    but in the second row queen off diagonal is going to attack by first row queen!!

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk 6 лет назад

    Please can you make a video on 8 puzzle problem using A* search.

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

    hey! looking for the python code of this algorithm ... Any help please ?

  • @MrSupernova111
    @MrSupernova111 7 лет назад

    What about the 8 queen problem? Can your code be scaled to larger problems?

  • @desalegnbelay9088
    @desalegnbelay9088 6 лет назад

    thanks a lot for your clear and brief tutor and it insight me about this topic thanks again keep go on

  • @shridharhegde2593
    @shridharhegde2593 6 лет назад

    Very good and clear explanation. Thank you for the video.

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

    this is a great video. Always helps me a ton to see stuff drawn out like this.

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

    You can keep a Map for the finding how many queens are attacking a row, column or diagonal and check if the current cell is under attack or not

  • @davidfesteban
    @davidfesteban 6 лет назад

    Hello m8! I was expecting another kind of solution. I really appreciate your video and i would like to say thank u. But, i think that we could work in a faster solution

  • @razakadam74
    @razakadam74 6 лет назад

    I like your explanations but I find it really hard hearing you. Kindly work on your audio

  • @AbhishekTiwari-xk5go
    @AbhishekTiwari-xk5go 7 лет назад

    sir, can i get the above code in C++, i would be very helpfull if u can do it

  • @vivekchaurasia8925
    @vivekchaurasia8925 6 лет назад

    i saw your lots of videos which helps me a lot do as many as possibles plz...

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

    I watched many backtracking videos, but this is so simple and understandable. thank you man

  • @khushboochauhan745
    @khushboochauhan745 8 лет назад

    can u show give the solution tree/space tree for n queen problem?

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

    concise explanation. understood the use of row + i, row - i .

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

    Loved this solution!! Your solution is amazing.. would be better if you had explained time complexity, why it is exponential.

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

    Appreciate your hard work. Very well explained.