By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,913 Members | 1,379 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,913 IT Pros & Developers. It's quick & easy.

How can I create a more efficient function?

P: 1
I have a function that's supposed to find the max student, second max student, min student, and second min student based off a compare function within the student class. For the Compare::lt I use in this function it bases off last_name, first_name then SSN and it also keeps track of the numbers of times any compare was called. I'm supposed to limit this call, can anyone help me think of a more efficient method? Currently with the following code I'm getting around O(4n)
1 Week Ago #1
Share this Question
Share on Google+
1 Reply

P: 135
I am not sure if theoretical explanation of something is enough to judge the actual implementation and hence provide feedback on the optimisation.

Also for the complexity, O(4n) will be O(n). Similarly, O(6n), O(8n), O(4n) .. etc. = O(n). They all represent linear growth.
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.