Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

part a) Modify the matlab code below to find the number of possibilities (through combinations and permutations) that 3 different awards can be awarded to

part a) Modify the matlab code below to find the number of possibilities (through combinations and permutations) that 3 different awards can be awarded to 4 students through the following cases: case I: one award goes to one student, case II: two awards goes to one student, case III: three awards goes to one student.

part b) Modify the matlab code below to find the number of possibilities (through combinations and permutations) that 5 different awards can be awarded to 8 students through the following cases: case I: one award goes to one student, case II: two awards goes to one student, case III: three awards goes to one student.

Matlab code:

close all; clear all; % clear all variables, close all windows with plots clc

tot_students = 5; num_awards = 3; students=[1:tot_students];

C3_alldifferent = combnk(students,num_awards); [rcomb1,ccomb1] =size(C3_alldifferent);

C3_alldifferent % Display ALL of the combinations n choose k

perm_nk1 = []; for ip=1:rcomb1; perm_nk_ip = perms(squeeze(C3_alldifferent(ip,:))); perm_nk1 = [perm_nk1; perm_nk_ip]; end perm_nk1 [rperm1,cperm1] = size(perm_nk1)

% Next generate those cases where one student gets 2 awards C2_alldifferent = combnk(students,num_awards-1) [rcomb2,ccomb2] =size(C2_alldifferent) % Determine the number of combinations (rows) by determining the size of the array

perm_nk2 = []; for ip=1:rcomb2; perm_nk_ip = perms(squeeze(C2_alldifferent(ip,:))); perm_nk2 = [perm_nk2; perm_nk_ip]; end perm_nk2

pnk2_onerA = [perm_nk2(:,1) perm_nk2(:,1) perm_nk2(:,2)]; pnk2_onerB = [perm_nk2(:,1) perm_nk2(:,2) perm_nk2(:,1)]; pnk2_onerC = [perm_nk2(:,2) perm_nk2(:,1) perm_nk2(:,1)]; pnk2_onerepeat = [pnk2_onerA; pnk2_onerB; pnk2_onerC];

perm_nk2 = pnk2_onerepeat; perm_nk2 % show results [rperm2,cperm2] = size(perm_nk2); rperm2

% Next generate those cases where one student gets 3 awards

C1_alldifferent = combnk(students,num_awards-2) perm_nk3 = [C1_alldifferent(:) C1_alldifferent(:) C1_alldifferent(:)]; [rperm3,cperm3] = size(perm_nk3);

ALL_permutations = [perm_nk1; perm_nk2; perm_nk3] [rperm_tot,cperm_tot]= size(ALL_permutations); rperm_tot

rperm_tot_check = rperm1+rperm2+rperm3

figure; hist(ALL_permutations(:),100); title(' Histogram of all permutations')

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_2

Step: 3

blur-text-image_3

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

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

The nature and importance of the global marketplace.

Answered: 1 week ago