I’ve been trying to figure this out for a while and I just cant get it. Any help would be great. I’m programming in C++.
Find a run time of O(n^3 log n) using two looping structures.
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.
Assuming that this is a homework, here is a hint: you need to put an
O(N*LogN)operation inside your two nested loops such that the operation does not need a loop.For example, you can start with an array of
Nitems, do nested loops oniandjthat reverse array elements betweeniandj, and then sort the resulting array. Reversing isO(N), sorting isO(N*LogN), so sorting dominates; two outer loops provide the remainingO(N^2). Both sorting and reversing can be done using standard library functions, without additional loops.