Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started