Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming: Starter: class HW11{ static long numWaysToGroup(int n, int k){

ID: 3764665 • Letter: J

Question

Java Programming:

Starter:

class HW11{
   static long numWaysToGroup(int n, int k){
       //YOUR CODE GOES HERE
   }
  
   public static void main(String[] args){
       System.out.println("Your answer is: " + numWaysToGroup(12, 5));
       System.out.println("Expected answer is: 1379400");
       System.out.println("Your answer is: " + numWaysToGroup(8, 6));
       System.out.println("Expected answer is: 266");
       System.out.println("Your answer is: " + numWaysToGroup(14, 5));
       System.out.println("Expected answer is: 40075035");
       System.out.println("Your answer is: " + numWaysToGroup(29, 5));
       System.out.println("Expected answer is: 1540200411172850701");
       System.out.println("Your answer is: " + numWaysToGroup(11, 11));
       System.out.println("Expected answer is: 1");
       System.out.println("Your answer is: " + numWaysToGroup(12, 6));
       System.out.println("Expected answer is: 1323652");
       System.out.println("Your answer is: " + numWaysToGroup(5, 8));
       System.out.println("Expected answer is: 0");
   }
}

Use dynamic programming to write a Java function numWaysToGroup (int n, that takes as input an integer n and an integer k and returns the number of ways to people into k groups. Each group has between 1 and n people in it. Also, each pers exactly one group. If n 4 and the people are {1,2,3,4} then the groupings are: * Into 4 groups: o 1), 2), (33, (4) * Into 3 groups o 1,2, £3), (4) o 1,3), £2), {4) o 1,4), £2), 13) o 13, 2,3), (4) o (1), 52), 13,4) * Into 2 groups o 1), 12,3,4) o 1,2, 13,4) o (1,3), 12,4) o (1,4), 12,3) o 1,2,4), 13) o 1,3,4),(2) Into 1 group * o 1,2,3,4) So, your function should return: numWaysToGroup (4,4)-1 numWaysToGroup (4,3) 6 numWaysToGroup (4,2)-7 numWaysToGroup (4,1)1 Your function should also return numWaysToGroup (n, k)-0 if n

Explanation / Answer

import java.io.*; class Partition { // Returns true if arr[] can be partitioned in two subsets of // equal sum, otherwise false static boolean findPartition (int arr[], int n) { int sum = 0; int i, j; // Caculcate sun of all elements for (i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote