Jump to content
KayS

Pseudocode

Recommended Posts

Hi, everyone the year has ended I finished my 2nd year at University. I was just going over my Subject Knowledge by doing quizzes, practice tests etc on my University site. However, there servers are messed up so I cant download the mark scheme and I don't know if my answers are correct so I'm going to post the question up and give my reasoning behind my answer and you could tell if I'm correct and what the correct answer would be.

 

28apc29.jpg

 

I have chosen C as the answer as when you give n = 100 it returns the lowest interger meaning that the less amount of data that needs to be processed by the algorithm meaning its would be the fastes.

 

Please let me know if you agree

Share this post


Link to post
Share on other sites

I would try them with a number significantly larger than 100 and see what kind of results you get.

Share this post


Link to post
Share on other sites

sorry i meant to write 1000 and it seems to be that C is the best would you agree? because

 

C 13*1000 +62 whereas D 1000(2) ... C returns a lower interger meaning it would be more efficent to process

Share this post


Link to post
Share on other sites

Hi, everyone the year has ended I finished my 2nd year at University. I was just going over my Subject Knowledge by doing quizzes, practice tests etc on my University site. However, there servers are messed up so I cant download the mark scheme and I don't know if my answers are correct so I'm going to post the question up and give my reasoning behind my answer and you could tell if I'm correct and what the correct answer would be.

 

28apc29.jpg

 

I have chosen C as the answer as when you give n = 100 it returns the lowest interger meaning that the less amount of data that needs to be processed by the algorithm meaning its would be the fastes.

 

Please let me know if you agree

 

You can go with process of elimination.

 

n^2 + anything is bigger than n^2, so S1 is bigger than S4 for sure

S4 is also bigger, than S3 (n^2 > n)

So, it's between S3 and S2. The simplest way is to plug in bigger and bigger numbers; 1000 and 10000 just to see which is bigger.

 

A more educational approach would be to look at how the graphs of n^2, logn and nlogn look like. You can see here for a chart (and a generally good Big-O "cheat sheet" site) http://bigocheatsheet.com/#chart

Share this post


Link to post
Share on other sites

hold

Edited by Sato

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.