Question: This pseudocode is an example of what the format for the pseudocode above should use in java:) i) Develop a well-documented pseudo code that finds
This pseudocode is an example of what the format for the pseudocode above should use in java:)
i) Develop a well-documented pseudo code that finds the two consecutive elements in the array with the smallest difference in between, and the two consecutive elements with the biggest difference in between. The code must display the values and the indices of these elements. For instance, given the following array [20, 52,400, 3, 30, 70, 72, 47, 28, 38, 41, 53, 20] your code should find and display something similar to the following (notice that this is just an example. Your solution must not refer to this particular example.): The two conductive indices with smallest difference between their values are: index 5 and index 6, storing values 70 and 73. The two conductive indices with largest difference between their values are: index 2 and index 3, storing values 400 and 3. In case of multiple occurrences of the smallest or largest differences, the code should display the first found occurrence. Question 1 Reduce a string by removing the repeated characters and replacing them with the number of times the character is repeated. 10: 1: Algorithm removeDuplicates(String) Input: A string of length n 3: Ouptut: A reduced string with characters followed by the number of times it is repeated in the initial string nt length of string 0(1) array character array of the string newStr w counter 0 8: if n == 0 then newStr = end if for i 1 to n (inclusive) do O(n) 12: if array[i] + array[i-1] then if counter == 1 then 0(1) newStr new Str + array[i-1] else newStr newStr + array[i-1] + counter end if counter 0 end if 20: end for 21: return newStr 11: 011) 1. a. The time complexity of my algorithm is O(n) 1. b. The space complexity of my algorithm is 0(1) since we are not creating a new array in our algorithm. i) Develop a well-documented pseudo code that finds the two consecutive elements in the array with the smallest difference in between, and the two consecutive elements with the biggest difference in between. The code must display the values and the indices of these elements. For instance, given the following array [20, 52,400, 3, 30, 70, 72, 47, 28, 38, 41, 53, 20] your code should find and display something similar to the following (notice that this is just an example. Your solution must not refer to this particular example.): The two conductive indices with smallest difference between their values are: index 5 and index 6, storing values 70 and 73. The two conductive indices with largest difference between their values are: index 2 and index 3, storing values 400 and 3. In case of multiple occurrences of the smallest or largest differences, the code should display the first found occurrence. Question 1 Reduce a string by removing the repeated characters and replacing them with the number of times the character is repeated. 10: 1: Algorithm removeDuplicates(String) Input: A string of length n 3: Ouptut: A reduced string with characters followed by the number of times it is repeated in the initial string nt length of string 0(1) array character array of the string newStr w counter 0 8: if n == 0 then newStr = end if for i 1 to n (inclusive) do O(n) 12: if array[i] + array[i-1] then if counter == 1 then 0(1) newStr new Str + array[i-1] else newStr newStr + array[i-1] + counter end if counter 0 end if 20: end for 21: return newStr 11: 011) 1. a. The time complexity of my algorithm is O(n) 1. b. The space complexity of my algorithm is 0(1) since we are not creating a new array in our algorithm