Question: // Implement sorting method using parameters, index, or array that is given in function. * Suppose some city has n people, and these people need

// Implement sorting method using parameters, index, or array that is given in function.// Implement sorting method using parameters, index, or array that is givenin function. * Suppose some city has n people, and these people

* Suppose some city has n people, and these people need to vote to select a mayor of the city. There are three candidates for a mayor: "A","8" * We are given an array of n Strings where each element represents a vote for either candidate "A" or candidate "B", or candidate "C". * For the purpose of this problem, let's assume there is a clear winner (so one candidate has more votes than the other two). * Design and implement (in Java) an in-place algorithm for sorting this array and determining who wins the election, "A", "B" or "C". * Example: if we are given the following array that represents votes of 11 people: ("A", "B", "A", "C", "A", "A", "A", "B", "C", "A", "B"], your method should return "A" and change the array so that it is sorted: ["A", "A", "A", "A", "A", "A", "B", "B", "B", "C", "C" The algorithm must satisfy the following requirements: . Use the variation of the partition method of quicksort) Should run in linear time - Use no extra memory (except for two integer indices and a tmp variable for swapping). - Run in two passes * Important: Do NOT just iterate over the array and count the number of "A", "B" and "C"s - such solutions will get a points. * DO NOT use counting sort. Instead, this of how you can modify the algorithm you wrote in sortAB. * @param votes input array of votes * @return winner */ public String sortAndFindWinner (String[] votes) { // FILL IN CODE Kotlunin undate available "B" and "C". e some city has n people, and these people need to vote to select a mayor of the city. There are three candidates for a mayor: "A", given an array of n strings where each element represents a vote for either candidate "A" or candidate "B", or candidate "C". e purpose of this problem, let's assume there is a clear winner (so one candidate has more votes than the other two). and implement (in Java) an in-place algorithm for sorting this array and determining who wins the election, "A", "B" or "C". e: if we are given the following array that represents votes of 11 people: ["A", "8", "A", "C", "A", "A", "A", "B", "C", "A", "B"], ur method should return "A" and change the array so that it is sorted: ("A", "A", "A", "A", "A", "A", "B", "B", "B", "C", "C"] Zgoritha must satisfy the following requirements: e variation of the partition method of quicksort) run in linear time extra memory (except for two integer indices and a tmp variable for swapping). two passes ant: Do NOT just iterate over the array and count the number of "A", "B" and "C's - such solutions will get a points. use counting sort. Instead, this of how you can modify the algorithm you wrote in sortAB. votes input array of votes n winner ering sortAndFindWinner (String[] votes) { LL IN CODE * Suppose some city has n people, and these people need to vote to select a mayor of the city. There are three candidates for a mayor: "A","8" * We are given an array of n Strings where each element represents a vote for either candidate "A" or candidate "B", or candidate "C". * For the purpose of this problem, let's assume there is a clear winner (so one candidate has more votes than the other two). * Design and implement (in Java) an in-place algorithm for sorting this array and determining who wins the election, "A", "B" or "C". * Example: if we are given the following array that represents votes of 11 people: ("A", "B", "A", "C", "A", "A", "A", "B", "C", "A", "B"], your method should return "A" and change the array so that it is sorted: ["A", "A", "A", "A", "A", "A", "B", "B", "B", "C", "C" The algorithm must satisfy the following requirements: . Use the variation of the partition method of quicksort) Should run in linear time - Use no extra memory (except for two integer indices and a tmp variable for swapping). - Run in two passes * Important: Do NOT just iterate over the array and count the number of "A", "B" and "C"s - such solutions will get a points. * DO NOT use counting sort. Instead, this of how you can modify the algorithm you wrote in sortAB. * @param votes input array of votes * @return winner */ public String sortAndFindWinner (String[] votes) { // FILL IN CODE Kotlunin undate available "B" and "C". e some city has n people, and these people need to vote to select a mayor of the city. There are three candidates for a mayor: "A", given an array of n strings where each element represents a vote for either candidate "A" or candidate "B", or candidate "C". e purpose of this problem, let's assume there is a clear winner (so one candidate has more votes than the other two). and implement (in Java) an in-place algorithm for sorting this array and determining who wins the election, "A", "B" or "C". e: if we are given the following array that represents votes of 11 people: ["A", "8", "A", "C", "A", "A", "A", "B", "C", "A", "B"], ur method should return "A" and change the array so that it is sorted: ("A", "A", "A", "A", "A", "A", "B", "B", "B", "C", "C"] Zgoritha must satisfy the following requirements: e variation of the partition method of quicksort) run in linear time extra memory (except for two integer indices and a tmp variable for swapping). two passes ant: Do NOT just iterate over the array and count the number of "A", "B" and "C's - such solutions will get a points. use counting sort. Instead, this of how you can modify the algorithm you wrote in sortAB. votes input array of votes n winner ering sortAndFindWinner (String[] votes) { LL IN CODE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!