Google Interview Question
1,227 Interview Reviews |
Back to all Google Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineer at Google:
You have a 64bit interger counter set to 0. How long it will take to overflow the counter given that you are incrementing it at 4Ghz speed.
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (6)
2 of 3 people found this helpful
4GHz means 4*(2^30) instructions per second.. which is 2^32
effectively it is (2^64)/(2^32) = 2^32 seconds.. or roughly 136years.
Helpful Answer?
Yes |
No
Inappropriate?
0 of 1 people found this helpful
increment speed(is) = 1 second / (4*10^9) increments | 4Ghz = 1x10^9 Hz
total seconds (ts) = 2^64 increments * (1 second /(4*10^9) increments)
ts = 4.611 * 10^9 seconds
total years = ts/(60*60*24*52) = 146.2 years
Helpful Answer?
Yes |
No
Inappropriate?
0 of 1 people found this helpful
and 4ghz = 4*10^9 Hz
Helpful Answer?
Yes |
No
Inappropriate?
i.e, 4GB per second. Not incrementing every second.
So after elapsing first second, counter is at 4GB. After elapsing 2nd second, it is 4 + 4 = 8GB.
64 bit integer is, 2^64 = 2^32 * 2^32. Which is roughly 4GB * 4GB = 16GB.
So per second counter incremented to 4GB, so for 16GB it takes 4 seconds.
Helpful Answer?
Yes |
No
Inappropriate?
1 of 1 people found this helpful
To be accurate, the answer is 4G * 4G = 16 G^2 = 16 * 2^30 * 2^30.
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up
0 of 2 people found this helpful
by grad stud: