Explanation of Solution
The algorithm for lists all possible rearrangements of the symbols in a string of five distinct character is shown below:
Step 1: Start
Step 2: Define the function “permutationFucntion” that is for returns the all possible list of rearrangements for given string using “join” function.
Step 3: Define the function “permuteFunction” that is for compute the rearrangement for given string with three arguments such as “string”, “starting index” and “last index”.
If starting index is equal to last index
Display the string by calling the function “permutationFunction”.
Else
Check the range of starting index and last index using “for” loop.
Swap the string index using “nstr[startIndex], nstr[i] = nstr[i], nstr[startIndex]”.
Recursively call the function “permuteFunction” with given string, increment of starting index and last index.
After calling function, then swap the string index using “nstr[startIndex], nstr[i] = nstr[i], nstr[startIndex]”.
Step 4: Assign the sample string
Step 5: Compute the length of string
Step 6: List the given sample string
Step 7: Call the permutation function with list string, value of starting index and “length of string – 1”.
Step 8: Stop
Algorithm Explanation:
The given algorithm is used to lists all possible rearrangements of given string of five distinct characters.
- From the given algorithm, the function “permutationFunction” is used to displays the list of rearrangement string using “join” function.
- Then compute the possible rearrangement using the function “permuteFunction”.
- In this function, first check whether the staring index is equal to the last index...
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Python problem To decipher a code we must make a program that performs certain operations on the input string. -If they find 3 equal letters in a row, you must replace them with the next letter in the alphabet.-If you only find 2 equal letters in a row, you must replace them with the previous letter in the alphabet.-The comma must be removed-The period should be left and a space added after it.-All other characters should be left as isNote that in this case after the "Z" is the "A", and therefore before the "A" is the "Z". Given a string S, execute the operations described above, until no more can be executed. For example: GHHGP, OOOMMZAAZ => GGGPPLZZZ => HELLO EntryThe input will be a single line containing the string S. The string only includes uppercase letters of the English alphabet (Does not include Ñ) and special characters. DepartureYou must print the resulting string in double quotes ". Examples Input Example 1 LLLENTTA, JDDD OBCCBUMMTO!Output Example 1 "HIDDEN…arrow_forward20. Develop an algorithm to find the number of words that contain a particular character in a given String. Example: Input: "this is one of the amazing exercises", 's' Output: 3; Describe your algorithm in pseudocode. 21. What is the runtime complexity of your algorithm?arrow_forwardالفصل: الثاني الموضوع : واجب منزلي Assignment Question: (i): Given three numbers (numl, num2, and num3), write an algorithm to find and print the sumarrow_forward
- Let Σ= {Ac,BA,bcb,cd,ab,f,d,e}. (a) Identify valid strings and Find the length of the valid given below strings • fefBAfbcbcdAcfab • BAeffBAAcbcbab • bcbefabfABAAceddbcb Note: factorize each string for finding their lengtharrow_forwardPART 2 Answered only if you Have answered part 1.......plase skip it if you dont know the correct answer i need it urgent. Will doewnvote in case of wrong or copied answers from chegg or bartleby! A regular expression (shortened as regex or regexp; also referred to as rational expression) is a sequence of characters that specifies a search pattern. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. using regex create a python program to verify the string having each word start from 'j'? It should return True otherwise false.arrow_forwardWrite an algorithm that reads 10 integer numbers and calculates the average for numbers that are divisible by 5.arrow_forward
- Design an algorithm to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format: (9) test Scorel weight Test Scorel For example, sample data is as follows: 75 0.20 95 0.35 85 0.15 65 0.30arrow_forwardCode in python : function that gives length of string.arrow_forwardComputer Science iostream reduces all errors to one of four states, such as eof(), list other threearrow_forward
- please code in python Find the longest palindrome in a string and also print its length.arrow_forwardInput: a string in a line. ➢ Output: Print the pattern and the repeated count if there is a repeated pattern, Print "none" otherwise. ➢ Task: Design an algorithm in pseudocode/code to for the problem and write down the Algorithm analysis. The complexity of the algorithm must be in O(n). ➢ PS: You use the algorithm for string matching taught in class. The repeated pattern is valid only from the first character.arrow_forwardAll Prime Problem Create a program that lists all prime numbers from 1 to N. The input number N should be an integer greater than 0. Sample input/output | Input Output Input should be greater than 0! 2357 2357 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 7 100arrow_forward
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning