Does anyone know the Big O of array_unique()?
I haven’t gone through the source, but I would imagine it loops through each value and checks to to see if it is in the array which would be O(n^2) is this correct?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s
O(nlogn)since it uses sorting instead of yourO(n^2)scanning.Quoted from http://php.net/manual/en/function.array-unique.php
EDIT: Remember to Google it, check the manual, check for existing questions, and then ask it.