Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve it with c++ and as it is asked . answer it as soon as possible. thank you Midrerm Project implement the algorithm, described

image text in transcribed

please solve it with c++ and as it is asked . answer it as soon as possible. thank you

Midrerm Project implement the algorithm, described below in the section titiled Permutation Algoritm, for generating alil he permutations of n distinct symbols .THE PROVIDED ALGORITHM MUST BE IMPLEMENTED You are NOT allowed to use any other algorithm. . This project must be an indvidual eftort Any apparent coliaboration in your submited work will be reported as Academic Misconduct . You must also use the following main program and are not permitted to change n * You must write a function named permute that (a) accepts a character array tr the symbols to be rearranged, (b) accepts an integer for the number of symbols in the array, and (c) returns 1 if a permutation was generated and 0 if a permutation could not be You are alowed to write helper functions you deem useful . The foilowing main program must be used char symbo ls[10] . ( 's. "M' int n-5 /l Generate pernutations until there are no more. int count while (hasNext) ( counte+ for (int i-o; i n; i..) { printf""symbols[i])i printff"Total pernutations return 8: sd", count); Step Description 1 The first time this algonthm is used so forth) 1b The symbols S, S, S, are the first permutation so return 1 to indicate a permutation has been generated The algornthm has aiready been used at least once Find a symboi that can be swapped 2 Set k to 1 3 Ifk > n then no symbol can be swapped so return 0 (no more permutations are possible) 4 Find the position (p) of Syin the current permutation 5 Ifp sn then swap the symbols at positions p and p-1 and retum 1 (a swap was possible and a new permutation has been The symbol cannot be swapped-return it to its initial position 6 Find the initial position 0) for S 7 Itprithen at Midrerm Project implement the algorithm, described below in the section titiled Permutation Algoritm, for generating alil he permutations of n distinct symbols .THE PROVIDED ALGORITHM MUST BE IMPLEMENTED You are NOT allowed to use any other algorithm. . This project must be an indvidual eftort Any apparent coliaboration in your submited work will be reported as Academic Misconduct . You must also use the following main program and are not permitted to change n * You must write a function named permute that (a) accepts a character array tr the symbols to be rearranged, (b) accepts an integer for the number of symbols in the array, and (c) returns 1 if a permutation was generated and 0 if a permutation could not be You are alowed to write helper functions you deem useful . The foilowing main program must be used char symbo ls[10] . ( 's. "M' int n-5 /l Generate pernutations until there are no more. int count while (hasNext) ( counte+ for (int i-o; i n; i..) { printf""symbols[i])i printff"Total pernutations return 8: sd", count); Step Description 1 The first time this algonthm is used so forth) 1b The symbols S, S, S, are the first permutation so return 1 to indicate a permutation has been generated The algornthm has aiready been used at least once Find a symboi that can be swapped 2 Set k to 1 3 Ifk > n then no symbol can be swapped so return 0 (no more permutations are possible) 4 Find the position (p) of Syin the current permutation 5 Ifp sn then swap the symbols at positions p and p-1 and retum 1 (a swap was possible and a new permutation has been The symbol cannot be swapped-return it to its initial position 6 Find the initial position 0) for S 7 Itprithen at

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

What do you look for when finding new friends?

Answered: 1 week ago

Question

=+ 3. What are adverse selection and moral hazard?

Answered: 1 week ago