Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below code is the implement for method 2 & 3. Please implement the method 1 & 4. Please make adjustments if necessary. Thanks. import java.util.Random;

image text in transcribed

Below code is the implement for method 2 & 3. Please implement the method 1 & 4. Please make adjustments if necessary. Thanks.

import java.util.Random; import java.util.Scanner; public class AvgNum { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter the Number of Candiadtes:"); int size=sc.nextInt(); AvgNum obj=new AvgNum(size); obj.GenerateRanks(size); obj.FindPermutaion(size); sc.close(); } int array[]; AvgNum(int size) { array=new int[size]; } public void GenerateRanks(int size) { int rank; long sum=0,Average; Random rand = new Random(); System.out.println("Candidate\tRank"); for(int i=0;i { rank = rand.nextInt(10); array[i]=rank; System.out.println(i+" \t"+rank); sum=array[i]+sum; } Average=sum/size; System.out.println("The Average of Ranks of the Candidate is:"+Average); } public void FindPermutaion(int size) { long fact=1; long sum=0,Average; System.out.println("Candidate\tPermutation"); for(int i=0;i { for(int j=1;j For the hiring problem with n candidates, you can always use an array of ranks to denote the candidates, e.g., ifn-4, array (3,2,4,1) means you would hire the first candidates (rank 3), the second candidate (rank 2, better than rank 3) and the last candidate (rank 1) Use four methods to estimate the expected number of hires in hiring problem that contains n candidates. 1 . Output !-. 2. Generate 10,000 random arrays of ranks, check the number of hires for each random array, and output the average; 3. Enumerate all the n! permutations of the arrays of ranks, check the number of hires for each array in the set of n! permutations, and output the average; 4. Output Ln n Compare the results you get from method 1, 2, 3 and 4 for n-8,10,12 in terms of number of hires and the running time. If n-50, can your program give the result using methods 1, 2, and 4? What about using method 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions

Question

1. Define mass and mediated communication

Answered: 1 week ago