Question: Implement the following function, and comment on the running time of your function in the functions header. /* Return a vector storing all distinct values

Implement the following function, and comment on the running time of your function in the functions header.

/* Return a vector storing all distinct values in the input vector e.g., list=[2,4,4,4,2,1], return a vector containing [2,4,1]

e.g., list=[1,1,4,5,1,3,2,2,2}, return a vector containing [1,4,5,3,2]

@param list: contain the data set

@pre: list has been initialized with a certain number of elements

@post: return a vector storing elements from list, all duplicates are removed, and values keep the order of their first occurrences in list, i.e., as 2 appears first in list, it will also appears first in the returned vector. */

vector Distinct (vector & list)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!