Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find the number of elements that are repeated in a given list of numbers and display the number and it's frequency. For example, if L

Find the number of elements that are repeated in a given list of numbers and display the number and it's frequency.
For example, if L=[2,3,2,5,7,3,5,9,2,7,7,7,11] then the output is:
2: 3
3: 2
5: 2
7: 4
Only repeated numbers and their frequencies should be printed out.
Hint: Steps that can help to solve this problem.
Step 1. Start reading the numbers using a for loop
Step 2. Create list of lists.
Step 3. Create a new list for every new number read from the original list
Step 4. Append the new number to the newly created list.
Step 5. Store all lists into one single list as follows.
Step 6. For each new number read from the data, check if it exists in any of the lists discovered so far.
Step 7. If it exists, append that number to its list.
Step 8. Otherwise, go to Step 3
Step 9. If all numbers are done, iterate over the list of lists and check those lists that have length of more than 1(using len() function).
Iterating of a list of lists can be done in the same way as iterating any other list, each time the target variable will be set to a new list.
#Sample code to get started
#this is list of lists
List_of_lists=list()
#list for a new number where a new number is stored
new_number_list=list()
#append the new number to the list
new_number_list.append(new_number)
#append the new_number_list to the list of lists
List_of_lists.append(new_number_list)
Do not use maps, sets, dictionaries or any other data structures that are not covered in class so far.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

How can I or others help?

Answered: 1 week ago

Question

=+3 Offer guidelines for becoming a valuable wiki contributor

Answered: 1 week ago