Is it O(n log n) or O(log n)?
Share
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.
I’m going to say it’s not O(log n) because binary searches don’t work well on linked lists – you don’t have efficient random access.
If you really tried to do binary search, it would take O(log n) steps, but in each step, you need an O(n) traversal to access the desired element. So you could say it’s O(nlog(n)).
You should just do a O(n) linear search instead.