I’ve wrote an algorithm that looks for duplicates in unsorted lists. It does n – m operations on each iteration where m is iteration number and n is size of input list. What is its big O?
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.
O(n^2). The work here is
n+(n-1)+(n-2)+...+1 = n(n+1)/2.A more intuitive way to look at it is that you do at least
n/2work for at leastn/2iterations, so you do at leastn^2/4work.