Question: i need it in java Given the following problem: You have a row of 2n balls of two colors, n black and n white. You

i need it in java
Given the following problem: You have a row of 2n balls of two colors, n black and n white. You want to get all the black balls to the right-hand end, and all the white balls to the left-hand end. The only moves you are allowed to make are those that interchange the positions of two neighboring balls. 1. Design an algorithm for solving this problem 2. Analyze the time efficiency of your algorithm 3. Implement your algorithm in either C++, Java, or Python programming language, to determine the number of moves it takes 4. Your program should accept input from the user a string of equal number of B's and W's letters, where B represents black ball and W represents white ball 5. The output of the program is the final arrangement of the balls and the number of moves
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
