6.4 Hamiltonian Cycle - Backtracking

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

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

  • @dorkCatechol
    @dorkCatechol Год назад +96

    00:05 Hamiltonian cycle is a problem of finding a cycle that visits every vertex exactly once in a graph.
    02:32 There are multiple Hamiltonian cycles possible in a graph
    04:47 Hamiltonian cycles are not possible in a graph that contains articulation points and pendent vertices.
    07:18 The Hamiltonian algorithm starts from vertex 1 and tries to form a valid path.
    09:47 The algorithm checks for cycles in an array.
    12:09 The method is to use the mod function to get the values in a specific pattern.
    14:23 There are two possible Hamiltonian cycles in the given example
    16:34 The Hamiltonian cycle algorithm works by recursively checking for cycles in a graph.
    hope this helps

  • @islstudentzone6573
    @islstudentzone6573 6 лет назад +396

    Thank u so much Abdul Bari Sir..Your Channel is helping a lot to our CSE & IT Department :)

    • @sohamparmar4976
      @sohamparmar4976 Год назад +6

      Physics students too by learning classical algorithms and trying to find an efficient quantum algorithm for the same problem.

  • @msafadonus
    @msafadonus 6 лет назад +457

    You Indians! You are amazing! Thank you for your help. Best Regrads from Turkey!

  • @KevinAMathew
    @KevinAMathew 5 лет назад +1981

    I just realised my teacher watches your videos first and then teaches us😂🤦‍♂️

    • @vinothsiva7022
      @vinothsiva7022 5 лет назад +40

      Same here😂😂

    • @ZapySolo
      @ZapySolo 5 лет назад +68

      same here... our teacher even recommended us to watch his playlist

    • @KevinAMathew
      @KevinAMathew 5 лет назад +80

      @@ZapySolo, your teacher is a good person.

    • @mahimsd7645
      @mahimsd7645 5 лет назад +63

      All teachers who watch him and then teach are good learner's ...

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

      lol same

  • @hollyj8650
    @hollyj8650 3 года назад +22

    He is absolutely the clearest teacher on RUclips and other online sources. Thank you so much

  • @Chaitanyat6
    @Chaitanyat6 4 месяца назад +9

    6 years and still one of the best playlist to learn algorithms

  • @MiddleEasternInAmerica
    @MiddleEasternInAmerica 4 года назад +79

    sending love and respect from EGYPT, thank you

  • @jayapandey5876
    @jayapandey5876 6 лет назад +54

    sir, you are a mind blowing teacher. While studying any of your tutorials, i have got no doubts though i had no prior knowledge on the topics. Thank you for making these videos.

  • @emanhussien2325
    @emanhussien2325 5 месяцев назад +5

    Too much respect Teacher from Ethiopia ❤❤❤😊😊

  • @TusharSingh-un9wn
    @TusharSingh-un9wn 3 года назад +3

    I watch your videos first thing in the morning , as they say, To make your whole day better do something good after you wake up.

  • @yaseenmac3891
    @yaseenmac3891 6 лет назад +21

    What a wonderful explanation.
    Keep going sir. Students needs teachers like you.
    -bangalore

  • @dimitarmitranov4436
    @dimitarmitranov4436 4 года назад +16

    Sir, I just want to say, that this is the first Indian scientist who teaches programming or mathematics with an accent I am willing to listen to. Great English, great explanation. Good Job!

  • @srijani_mondal
    @srijani_mondal Год назад +8

    Just awesome sir.......can't express your help sir throughout my DAA journey....a lot of respect for you sir.....🙏🙏🙏🙏

  • @NaveenNaveen-vj9bo
    @NaveenNaveen-vj9bo Год назад +56

    Paying lakhs to college but still studying in RUclips 🤧

  • @ShivAdiShakti108
    @ShivAdiShakti108 5 лет назад +9

    Sir, You are Pride of Data Structures and Algorithm! A Big Thank You :)

  • @nohaahmed1948
    @nohaahmed1948 2 года назад +10

    Your algorithm playlist is really so helpful and pretty clear for complex ones, thanks a million sir.

  • @winsont.7403
    @winsont.7403 5 лет назад +17

    Thank you very much ! Your video helped solving one of the major challenges to the project we are doing !

  • @pravinnaga3524
    @pravinnaga3524 4 года назад +35

    There’s a direct entry ticket reserved fr u in heaven fr making me to understand this concept fr my tomorrow algorithm exam 🙃

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

    After watching your explanation there is no chance to dislike....
    Tqq sir

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

      So you were disliking before, without watching the video?

  • @brnakblut
    @brnakblut 14 дней назад +1

    this man is exact definition of "teacher"

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

    Sir you explain these algorithms so perfectly. I really thank you for helping us in building a strong foundation of algorithms.

  • @程龙-b1w
    @程龙-b1w 6 лет назад +20

    You rock, Sir. Complex concept is explained simply and clearly.

  • @venkatanagaeswarkousikneri462
    @venkatanagaeswarkousikneri462 5 лет назад +13

    Vidyaniketan students,hit the thumbs here to show thankfulness to sir at the last moment.

  • @krishnachaitanya5050
    @krishnachaitanya5050 3 года назад +5

    Thankyou sir.With the help of your videos I am able to clear my daa paper almost.Whatever may be the result of it,your videos are always no1 for future reference too.🙏tqsm sir

  • @nathancarnelos
    @nathancarnelos 4 года назад +5

    watching this class from brazil, amazing teacher!

  • @spartaninfo3273
    @spartaninfo3273 Год назад +6

    my teacher directly playing this playlist in class.

  • @ashokepaul540
    @ashokepaul540 Год назад +2

    Thank you sir, 🙏🏼 you explained well as nobody else did yet..but it is a NP - complete problem!

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

    Sir thank you. .your teaching was excellent. .what ever your concept logic is to good for student understanding. After watching your videos we are confident about the concept. .

  • @kunalwadhai777
    @kunalwadhai777 Год назад +1

    I had never saw the content like that and the way you explain the algorithm is like a boom fire....Yeah I realize and it is true that if a teacher is expertise in that perticular subject then no one subject is hard for student.

  • @masongarcia8936
    @masongarcia8936 3 года назад +6

    Thank you so much Sir! You do an amazing job at explaining these concepts. Much appreciation in the US!

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

    As always the best teacher on internet!!

  • @sagarmishra6746
    @sagarmishra6746 3 года назад +23

    I just realised that this is the only way to learn my subject because our teacher never teaches us

  • @priyeshgautam6270
    @priyeshgautam6270 6 лет назад +2

    i had given up on exams, until i saw your tutorials sir thankyou very much :)

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

    Assalamua'likum, sir. Love from University of Dhaka. Your explanation is way too good Alhamdulillah, and really helpful as well.

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

    You make complex things dead easy... Kudos Sir

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

    Abdul, based on the information in Corman's book, Travel Salesman and H-Cycle problems are NP-Complete. 1:30 you mentioned it's an NP-hard problem

    • @陳可瀚-w6r
      @陳可瀚-w6r Год назад +3

      NPC is both NP-hard and NP problem

  • @anupdhoble2879
    @anupdhoble2879 11 месяцев назад +4

    For Revision start at : 7:00

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

    sir i always found everyone blessed you for what you are doing

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

    This will help me in my semesters which is due tomorrow!!

  • @krishnasamandhayala2584
    @krishnasamandhayala2584 6 лет назад +12

    great teaching skill. simply rocking sir,

  • @adiShekhar7
    @adiShekhar7 6 лет назад +7

    this is some epic stuff !! the way of explanation is just amazing !

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

    u are the teacher of our teacher's

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

    best explanation ever
    Gr8 work sir
    very nice and clearly explained..

  • @souravdutta7120
    @souravdutta7120 6 лет назад +2

    Wow the best explanation anyone can give. thank you so much.

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

    I wish you would show us the code for every other problem like you do in this particular one. Very nice explanation!

  • @premprakash5932
    @premprakash5932 6 лет назад +18

    Really, impressive. You explained perfectly.

  • @indiandroid
    @indiandroid 5 лет назад +51

    Is it me or does this video look normal in 2x speed??????

  • @sivaram9654
    @sivaram9654 6 лет назад +27

    *simply,rocking sir*

  • @fearless.vishnoi
    @fearless.vishnoi 6 лет назад +2

    i realised that our college teachers teach us after learning from these videos

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

    You are amazing! Thank you for your help. Best Regrads from syria

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

    thanks for the algorithm... love your teaching style Sir..

  • @spotlight4091
    @spotlight4091 6 лет назад +2

    Very nice explainations sir....This is first time studying,can't understand some topics in this subject...But ur class and explaination, give more clear and good pronounsation to understand...thankq so much sir...continue🙏

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

    This way of describing algorithm is very easy to understand

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

    I want to be a teacher like you....your vedios help me a lot to teach DAA.☺

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

    I just realised i watch your videos first and then teach my teacher

  • @sydharthydv
    @sydharthydv 6 лет назад +18

    I wish I had a sir like this irl

  • @vinaysonekar2001
    @vinaysonekar2001 2 года назад +10

    Exact same question, answer and method in my college notes means my teacher first watches Abdul sir's video and then teach us😂
    Thank you Sir for such a good explanation 😊

  • @malinakumar3837
    @malinakumar3837 6 лет назад +2

    you are the best teacher i have ever seen

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

    Thank you so much sir......it was the best explanation one could ever get

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

    Great job sir....!! Tqsm for making Daa so simple and easy to understand!

  • @lazarus6983
    @lazarus6983 16 дней назад

    Wow amazingly clear explanation. Very good teacher

  • @Abuthalharahmani
    @Abuthalharahmani 9 дней назад

    Thanks sir today my design and analysis of algorithms exam they asked this question . ❤

  • @chenyi-d5j
    @chenyi-d5j Год назад +1

    thank sooo much! explained so clear for us students.您配享太庙。

  • @nafshhhh
    @nafshhhh 6 лет назад +4

    Sir ur videos Are very helpful for us....

  • @harshpenshanwar5543
    @harshpenshanwar5543 Год назад +2

    great teaching sir👍👍👍

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

    I am preparing for the exam. Thank you so much for your lesson.

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

    Teacher of Teachers.

  • @mysterylooks1
    @mysterylooks1 Год назад +2

    Sir can you do a video on Edit Distance and Counting Inversion problems? I love your work and would really want to see these topics covered by you, you're simply magical

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

    Sir thank you very much for making it understable and easy

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

    It was clear and clean,thanks a lot sir

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

    thank u so much sir.. you have outstandin way of teaching... finally i cleared on some other Daa topics by your lectures... once again thank you so much

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

    Thank you so much sir! Made my day.. really was'nt able to find appropriate notes that articulates the main thing which is in fact way easier than rather complicatedly mentioned in regular classses.

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

    Thank you, thank you, thank you, thank you sir. you are a god sent

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

    Very helpful and good explanation 👍

  • @mohdshahalamrayeen4452
    @mohdshahalamrayeen4452 6 лет назад +2

    keeping spreading knowledge and love sir.... Thanks for this video course.

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

    Abdul Sir, you are explaining stuff really well. Can you make videos on Dynamic Programming and how to tackle those problems in top-down and bottom up approach!

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

    Clearing my subjects with good marks only because of you and gate smashers 😂🛐

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

    14:00 the explanation of algorithm

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

    Thank you very much. I don't think anyone could explain it in better words.

  • @boibrainiac
    @boibrainiac 7 месяцев назад +1

    you are always with me in my shower before an exam. 🚿

    • @Anji.145
      @Anji.145 7 месяцев назад

      He's also with me in the exam 😊

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

      Let me also join 😄, ill also bring mausam 👉👈

    • @boibrainiac
      @boibrainiac 7 месяцев назад +1

      @@syedaaryan5985STAY AWAY from my mausam. he makes me wetter than the shower

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

    You are the saviour sir😊

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

    Best ever explanation.....Thanks sir.....😇😇😇😇

  • @sumitkumar-kh6vs
    @sumitkumar-kh6vs 6 лет назад

    sir your teaching style is very nice i am underatanding easily keep it up sir

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

    a goldmine in youtube

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

    Thank you sooo much sir .... Just made it very clear ❤❤❤❤❤❤

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

    I wish google had a double like or triple like option for ur videos

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

    thank you, uni student from syd.

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

    Thanks, you carried my assignment :D

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

    It was really really helpful. Thank you so so so much.
    I loved your teaching techniques sir.
    Keep going.

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

    Thanks a lot abdul sir . Liked that you explained the written code as well. Pls try and do it for all problems .

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

    I have written sample code for this problem.
    package bt;
    public class HamiltonianCycle {
    /**
    * Find all HamiltonianCycle solutions
    * @param graph
    * @param slots
    * @param slotCurrent
    * @param startVertex
    */
    public static void find(final int[][] graph, int[] slots, int slotCurrent, int startVertex) {
    int[] connVertexes = graph[startVertex];
    // Find all the branches a vertex can go deep in
    for (int point = 0; point < connVertexes.length; point++) {
    // We can use this point
    if (connVertexes[point] == 1) {
    // Use startVertex as the path
    slots[slotCurrent] = startVertex;
    try {
    // Rule2: Check if slots is full, this point should have an edge to the start point
    if (slotCurrent >= slots.length - 1) {
    if (checkConnectToStartPoint(graph, point, slots)) {
    printSolution(slots);
    return;
    }
    } else {
    // Rule1: This point should not be duplicate with point in slots
    if (checkDup(point, slots)) {
    continue;
    }
    // Move slots pointer
    // Go deep in this point
    find(graph, slots, slotCurrent + 1, point);
    }
    } finally {
    // Go to another branch, reset the slot use status
    slots[slotCurrent] = 0;
    }
    }
    }
    }
    private static void printSolution(int[] slots) {
    for (int i = 0; i < slots.length; i++) {
    System.out.print(slots[i] + 1);
    if (i != slots.length - 1) {
    System.out.print(",");
    }
    }
    System.out.println();
    }
    private static boolean checkConnectToStartPoint(int[][] graph, int point, int[] slots) {
    // Get all the points to which this point is connected
    int[] connPoints = graph[point];
    for (int pathPoint = 0; pathPoint < connPoints.length; pathPoint++) {
    if (connPoints[pathPoint] == 1 && pathPoint == slots[0]) {
    return true;
    }
    }
    return false;
    }
    private static boolean checkDup(int point, int[] slots) {
    for (int pathPoint : slots) {
    if (pathPoint == point) {
    return true;
    }
    }
    return false;
    }
    public static void main(String[] args) {
    int[][] graph = new int[][]{
    {0, 1, 1, 0, 1},
    {1, 0, 1, 1, 1},
    {1, 1, 0, 1, 0},
    {0, 1, 1, 0, 1},
    {1, 1, 0, 1, 0}
    };
    int[] slots = new int[graph.length];
    find(graph, slots, 0, 0);
    }
    }

  • @Chintu44
    @Chintu44 Год назад +2

    Father of ADA 🙏

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

    impressive sir,u'll reach heights sir

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

    Best Classes for DAA.

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

    U r truly a great guy sir, respect

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

    Dear Sir, It will be very nice and easy for us to do self study. If you use some Algorithms from CLRS or Sartaj Sahani,to explain the problem.
    We love your tutorials,
    Thank You

    • @numbgaming716
      @numbgaming716 6 лет назад +2

      True..It'd be a great lecture by a 'gem' then!!Simply great

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

    Completing syllabus in corona pandemic... 🗣️🗣️

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

      keep going...build some stuff

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

    Amazing teach Daizuki desuuu

  • @ahmedsoliman4015
    @ahmedsoliman4015 6 лет назад +2

    Amazing explanation, Thank you!

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

    Thanks for teaching very well with smile face .we understand your teaching..if you please say important semester year qns of daa