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.
It's not a trick question. The upper bound on program execution time is the number of distinct states that the computer could be in multiplied by instruction execution time.
What area of topic does this fall under?
Automata theory
Software Engineering Career
13h
2443
L4 Google -> 45 interviews, 5 offers, AMA
Tech Industry
2h
457
can you notice a difference in the youthfulness of women when you know they have a past of many nights out drinking?
Tech Industry
7h
798
The man I love hates me because I’m Vietnamese
Tech Industry
20h
1771
Why doesn't OpenAI offshore and reduce expense by 80%
Tech Industry
3d
41741
What happens when most of your team is Indian?
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?