Answered step by step
Verified Expert Solution
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 then the output is:
:
:
:
:
Only repeated numbers and their frequencies should be printed out.
Hint: Steps that can help to solve this problem.
Step Start reading the numbers using a for loop
Step Create list of lists.
Step Create a new list for every new number read from the original list
Step Append the new number to the newly created list.
Step Store all lists into one single list as follows.
Step For each new number read from the data, check if it exists in any of the lists discovered so far.
Step If it exists, append that number to its list.
Step Otherwise, go to Step
Step If all numbers are done, iterate over the list of lists and check those lists that have length of more than 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
Listoflistslist
#list for a new number where a new number is stored
newnumberlistlist
#append the new number to the list
newnumberlist.appendnewnumber
#append the newnumberlist to the list of lists
Listoflists.appendnewnumberlist
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
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