How would you answer this? “There is an application running in a machine with 1 KB memory and this application eventually terminates. How long can such an application run?” PS - apparently “until it runs out of memory” is not the answer.
This question is very vague and open ended. You could talk a lot about operating systems, app runtimes, memory management, system architecture etc. Since it's a phone screen, they would probably like to know how broad and deep you know about computers.
Also, not a trick question.
What company interview was this?
One of the FAANG
Your answer is vaguer than this interview question. Wtf is wrong with you. Just say the company name!
142 years? while (datetime.now.year < 2161);
WTF BS
If it eventually terminates, that means it doesn't go into an infinite loop. Which means it can't hit the same state twice. How many different states can 1KB of memory represent? That's the max number of cycles it can go through.
Don’t forget about register states.
Computers aren't real
it can run for a long time if well designed and written or can terminate immediately.
I don't remember enough about base memory consumption by processes. But it seems to me there will be some overhead due to OS stuff. So your program itself will have 1024 - X = memoryLeft And then with that memory left you can generate 2^8 states for each byte. So you have 2^8 * memoryLeft states you can transition through. But we don't have to transition linearly. The pattern of traversal can be super convoluted. Even a linear transversal could take longer than the universe. And we can get a whole lot more than that. Not to mention all the delays between transitions, like sleep timers, etc. So it's hard to say, but I'd head down this path of logic and see what his reaction was ------- Edit: Actually, can we only visit each state once? I guess I was thinking of state transitions wrongly maybe.
Tech Industry
Yesterday
230
Why some people are more successful than the other?
AMA
Yesterday
1361
I’m a professional coaster AMA
Ask Blinders
Yesterday
814
Tipping culture is really getting out of control! Waiter gave me ‘a look’ because I tipped her 10% for ‘BAD service!’
Tech Industry
Yesterday
808
The new Tesla Model 3 P goes from 0-60 in 2.9 seconds
Tech Industry
Yesterday
2153
TESLA UP 14% AFTER HOURS 🎉🎉🎉🎉
What clarifying questions did you ask? What assumptions did you make? You know, like what the fuck does the application do, how does the app and machine handle memory, what kind of machine... for starters.
I did mainly ask what the application does, to which I was told “it updates its state and eventually terminates”. That’s all I could get out of the interviewer.
Bro for something like this you have to then make assumptions about memory management on both the app and machine and give several scenarios of how the app will eat up memory and term. Memory leaks?