PROBLEM 4 (12 pts) - List of frequent elements Write a function which receives as input a lists and a number n (the freq
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
PROBLEM 4 (12 pts) - List of frequent elements Write a function which receives as input a lists and a number n (the freq
PROBLEM 4 (12 pts) - List of frequent elements Write a function which receives as input a lists and a number n (the frequency), and returns as result a list of frequent elements (i.e. elements which appear at least n times in this list). def frequentElements (someList, n): Example: frequentElements([6,4,3,5,8,7,3,8,4,4,8],2) frequentElements([6,4,3,5,8,7,3,8,4,4,8],3) --> [3,8,4] --> [4,8] Note: the elements in the returned list should be according to the order they fulfill the frequency criterion (when checked left to right). Each frequent element should appear just once.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!