Question

5. Modify the algorithm used in this chapter to locate the longest run of non-consecutive charact...

5. Modify the algorithm used in this chapter to locate the longest run of non-consecutive characters in the string

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You just need to change the lines of 8, 9 and 10.

The modified pseudocode/algorithm is given below:

Change line number 8 to 10 as below
THEN {
Current_Run_Value = New_Digit // Assigning New_Digit to Current_Run_Value
Current_Run_Length = 1 // Setting Current_Run_Lentgh value to 1
}
ELSE
Current_Run_Length = 110 + Current_Run_Length // In the ELSE block just adding 110 to Current_Run_Length and updating it to Current_Run_Length

Add a comment
Know the answer?
Add Answer to:
5. Modify the algorithm used in this chapter to locate the longest run of non-consecutive charact...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Run-length encoding (RLE) is a simple "compression algorithm" (an algorithm which takes a block of data...

    Run-length encoding (RLE) is a simple "compression algorithm" (an algorithm which takes a block of data and reduces its size, producing a block that contains the same information in less space). It works by replacing repetitive sequences of identical data items with short "tokens" that represent entire sequences. Applying RLE to a string involves finding sequences in the string where the same character repeats. Each such sequence should be replaced by a "token" consisting of: the number of characters in...

  • Longest paths Can you modify Dijkstra’s algorithm to find the length of the longest path from...

    Longest paths Can you modify Dijkstra’s algorithm to find the length of the longest path from a vertex s to another vertex t in a directed acyclic graph?

  • Find the probability mass function of X, the length of the longest run of consecutive heads...

    Find the probability mass function of X, the length of the longest run of consecutive heads in four flips of a fair coin.

  • Question 2 In a series of 100 fair coin flips, on average, what is the longest consecutive run of...

    Question 2 In a series of 100 fair coin flips, on average, what is the longest consecutive run of either heads or tails? What about for 1000 fair coin flips? Perform a Monte Carlo simulation to answer this question. Hint: look at function rle(). For example, suppose in 10 coin flips we observe {H,H,H,T,T,H,T,T,T,T},{H,H,H,T,T,H,T,T,T,T}, then the longest run is four. use rstudio do this.

  • Write a pseudocode description of the printLCS () algorithm, which prints the longest common subs...

    Write a pseudocode description of the printLCS () algorithm, which prints the longest common subsequence of two strings x and y. Your algorithm should take as input the completed ïïcs Π integer array of longest common subsequence lengths, and the two strings x and y. (So, you do not have the path[] [] array - see Lecture 19, slides 100 and 101.) Your algorithm must return the specific string corresponding the length found in 1lcs [n] [m] and it should...

  • In an array, a "run" occurs when 2 or more consecutive elements match. For example in...

    In an array, a "run" occurs when 2 or more consecutive elements match. For example in the array {2, 3, 3, 3, 3, 5, 5 6} there is a run of threes, and a run of fives. The length of the run of threes is 4 (because there are 4 threes in a row). Write a method that returns the length of the longest run. If no run occurs, return 0. maxRun([2, 3, 3, 3, 3, 5, 5, 6]) rightarrow...

  • PLEASE CODE IN PYTHON Run-length encoding is a simple compression scheme best used when a data-set...

    PLEASE CODE IN PYTHON Run-length encoding is a simple compression scheme best used when a data-set consists primarily of numerous, long runs of repeated characters. For example, AAAAAAAAAA is a run of 10 A’s. We could encode this run using a notation like *A10, where the * is a special flag character that indicates a run, A is the symbol in the run, and 10 is the length of the run. As another example, the string KKKKKKKKKKKKKBCCDDDDDDDDDDDDDDDKKKKKMNUUUGGGGG would be encoded...

  • Python3 : Write the function longestRun(s, chars) that takes a possibly-empty string s and a second...

    Python3 : Write the function longestRun(s, chars) that takes a possibly-empty string s and a second possibly-empty string of chars. We will say that a character is "good" if it is in the chars string (case insensitively, so "A" and "a" would match). The function should return the length of the longest consecutive run of good characters in the given string s. For example, consider: longestRun("abbcazBbcababb","bz"). This returns 3 (look for "zBb"). Restrictions: for loop, slicing cannot be used, if...

  • Write your code in the file StringRec.java. For this problem, the following restrictions apply: YOUR CODE...

    Write your code in the file StringRec.java. For this problem, the following restrictions apply: YOUR CODE MUST BE RECURSIVE. Do not use loops (while, do/while, or for). Do not declare any variables outside of a method. You may declare local variables inside a method. Complete the following method: public static String decompress(String compressedText): Decompress the input text, which has been compressed using the RLE algorithm (previous hw assignment): Run-length encoding (RLE) is a simple "compression algorithm" (an algorithm which takes...

  • 0. Modify or create the table(file) named Staff first used in assignment 5. There is no...

    0. Modify or create the table(file) named Staff first used in assignment 5. There is no change to the structure, and if you need to recreate it the column names, data types and lengths are described below: Table Name Column Name Data Type Length Comment/constraint Staff: id int name varchar office char fee decimal reviewDate date 3 primary key 15 not null 7 7,2 default 0.00 Initials have been added to the name column values, so data for an insert...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT