This video provides a comprehensive one-shot revision of all 12 ADA Lab programs for VTU BCSL404 (Algorithm Design and Analysis) under the VTU 2022 Scheme, covering key algorithms including Kruskal's and Prim's for Minimum Spanning Tree, Floyd's and Warshall's for all-pairs shortest paths and transitive closure, Dijkstra's for single-source shortest paths, topological sort for DAGs, 0/1 Knapsack and discrete knapsack using dynamic programming, sum of subset problem, selection sort, quick sort, merge sort, and the N-Queens problem, with step-by-step explanations and complete C++ programs for each algorithm.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
ADA Lab BCSL404 One Shot | All 12 Programs + Viva | Clear Lab Exam in One Video!
Added:Hi hello everyone welcome back to my YouTube channel as I had said I was not able to upload this video yesterday I had said I'll be uploading this video by 16th or 17th maximum but I'm uploading it today on 17th I'm very sorry for it if you have completed your examination yesterday I'm really sorry and if you have tomorrow or day after tomorrow and many of the comments which I got in the Instagram posted stories about the 28th so I'm pulling it and many of you had it on 18th as well and I wish you all the very best for your examination and let's start this video. this video how it will be mean first easily I'll be explaining like the concept which you have to know in the algorithms and next also the problem which you have like easily as it is a one shot I'll be making it very like short and uh you can easily score so that um uh even the problems will be clear even the programs will be clear let's start the first uh program that is Chrisll's algorithm I had uh let's start the video without further wasting time if you're watching my channel without subscribing. Make sure to subscribe and then watch the video. Let's start the first. The first is about the Kriskll's algorithm. Kriskll's algorithm is nothing but you have to find the minimum spanning tree that can be defined as as it is a one short video. I'll be explaining it very quickly just I'll be not repeating the concepts or anything just it will be a quick revision type so that easily you can score and easily you can get the output. Okay, first let's see first what is minimum span entry. It is defined as nothing but the spanning tree in which the sum of weights is minimum weight is should be minimum.
That is called as what?
Minimum spanning tree. Okay.
If you want the same PDF, please do me on Instagram. My Instagram account is SP O R I F_s.
And next algorithm algorithm is nothing.
See first let's see when you have to take a minimum spanning tree which I said you have to have a connected graph okay connected graph maybe you have this graph if you want to find minimum spanning tree you take it as U and V okay when you take it as U and V first take the graph 1 2 3 4 5 6 7 and all it's there right and now you can take it as 1 2 okay you can pair it you can take U and pair it and next you can combine it with three that is next minimum spanning and next you can combine it with four Five and six and seven you can combine and you take the minimum span tree 1 2 3 3 4 4 if you add you'll be getting the 17. Now I'll be explaining the code also. See here you will be taking input output and next edge and the minimum cost will be declared in void main ind this and all I had done actually this video so I'm going very fast and you will take the number of vertices which you have and next you will scan that that is when you take the input you have to scan okay next you'll be entering the cost matrix next for I for J scan you do cost of I as it is you can see here cost is already I okay next is for J and parent of I is equals to Z and next is spanning minimum spanning that you'll be printing the edges while any that is next is less than number of vertices minimum will be that when you write the infinity symbol it is called as 999 for I for J that is if cost is I less than min= to cost of I of J A= to I b= to= to J and then X is Y of parent of U is equals to parent of U of parent of V again it is same V is equals to parent of V if U is not equal to V means if this edge is not equal to this edge you'll be printing the edge okay that is in the form of percentage to percentage B to B and you'll be printing ND that is next edge plus that means plus means next stage you'll be going AB the value and minimum value next you'll be declaring like converting minimum cost is equals to min cost plus min okay that you'll be adding so parent of v is equals to cost of a which I declared will be a is equals to 999 sorry it should UPA and next is if you print here you'll be getting the answer. Okay, I hope you are clear with this and um this is about the crystals algorithm. I hope you have got this. If you have any of the doubts please do let me know in the comment box. And next we'll be moving on to the prim algorithm also which is also the easiest of all just you need to know it's about the just the change okay that you need okay yeah this is nothing but uh this is a greedy algorithm that you have and this also minimize no cycle should be from there In crystals one cycle can formed like full cycle but here it should not be formed. Again the same minimum spine clone you get but there you got it as 1 3 3 4 for some value right here you'll be considering the minimumist value and next you'll be seeing that it should not find out the no cycle should be found.
Okay see 1 2 you can do and 2 3 and again if you do 2 4 it will be forming a full cycle. So you should not take then you can take 1 four. Okay 1 4 and next you can take four five. This will not form. You can have not taken two five right only this three you have taken.
And next you can take four and seven and see 1 2 is visited three is visited four is visited five is visited six is not visited. So you can take six and seven because in five and six and six and seven this is the minimum value. So you'll be taking and if you like you'll be getting the value as 17. Okay. In this also it is almost same. See just input output and next general you'll be saying here you will be taking just the visited visited of 10 is equals to zero min cost is equals to zero and cost of 10 okay that means it will be declaring in the 2D array in number of nodes we'll be having scan f and next agency matrix we'll be printing for i for z and next what we'll be doing scan f if cost is equals to zero means that is 999 we'll be printing it as infinity that is infinity is set to be 999 and cost of visit like when vis visited of 1 is equals to 1. If you have visited it will be printed as one. And next next line while n is less than again for i for z if cost of i of j is less than the minimum number. If and cost of like visited of i is equals to not equals to z. Here we said it is equals to 1. Now it is not equal to Zing and U= and next of= 0= to Z. Next is percent plus again cost plus and again B of cost of A of B= the cost will be printing that's all the program here. Okay. This is about the prim algorithm. I hope you have got.
Next, let's discuss about the third problem also that is program. Program three contains 3A and 3B program. This is having Floyd's algorithm and this will be having warshell algorithm. Okay, I'll be explaining as I explained program 1 3 the numerical what you have to understand the concept everything will be explained. Please do watch the full video in order to understand these two programs. If you see this one video, you'll be understanding both the programs of 3A, 3B and even I'll be explaining program 4 dtras also here only.
And uh let's start without further wasting time. First I'll explain the concept [snorts] that you have to understand then I'll explain the code how it works. See first if you take as all are saying me that you have to explain in Canada as well as English.
I'll try to do both uh like a little I'll explain in Canada and a bit in English. I'll try to implement both from now on. Okay. Now see if you consider consider 1 2 3 four and vertices three the nodes there next to graph sorry graph nodes there. These are the graph nodes which you are considering and the distance between them are being given 15 15 50 35 and 5. And I hope you know to write this transition matrix that is uh from 1 2 3 and 4. Here also 1 2 3 and 4.
The distance between 1 to 1 and um here it should be zero.
Sorry. Uh 1 to 1 is zero because there is no distance that has been given from the distance from its self to self is always zero. from 2 to 2 it will be always zero and 1 to 2 1 to 2 distance and 1 to 3 so you'll be writing infinity if there is no connection you'll be writing infinity if it's there you'll be writing the values which is there okay now what you have to do here is the minimum distance find out through all the particular nodes through first, second, third and fourth node.
Next minimum distance through node one, node two, node three and node four. You have to calculate all the distances minimum distances from all the each nodes through like you have to visit through that. Okay, if you take one, you have to visit through one from anywhere.
Okay, that is how does this works. Okay, let's start. I will uh [clears throat] explain everything in detail. See here first if you take node one, what it will be changing is see if you take 1 to 1, obviously this diagonal will be zero because the from itself to itself is zero. Okay. Now if you take 3 to 1, 1 to 2 is what? 30 + 5 30 and 5 is 35. Okay.
4 to 1 and 1 to 2 is how much? 15 and five again. Okay. But 3 to2.
Okay. This was about the 1 through 1 through node one. You have to start from any other node. It should pass through one and it should end at the end.
Okay. Next five.
Next again the same value 2 1 2 1 50 2 3 3 1 2 3 3 1 15 30 that is 45 but 50 45 is less than 50. So you have to consider 45 next 2 to 4 to 1 to 1 2 to 4.
Okay. Now next to 2 to 4 4 to 3 2 4 4 to 3 5 + 5 but 2 to 3 value 2 to 3 previously 15. Okay this you will be replacing it with 10. Okay.
You have to replace. What I'm trying to say here is if you you have to check through all the nodes through 1 2 3 and four. Each nodes you have to check 1 2 3 uh you need not check the diagonal the rest all nodes you have to be checking.
If you get the minimum value you have to consider that else go with the uh what is the value which is being there already. This was all about the Floyd's algorithm. How you apply is also same but instead of this you'll be just using zeros and ones whether the direction is present or not. Okay. [clears throat] Now let's explain the program as you know standard input output and you'll be using the limits here that is you'll be defining the four like you will be uh when you're giving the matrix four anything limit you can give 40 anything you can give and you'll be calling the function as Floyd version of int graph of v that is 2D array you'll be and distance also you'll be calling and next is for int i is equal to z i less than v i ++ plus because what the value you give it should be less than V because you have defined maximum of V as what V right V4 it should be less than that so you'll be using that and four rows and four columns that is how you define here and next again for loop you'll be using I J and you'll be assigning distance as graph of I J and next what you will be doing for K again I J what you will be doing if I K is not equal to in max. Int max value it is infinity and KJ is not equal to infinity and I plus K is less than I value 30 35 it is 65 is less than 70 condition of I that is distance of I will be replaced with this value because minimum value you'll be considering that is how you take here and you'll give the print f statement shortest distances again you'll have for loop that is distance of I infinity I if it is infinity how to do you'll be printing it as infinity / t that is in the next tab you'll be using / t for the next tab next 0 infinity 3 infinity 2 0 infinity infinity infinity 7 0 1 6 infinity infinity 0 Floyd graph because function name Floyd main function again it will be closing. This is how Floyd algorithm works. I hope you have understood. If you have any doubts, do let me know in the comment box. If you're watching my channel without subscribing, make sure to subscribe and then watch the video. Now, let's discuss the Warshall's algorithm which is also very important. Again, as I said, it is also similar and same as Floyd's algorithm, the numerical which I have explained. Just here instead of four nodes, I have changed it as XY Z and WXY Z. Okay. You see here they have not given the distance value.
distance.
So y to x x y z w x y z w y to x y. So next Y2 Y X2 W1 but W2 X W I hope you have understood. Next again because W to W through Z. Okay. W to W through Z. Okay. W to Z to W.
So one that is how you can change here. I have explained everything in detail. Uh you can go through this. Okay. If you have any doubts in what I have explained, I have explained just a bit because all everything is same as Floyd's again. Uh just the one and zeros will be there. If it is present, it is one. If it is absent, if it is zero. Okay, I hope you can see this last answer. Please do put this graph and you work it out basically and you will get the answer.
number of next of mat matrix matrix mat of ial for I hope you remember. Okay. Next.
I 1 K because I K 1 K 1 I.
Okay. Now that is how you are saying here. And next enter the number of scan and agency matrix for scan because it should print all the values.
Next path matrix mat when it is updating through node node x w y and zency matrix the first matrix which you'll be having. Okay matrix the first matrix this we have taken and path matrix is the last which we have got by tracing. Okay, this is the path matrix. I hope you got this.
Even we'll be discussing the dystraas algorithms also in this video only without further wasting time. See this is dystraas algorithms. I'll be explaining first the uh required numerical here. It it is very easy just you have to find out the minimum distance between the graph which has been given A B C D E they have given see A to B they have given six right but A to B you can find it out by A to D and D to B okay sorry A to D to B that is 1 and 2 will give you what three and A to D will be what a to D will be 1 and A to D to E will be what two Okay. Next to A to B.
Next to A to D, D to E, E to C. Next, I to 1 1 and 5 that is seven. Next to A to D, D to E, E to B that is 1 1 and 2 1 1 and 2. Four I A to D, D to B, B to C. A to D 1 2 M two and sorry A to D to B to C. Okay. Now 5 6 7 8 I 1 to 5. Okay.
Now this is how you find out each value.
A to B 3 A to C A to E 2 A to A to B C D. Okay. D find out one minimum distance E B C D E find out 3 721 okay now that is how the find you find out the value okay again the output will be as it is now uh after explain program I'll say see first you will be having input output integer seeu void new first you have to keep track about that. See next in 2020 number of visit of 20.
Okay.
Next number of vertices that cost. This is the matrix as you know 2D. Next source.
This is the source node. Okay.
That is the source node and you will be taking the input and next to source cost visit print I for loop I not equal to source I not equal to source that means we will only find distance from all but not source distance from A to A B C D E that is this line meaning okay you'll be printing Right that is percentage D to D is percent D source I D of I that is source I the value of that and the agency matrix value of that you will be printing distance of that next again in source next distance.
Next for J equals to 2 and you have incremented J by 1 minimum is equal to 999 infinity value I1 value not equal to visited of I visited of I not equal distance of I is minimum less than minimum minimum D of I replace U will be equal to I next visited of U is equals to 1. Okay.
U next to cost of UW is not equal to 999.
Okay. That means it should value and wal you'll replace that is you will swap swap function okay now you'll swap this by this if it is greater that is how this algorithms work I hope I am clear first I'll be explaining again in English As I've explained full in Canada first you have to see uh node uh sorry uh here you'll be declaring and you'll be having visted and source source will be through what node you are selecting and you'll print this and all I have I hope you have got mainly explain here see here for I you will take visited will be zero and distance will be see here distance will be cost of source of I and again you will declare it as 1 and zero for J you will increment by one J will incremented by one. Minimum will be 999 means it is infinity and you will take in for loop if it uh it is not equal to visited of i. What you will do? D of i is minimum less than minimum. If it is less than minimum you'll replace the value of minimum as d of i and u will be i. Okay.
Again what you will do instead of u will be 1 and w you will take for loop u u sorry uw is not equal to 999. That means it should have some value that means it's not infinity and w will be equal to zero. If these both satisfies what you have to check d of w distance of w if it is greater than cost of u w and u okay if you add these both if it is greater you will replace this value by this okay that's it d of w will be equal to again this that's all about the destras algorithms let's continue with the fifth program as I said I'll be just explaining the concepts that is required and basically see first if you have in topological sort 1 2 3 4 5 is given. In topological sort, it's nothing but you will be deleting the incoming node with its outgoing node. If it has incoming node, if it don't has like you should see first it has incoming node or not.
It should have any incoming nodes. Okay, you should delete that node with the outgoing node. Okay, that is the basic idea here. You will follow first. See one doesn't have any incoming node. So you delete this with the outgoing node.
So it became just 2 3 4 5. Again delete two and three the out node and again 3 4 5 and again last will be remaining with four to five and again you'll be deleting and this is the order of sequence okay that you'll be getting this you can explain for the uh like if they ask and next you can see is about the program let's explain if we see the program here see first they have given the input output as usual just you'll be taking and next this is finding degree for finding the degree you'll be taking the in first is 2D array 3D 1D array and int integer and next we'll be like declaring topological like you have to print the order of sequence of which is printed right next we'll be taking void mean and next we'll be declaring this number of nodes you'll be entering number of nodes and next you'll be entering the scanf that is you have entered print a rate that you should scan okay next again the agency matrix agency matrix if you want again it is matrix so it is should have either columns and rows so you have I and J that is for rows and columns and then you'll be scanning that. Next the agency matrices you'll be printing that with the percentage t of I of J that is 2D array and next you'll be giving as topological of n comma a n comma a is nothing but the number of nodes and the agency matrix which you will be giving that is called as n and a that you will be printing and next we will see it's about the find and degree again you'll be declaring here what you have declared again you'll be taking the same I sum i j sum you'll be taking for row column and the sum you'll be taking next for J sum is equals to Z for J again sum is equals to sum plus A of I that is the adency matrix you should add right then you'll be taking that and next what is the idea it's nothing but the ad matrix that is I it's nothing but the loop variables and N is number of nodes right next you'll be taking in degree of sum like J is equals to sum and next we'll be doing void topological of inn in of i of 10 10 and next k top t of 100 and stack and You'll be declaring K first you'll be initialize it as one and top as minus one because it is a stack and next what you'll be doing find degree of a in degree comma n okay next for I what you'll be doing if n in degree is equals to zero you'll be inserting it as stop okay if it is not equal to minus one then you'll be decreasing that is stop minus minus post decrement you'll be doing next t of k++ is equals to u you'll be giving and for v if they are both are equal that is u v is equal equals to 1. If it is there, you'll be doing V of minus minus. And if integrity of V is equals to is equals to 0 means that is stock that is stack plus that is pre-increment is equals to V then you'll be printing the topological sequence for I and then you'll give the T of I that is you have taken T right and starting you can see sorry yes one second. Yeah, here you have taken t of 100, right? So you have just initialized the size and that you have to print as what are the uh numbers that is order you are getting how the output will be means first it will ask for the number of nodes you will enter something as five okay for the given examples and then you'll enter the agency matrix it will print the ad agency matrix and then it will say the topological sequence is 1 2 3 4 5 this is the output that you'll be getting I hope you understood okay next let's see the sixth that is the 01 knapsack problem using dynamic programming. First you take the maximum size y and all this I have explained in the like you have know about the theory also I hope this I'll be not explaining that is when you have weights and all you have to compare and this you'll be getting the optimal solution as what eight so you will be getting output as eight see first input output again and next we'll be taking max 50 and p of max w of max and n okay naps of int i in m you will be taking and m it's nothing but the maximum capacity and I it's nothing but the optimal that is object which you will be taking next you'll be taking the optimal solution number of objects and you'll scan that next is enter the weights and you'll scan that for I okay next the profits for I you'll scan that napsack capacity you'll scan that next is for optimal solution you should give napsack of n minus one that is the number of objects how much you enter that minus one and the maximum capacity now the optimal solution will be this you will be printing written zero next what you'll be doing int napsack of int i in m if i is less than zero and W of I is greater than M that is maximum written napsack of I - 1 M and next is written max of napseack of I - 1 M this again and next is J minus1 and Mus W of I + P of A and again E A B if you take that is written A greater than B that is turnary operator you'll be using question mark A is to B I hope you know this and all I don't have like you don't have time to read that and all just you try to recall the concepts that you know about the NAVSAC and just try to write. Okay, how you will be writing is first the program when you start you should be knowing first what you'll be declaring then what three you have to write and then you'll write in main and what you have to declare here you'll be declaring next is objects weights and the profits then you'll be printing the napsa capacity then you'll be writing the optimal solution that means 80% of your code is done next obviously you'll be taking what uh you have taken all means then you have to print right next what is the capacity that you need only it's the main next you'll be taking the capacity and then you'll be printing this maximum value of that. Okay. Next it's about the discrete napsack. I have given the C++ program. Okay. First is about the input output stream vector and algorithm name space std and strct weight that you'll be declaring as a structure to represent the item. Next is discrete mapsack of vector item items in capacity you'll be taking and again it is begin end and for const item A const item and B. Okay. And I'm% you'll be using in order to address that. Okay. See guys, I could have explained still in a better way because uh like if I go deeper, you'll be able to understand. But uh most of you had commented that you have on 18th right.
So if you have tomorrow the exams, you'll be not having much time to read.
So I'm going a bit fast. So please do catch up at then you can easily learn.
No need to worry at all. And um next you can see here is about the in total value current weight. And next is for const item and items is two item current weight will be plus item dot weight less than or equal to capacity.
And next is about the current weight plus is equals to item dot weight. And next is total value plus item dot value.
And next is what is the total value you have got last. You'll be printing that returning. And next again for continue snapsack also you'll be taking the same almost one line just it changes and next you'll be having here else okay that is the one change you'll be having again it in the in main you'll be having number of items here see c see out that is for print f you'll be having out for scan f you'll be having c in that is input and output okay that only change and you'll be having number of items that is uh next is capacity of napsack and next is item value, weight and value for each item and next is for J and next you'll be adding item item see out what will be item and item dot weight and value you'll be printing next you'll be pushing back that to the item and discrete result that is equals to discrete napsack of item comma capacity you'll be printing and again if you want the discrete napsack and continuous knapsack separately you'll be printing that in the C out okay that is the output function that is print f it will be printed next This is easy about the sum of subset. This is also much easier than all questions. But you may feel that it is difficult. But there is nothing here. See first what you have is see here you can see first input output again you'll be taking but in subset you'll be taking it as sum sum sum. Okay that is int int int. Y you'll be taking it as int int int. You have to have the count and uh next what are the elements that you enter and what is the ascending order of that. Right? So you'll be taking it as three times. And next we'll be taking X because that is nothing but the array to track the element to be included in the subset. Next what is W?
Means it is the array that you will be taking into store the input to like up to 10 elements that you have taken 10 10 size. Next is D comma count is equals to zero. You'll be having because to keep track of the subset vidman in sum is equals to zero. number of elements you'll be printing and scan f and in the ascending order again it is for I and next is scan f enter the sum scan f you'll be doing for i again what will be sum sum will be sum plus that is w of j okay what is w of i you'll be adding and next is enter the sum you'll be doing again after the sum is equals to if you will check whether sum is less than d the given number okay d it's nothing By the target sum which you have whether it is less or greater you'll be doing if it is less you'll be having no solution return if it is greater then what you'll be doing 0 0 sum you'll be taking here you to write in int int okay count is equals to zero also it is no solution and return then what you'll be doing subset if it is there what you'll be doing here is int cs int k int r you'll be taking int cs okay that is current sum you'll be taking int k that is index you'll be printing and next is r it's nothing But the remaining sum which you have and int i and x of k is equal to and then you'll be printing the subset for i and if it is one you'll be printing again if it is not you'll be printing the current sum plus weight of like one element plus another element if it is less than or equal to d again it is subset and you'll be printing the values and next you'll give current sum k + 1 and r minus w of k okay that is this x of k is equals to zero because not including like you should not include and this r minus w of ky you gave means remaining elements to be included what you have left out that should be included right so you gave that next is about the selection sort see guys most of the function which comes in the sorting techniques is very simple and it's repeated of all okay just I'll be saying in one and next I'll be saying what are the changes okay see again it is input output and library and time you'll be taking because you have to print how many how much time it took okay selection sort what you'll be doing int array n you'll be taking and i j and min minimum index temperature temporary variable and next you'll be taking for i and min index is equals to sorry yeah one second min index is equals to i you'll be taking for j next if array of j is less than array of min index what you'll be doing min index is equals to j here you took for min index what it should be i red for i okay In index of J it should be means for J you should take again you should check whether it is less than J or not that is minimum index then you'll be doing that next here it is the swap variable that is found and temp is equals to ar of min index array of this is equals to ar of I array of i is equals to temp next this is the main function that is same for all that is generate number you'll be doing some random number percentage 1,000 int main set value to 6,000 You'll be doing for allocating the memory int star array that is pointing to array in star maloc that is um memory allocation n into size of in how much size it's there you'll be printing that and next what you'll be doing yes rand that is the number of if it is null and random numbers you'll be printing by using n because you have taken here is n right and next you'll be doing for j and ar of i is equals to generate random number the function name which you have taken and next we'll be doing percentage d ar of five and next in the next line and next clock t start clock t end should be there. This is clock under t start clock under t. Okay, this will be clock and it is selection s. So you should take array of n or a comma n. Clock t end will be clock and double time taken will be double end that is end and minus start which you took clocks per second how much per second it took. Next we'll be taking time sorted and n that is how many number is there and the time taken.
And next you'll be giving a sorted index that is numbers which you have and you'll be giving the n value. And next for j what you'll be printing array of j and uh next line you'll be moving on free of array for the next program that is you'll be allocating dynamically free the memory and return zero. And that's all for this program. Okay in quickshot what you'll be changing I'll be saying easily. Okay that is first and all it's same. See here you will be using star A star B that is pointing and int a is equals to in temp is equals to star A star A is equals to star B this star B is equals to temp okay this is the swap variable in this you'll be using partition okay I hope you know the concept of quick swap and all I'm not going to say again and again because you already know this concept so what you'll be doing here is just you'll be taking the partition array low high and pi is equals to array of low and J is equals to low plus high I is equals to low + 1 and J is equals to high.
While of 1 if it is I less than or equal to high and I of less than or equal to what? I ++ while ar of J is less greater than what J minus minus. If I is less than J swap of amp% ar of I and amp% ar of J else break. Next is swap of amp percent of low and array of J written J. You'll be doing for a quick sort you'll be checking whether low is less than high p index is equals to partition of array low high and quick sort is array low pivot index minus one and here it is p index + one and high.
Okay, here it is low, here it is high.
Next again it is the same main function.
You can see this next merge out again it is the first you'll be taking that is what merge of that is array L M R okay I JK you'll be declaring for loop variables N1 and N2 this formula if you know that is MUS L + 1 N2 is equ= to R - M and this will be array you'll be declaring for array temporary arrays and this also I JK is equals to 0 0 1 and next will be L giving and Next while I is less than or equal to that is N1 and J is less than you will be adding it as ar of K is equals to L of I this will be R of J. While I is less than N1, you'll be declaring it as array of K is equals to LI. And again it is I ++ and K+. post decrement you'll be doing and J is less than N2 and you'll be giving it as array of K is equals to R of J and again you'll be including and next is merge sort of array L M and array M + 1 R and array of L M R okay next is again the main function is almost same okay again you can see this next is about the queens queens is nothing but input output Again you'll be taking define n4 how many boards is there means n4 you'll be taking and again int bold of n is equals to zero first you'll be declaring it as zero right that you'll be taking and then what you'll be doing next is about the print solution you have to print the solution which you have got right I hope you know but I'll be not explaining in detail this see four if you have here you can fill here it should not it should not be in column it should not be in row or it should not be as diagonal.
Okay. Next for I for J percentage D board of I of J you'll be printing next line you'll be printing. Next is is safe int row int call I j you'll be printing for i for next what you'll be doing row of i board of row of i how much row of i you'll be printing written zero for i is equals to row j is equals to column I greater than or equal to0 and j greater than or equal to z you'll be decrementing one and you'll be printing both the boards and return zero whether to check whether next you can insert here you can insert here you can insert all the rows and columns you'll be checking in this both the rows and columns. Okay. [snorts] Next is about the again it is same. You should check for I is J is less than N. Here it is.
Next you'll be printing if this means 0 and one you'll be returning. Next is about the int q util of int column you'll be taking if column is greater than or equal to n written one for int i is equals to z i less than n i ++ is safe of i, call board of i of call is equals to 1. uh NQ util of call + one return one board of I of call is equals to zero return zero NQ you'll be taking if it is zero you'll be giving it a solution doesn't exist and you'll be returning that as zero only if next is print solution and return one it will be there next in main function you'll be giving the function name which you give and starting here it is NQ solve NQ and return zero that's all about this NQ that is queen problem also it is easiest of all you can easily study no need to worry at all.
And uh that's all I wanted to say. I hope I have covered everything which I had to say. And if you want the same PDF, please do DM me on Instagram. My Instagram account is Spotify learn. And I'll be trying to reply each one of you also. And thank you for watching the video. Make sure to like, share, comment, and subscribe to my YouTube channel if you feel my content is helpful for you. And I hope I have uh done almost this um uh almost covered. And um I'll be now updating the viva questions that I'll be not saying in the voice just the uh pictures of it will be coming you can see this. Okay. And thank you for watching the video. Make sure to like, share, comment and subscribe my YouTube channel. Until next video.
Bye-bye.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23