Question: 2 + 5 3. The Java program compress below takes two parameters: a string s and an integer factor, which indicatos how many consecutive occuroncos
2 + 5 3. The Java program compress below takes two parameters: a string s and an integer factor, which indicatos how many consecutive occuroncos of any character c should be compressed in the form on where n is the number of consecutive occurrences of c. The program compresses the input string s by the given compression factor and return the re- sulting compressed string. For example, given the input string aabbbe and a factor 2, the resulting compressed string will be a2b3*, but it the factor is instead, then the sequence of two a's is not compressed and the resulting string will be ab. public static String compress (Strings, int factor if factor -2); if (s.length() factor) result == last String valueof (count: else result current last - C; current - String.value; count - 1; + . int count - 1 11 12 12 15 16 21 24 22 if (count > factor resuit last String, value (count): else result current; return result; 2013 (c) Data-flow Testing: For all the variables contained in the compress method above, list all the definition-use pairs, distinguishing between predicate (p-use) and computa- tional uses (c-use). You can use the following table as template. Variable Def-use pairs (p-use) Def-use pairs (c-use) (1.2). ... (3,4).... [10 marks) (5,6).... (7.8). - factor
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
