Programming 1
Week 9: Exercises

1. Duplicate Values

  1. Write a function that takes a list of integers and returns True if there are any duplicate values in the list. Use sorting to accomplish this task. Do not modify the original list.

  2. Write a function with the same behavior, using a set to accomplish the task.

  3. Which implementation do you think will be faster on a large list? As an experiment, allocate a list of 5,000,000 unique integers in the range from 1 to 1,000,000,000, then call both of the above functions on your list. Each function should return False. How does the exection time compare?