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
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