Calculating n with Super-Fast Computing: P1-P4

  • Thread starter Thread starter blackle
  • Start date Start date
  • Tags Tags
    Computing
Click For Summary

Homework Help Overview

The discussion revolves around calculating the value of n for different algorithms based on their runtime complexities, specifically in the context of a hypothetical scenario where computations are performed over an extensive period, such as 12 billion years. The algorithms in question include linear, quadratic, exponential, and logarithmic time complexities.

Discussion Character

  • Exploratory, Assumption checking, Problem interpretation

Approaches and Questions Raised

  • Participants attempt to calculate the maximum value of n for each algorithm given a fixed time frame. They explore the implications of computational speed and question how to interpret the problem statement regarding the calculations required for each algorithm.

Discussion Status

Several participants express confusion about the problem's wording and the calculations needed for part (b). There is an ongoing exploration of how to correctly interpret the time constraints and the implications of a faster computer on the values of n for each algorithm. Some participants provide insights into the calculations while others seek clarification on the problem's requirements.

Contextual Notes

Participants note the potential misunderstanding regarding the time units and the nature of the computations involved, particularly regarding the phrasing of "calculate the value of n." There is also mention of the Earth's sun's lifespan as a contextual backdrop for the problem's time frame.

blackle
Messages
8
Reaction score
0
• P1 takes n days to run
• P2 takes n^2 days to run
• P3 takes 2^n days to run
• P4 takes log(n) in base 2 days to run
So, to run P2 on an n of 4 would take 16 days.

a. For each version of the program, calculate the value of n (rounded down) we could compute if we let the program run for 12 billion years , which is (very) roughly how long until the Earth’s sun dies.

b. Let’s say we have access to a computer which runs one million times faster than the one above; so we could compute P1(1) in one millionth of a day. Write out the n we could compute for each of the above algorithms given this new processing power.

The Attempt at a Solution



a) I believe I solved part a) correctly.
P1: n = 12 000 000 000
P2: n = SquareRoot(12 000 000 000)
P3: n = log(12 000 000 000) in base 2
P4: n = 2^12 000 000 000

b) I have been trying to grasp the problem. So what values are we exactly supposed to find?
I understand:
P1: n = 1 took 1 day. but processor is 1 million times faster so takes 1/1000000 days.

What I am confused about is what of P2 are we supposed to calculate?
P2: n = 1 took 1 day. - do we take n to be 1? or we calculate the value of n to run an algorithm for 1/1000000 days like we did in part a)?

Any help would be appreciated. Thanks!
 
Physics news on Phys.org
blackle said:
• P1 takes n days to run
• P2 takes n^2 days to run
• P3 takes 2^n days to run
• P4 takes log(n) in base 2 days to run
So, to run P2 on an n of 4 would take 16 days.

a. For each version of the program, calculate the value of n (rounded down) we could compute if we let the program run for 12 billion years , which is (very) roughly how long until the Earth’s sun dies.

b. Let’s say we have access to a computer which runs one million times faster than the one above; so we could compute P1(1) in one millionth of a day. Write out the n we could compute for each of the above algorithms given this new processing power.


The Attempt at a Solution



a) I believe I solved part a) correctly.
P1: n = 12 000 000 000
P2: n = SquareRoot(12 000 000 000)
P3: n = log(12 000 000 000) in base 2
P4: n = 2^12 000 000 000

b) I have been trying to grasp the problem. So what values are we exactly supposed to find?
I understand:
P1: n = 1 took 1 day. but processor is 1 million times faster so takes 1/1000000 days.

What I am confused about is what of P2 are we supposed to calculate?
P2: n = 1 took 1 day. - do we take n to be 1? or we calculate the value of n to run an algorithm for 1/1000000 days like we did in part a)?

Any help would be appreciated. Thanks!
If I understand the problem correctly, if P1 runs for 12,000,000,000 years, n would not be 12,000,000,000 (which is in years); n would be 12,000,000,000 years x 365 days/year. This mistake affects all of your answers.

For the b part, if P1 takes n = 12,000,000,000 x 365 days, then on the faster computer P1 would take 12,000,000,000 x 365 /1,000,000 days, or 12,000 X 365 days. And so on for P2, P3, and P4.
 
blackle said:
• P1 takes n days to run
• P2 takes n^2 days to run
• P3 takes 2^n days to run
• P4 takes log(n) in base 2 days to run
So, to run P2 on an n of 4 would take 16 days.

a. For each version of the program, calculate the value of n (rounded down) we could compute if we let the program run for 12 billion years , which is (very) roughly how long until the Earth’s sun dies.

b. Let’s say we have access to a computer which runs one million times faster than the one above; so we could compute P1(1) in one millionth of a day. Write out the n we could compute for each of the above algorithms given this new processing power.


The Attempt at a Solution



a) I believe I solved part a) correctly.
P1: n = 12 000 000 000
P2: n = SquareRoot(12 000 000 000)
P3: n = log(12 000 000 000) in base 2
P4: n = 2^12 000 000 000

b) I have been trying to grasp the problem. So what values are we exactly supposed to find?
I understand:
P1: n = 1 took 1 day. but processor is 1 million times faster so takes 1/1000000 days.

What I am confused about is what of P2 are we supposed to calculate?
P2: n = 1 took 1 day. - do we take n to be 1? or we calculate the value of n to run an algorithm for 1/1000000 days like we did in part a)?

Any help would be appreciated. Thanks!

The problem statement is a bit confusing. For part (a), I take it to mean that:
Algorithm P1 takes n days to calculate n - or maybe n things.
Algorithm P2 takes n2 days to calculate n.
Algorithm P3 takes log2(n) days to calculate n.
Algorithm P4 takes 2n days to calculate n.​

There are on average, about 365.24 days per year, so there are approximately 365.24 (days/year)·12×109years ≈ 4.38×1012 days in 12 billion years.

It looks like you should compute each answer; in other words,
rather than saying that for P2: n = √(4.38×1012),
you should say that for P2: n = 2.09×106,
etc.​

For part (b):

This computer is 1 million times as fast, so Algorithm P1 takes n/1,000,000 days to calculate n - or maybe n things. Equivalently, Algorithm P1 takes n days to calculate n million. You could also think of this as follows: The fast computer can calculate in 12×109years what the slow computer (in part a) would require 12×1015 years to calculate.

The following may be handy for getting some of your results log2(x)=(1/ln(2))·ln(x) or log2(x)=(1/log10(2))·log10(x).

For instance, in part (a), P3 can calculate n = log2(4.38×1012) = (1/log10(2))·log10(4.38×1012) ≈ (3.3219)·[log10(4.38)+log10(1012)] = (3.3219)·[log10(4.38)+ 12]. Notice that log10(10k) = k

FYI: The Earth's sun has only about 5 billion years left - before burning out.
 
Thanks everyone for the reply, especially Sammy :)
 
Both SammyS and I were confused about what the problem was saying, especially this part: "calculate the value of n (rounded down) we could compute...". If this is the exact wording of the problem, you should probably get clarification on what it means from your instructor.

Computers don't generally compute a number; they perform an operation or a sequence of operations that results in a number.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 53 ·
2
Replies
53
Views
10K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
5K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K