Question: find _ mode ( arr: DynamicArray ) - > tuple [ DynamicArray , int ] : Write a standalone function outside of the HashMap class
findmodearr: DynamicArray tupleDynamicArray int:
Write a standalone function outside of the HashMap class that receives a dynamic array,
which is not guaranteed to be sorted. This function will return a tuple containing, in this
order, a dynamic array comprising the mode most occurring values of the given array,
and an integer representing the highest frequency of occurrence for the mode values
If there is more than one value with the highest frequency, all values at that frequency
should be included in the array being returned the order does not matter If there is only
one mode, the dynamic array will only contain that value.
You may assume that the input array will contain at least one element, and that all values
stored in the array will be strings. You do not need to write checks for these conditions.
For full credit, the function must be implemented with ON time complexity. For best
results, we recommend using the separate chaining hash map instance provided for you in
the functions skeleton code.
Example #:
da DynamicArrayapple "apple", "grape", "melon", "peach"
mode, frequency findmodeda
printfInput: da
Mode : mode Frequency: frequency
Output:
Input: apple 'apple', 'grape', 'melon', 'peach'
Mode : apple Frequency:
Example #:
testcases
Arch "Manjaro", "Manjaro", "Mint", "Mint", "Mint", "Ubuntu",
"Ubuntu", "Ubuntu"
one "two", "three", "four", "five"
for case in testcases:
da DynamicArraycase
mode, frequency findmodeda
printfda
Mode : mode Frequency: frequency
Page of
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
