224k views
5 votes
Let A be a collection of objects. Describe an efficient method for converting A into a set. That is, remove all duplicates from A. What is the running time of this method

User Richard II
by
6.4k points

1 Answer

2 votes

Answer:

An O(n lg n) algorithm( Mergesort )

Step-by-step explanation:

A been a collection of objects an Efficient method that can be used to convert A into a set is by applying

An O(n lg n) algorithm.

This is an efficient sorting methodology and it can be carried out using Mergesort ( an example of An O(n lg n) algorithm.) this methods works by firstly sorting out all the objects that is contained in A and they then we have to go through the sorted out objects in a linear manner in order to remove all duplicates.

Note : It will take ;O(n lg n) time to sort and O(n) time to remove the duplicates that is discovered

User Kits
by
5.9k points