Question3Max. score: 4.00Alice, Bob, Ben, and some of their friends participated in a competition. They were standing in line to take the participation ticket. Each person was given a unique ticket value which has a rating. You need to implement a code to form a team of 3 friends amongst them under the given rules:Select 3 friends with index(a,b,c) with ticket value(ticket[a], ticket[b], ticket[c].Team is valid only if(ticket[a] < ticket[b] < ticket [c] OR ticket[a] > ticket[b] > ticket [c] where,(0<=a<=b<=c<=n) (n=number of students participated)Complete the below pseudocode:Pseudocode:Function numTeams{Input int ticket, int Result = 0;for(int mid = 1; mid< ticket.length -1;mid++){int left=0;int right =0;int upperleft=0;int upperright =0;for(int b=0;b<ticket.length;b++) { if(b<mid and ticket[b]< ticket[mid]){ left+=1; } else if(b>mid and ticket[b] > ticket[mid]) { right+=1; } //code line 18 { upperleft+=1; } else if(b>mid and ticket[b] < ticket[mid]) { upperright+=1; }}Result+= left * right;//code line 28}return Result;}What will be the code in place of lines 18 and 28?Options:else if(b>mid and ticket[b]> ticket[mid]) //line 18Result+= upperleft+ upperleft* upperright; //line 28else if(b<ticket[mid] and ticket[b]< ticket[mid]) //line 18Result+= upperleft + upperright * upperleft; //line 28else if(b<mid and ticket[b]< ticket[mid]) //line 18Result+= upperleft + upperright; //line 28else if(b<mid and ticket[b]> ticket[mid]) //line 18Result+= upperleft * upperright; //line 281234
Question
Question3Max. score: 4.00Alice, Bob, Ben, and some of their friends participated in a competition. They were standing in line to take the participation ticket. Each person was given a unique ticket value which has a rating. You need to implement a code to form a team of 3 friends amongst them under the given rules:Select 3 friends with index(a,b,c) with ticket value(ticket[a], ticket[b], ticket[c].Team is valid only if(ticket[a] < ticket[b] < ticket [c] OR ticket[a] > ticket[b] > ticket [c] where,(0<=a<=b<=c<=n) (n=number of students participated)Complete the below pseudocode:Pseudocode:Function numTeams{Input int ticket, int Result = 0;for(int mid = 1; mid< ticket.length -1;mid++){int left=0;int right =0;int upperleft=0;int upperright =0;for(int b=0;b<ticket.length;b++) { if(b<mid and ticket[b]< ticket[mid]){ left+=1; } else if(b>mid and ticket[b] > ticket[mid]) { right+=1; } //code line 18 { upperleft+=1; } else if(b>mid and ticket[b] < ticket[mid]) { upperright+=1; }}Result+= left * right;//code line 28}return Result;}What will be the code in place of lines 18 and 28?Options:else if(b>mid and ticket[b]> ticket[mid]) //line 18Result+= upperleft+ upperleft* upperright; //line 28else if(b<ticket[mid] and ticket[b]< ticket[mid]) //line 18Result+= upperleft + upperright * upperleft; //line 28else if(b<mid and ticket[b]< ticket[mid]) //line 18Result+= upperleft + upperright; //line 28else if(b<mid and ticket[b]> ticket[mid]) //line 18Result+= upperleft * upperright; //line 281234
Solution
The code in place of line 18 should be:
else if(b>mid and ticket[b]> ticket[mid])
And the code in place of line 28 should be:
Result+= upperleft+ upperleft* upperright;
Similar Questions
Sports Craft Company has organized tournaments in multiple individual sports and invited top ranked players to play. Each tournament comprises of multiple matches in knock out format. Each match is played between two players.Problem Statement: Create the Player table as per information provided below:Column Name Data Type Constraint DescriptionPId INTEGER PRIMARY KEY Unique player Id is mandatory for every playerPName VARCHAR2(20) NOT NULL Player NameRanking INTEGER Player's ranking
Tickets for an event are allocated randomly from those who apply. For each of three events 1,000 apply for 500 tickets. 16 friends each apply separately for each of the three events.Question 20What is the expected number of the 16 friends who will get tickets for all three events?1234
Four friends, A, B, C and D got the top four ranks in a competitive examination, but A did not get the first, B did not get the second, C did not get the third, and D did not get the fourth rank. Neither A nor D were among the first 2. Who secured the third rank?
A contest is open to teams of 10 people each.Let t represent the number of teams entering the contest and p represent the total number of people.This relationship can also be shown in a table. Complete the equation that represents the relationship between t and p.t p1 102 203 304 40p=
From a group of 9 people, select the best 3 players to represent the group to participate in the team competition. How many total possibilities are there?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.