Question
Find Duplicates Write a function called find_dups that takes a list of int's as a parameter and returns a list of values that are duplicated
Find Duplicates
Write a function called find_dups that takes a list of int's as a parameter and returns a list of values that are duplicated in the given list. For example, if the given list contains values { 10, 20, 10, 30, 40, 20, 10 }, the list returned by your function should contain values { 10, 20 }. The order of the values in the returned list is not important, but the returned list should not contain any duplicates (i.e. the example had three 10's, but 10 shows up only once in the returned list). You will need to devise an algorithm for finding the duplicates. Suggestions will be given in class. You are free to use any member functions of the list class or functions included in the algorithm library. Once you have completed the function and tested it, determine the run-time (Big Oh) of your function. Remember to consider the run times of any library functions used as part of the solution. Explain how you arrived at the run-time, and note any assumptions you may have made regarding the run-times of any library functions.
Give your analysis of your function in file README.md.
#include using namespace std;
list
int main() { // A few lists for testing list
cout << "Duplicates in list1:"; print_list(find_dups(list1)); cout << "Duplicates in list2:"; print_list(find_dups(list2)); cout << "Duplicates in list3:"; print_list(find_dups(list3)); }
list
void print_list (const list
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