Hello friends today we will see how a tennis tournament problem can be solved using the divide and conquer strategy what is meant by a tennis tournament problem that is if I have many players who are participating in the tennis tournament then we are supposed to develop a strategy approach so that we can find out which player will be playing with other player and if I have selected random and number of players then we decide that who will play against the other player and what will be the winner strategy this is just a programming approach which finds out the number of players on the random basis from the list that it has and then predicts the winner and gives you a list of the total matches played the winner of those matches and in the end the winner of the to do that is what it is known as the tennis tournament problem divide and conquer application for this is just a strategic approach to tell that these are the kind of problems from the real world that can be implemented and solved using recursion and divide and conquer we start with the program it is a simple C program so we have the various header files here that is stdio dot h on your dot h and standard library with a head of files bidam is a name of a function which predicts the winner using the strategy it takes the array size the integer variable and the size on which we’re going to find out the winner we have declared simple variables win 1 w1 w2 and made as this tennis tournament problem is a strategic approach implementation of divide and conquer so any divide and conquer problem will always have a variable called mid because it signifies that I am going to divide my ArrayList into two parts by finding the middle of the re so and w1 and w2 taken as two variable names which will tell the two winners from each thing if I have paid then there will be various when I so how do I defend the winner so we’ve taken it as a name of w1 and w2 if in my egg if n minus X is greater than 2 then we continue in the loop that is there more than two players so we can find out that who is the winner and this function can be randomly walked on and it can be implemented using divide and conquer strategy we find out the mid by using the simple mid function X plus n by 2 the first tournament the last element by 2 W 1 is equal to Y naught P X so whatever is the value of my mid it is recursively passed over here to the winner and the first winner is calculated or it is predicted from this particular working module again the second winner has to be predicted because if there are more than two players I cannot decide directly who is the winner so depending on the number of players in my list or the number of players that have enrolled for this tournament that is when I enter the number of players it will be divided into the qualifying law the semifinals semifinals and the final so for every league all from every array that I subdivide my list in – I’ve been having winners from each list that is the way I need to minus w1 and w2 it follows the normal divide ins the conquer strategy so I have made and I have made mine mid plus one now what happens if W 1 is less than W 2 that is if a is 1 or loss commands depending on the number then we say the winner between the two is w1 w2 and the winner is w2 and we return w2 if w2 has 1 then we return w2 else what happens else we say the winner between the two players name if I have player 1 and 2 then I say the winner between player 1 and 2 is player 1 that is if w1 has one otherwise the winner between 1 & 2 if two players were there and w1 was less than double to get up to 2 has won the match here this particular loop closes now starts my main program from where I have called this particular function of Y not known is a simple program which says again the pain function int i which is a loop variable well is a name of a simple manner and is the player that I need to enter and Pisa array which will hold which can hold the name and the ranking of 100 place under the number of players that is I need to enter that in this particular tennis tournament how many players are going to play and that I’m going to scan with a variable and after I have scanned I vary my loop from zero to less than n and then an increment and now how do I choose my place I choose my player by choosing the random function that is why we have used in the beginning and STD libous file rank is a function which works on it random function will generate the random numbers of players that are going to play since there are eight players so a two random numbers will be generated which are going to have a match between each and then the result will be declared winner will be saved in wind that is what will then do whatever is the function wind is returning bananas returning that is whether it was written w-2 or return w1 that we have seen that will be saved in the variable wind and then the winner is wind value will be printed how does the result work on let’s see this was a programming code how when I actually execute this code how does it actually work enter the number of players I am entered at us eight these are the random players which are generated I have P of hundred so any number between one two hundred random numbers will be generated so player one to play rate I have this particular list here it is with the numbers so when I do it with the numbers randomly they will be judged and I have the winner between 38 and 46 the spot reset between 20 and 55 the winners 20 and between 46 and 20 again the winner is 20 now how does 46 in 20 come into picture that is Benna between 38 and 46 is 46 so that becomes w1 we now between 20 and 50 files 20 so for the next session or the next match 46 and 20 play so 20 becomes the first one then the winner between [Music] the winner between 53 and 55 is 55 the winner between 46 and 12 is 46 so here the two winners 55 and 46 so between 55 and 46 the winner is 55 and the winner between twenty and fifty five is twenty and the final winner is twenty so this is how my continuous loop will be working so what happens is the winner is in the end taken and Pickler thank you

Tagged : # # # # # # # # # # # # # # # #

3 thoughts on “Problem Based on Tennis Tournament – Divide and Conquer – Analysis of Algorithm”

1. Ajit Kumar says:

mam hmko som ka moment of inertia ka video upload kar the please

2. glenn mark abalos says:

i love the background music! ahahaha

3. Ekeeda says:

Hello Friends,

Watch Complete Video Series of Subject Analysis of Algorithm only on Ekeeda Application.

Use Coupon Code "NEWUSER" and access any one Subject free for 3 days!