Problem:
Consider a computer with identical interpreters at level 1, 2 and 3. It takes an interpreter n instructions to fetch, examine, and execute one instruction. A level 1 instruction takes k nanoseconds to execute. How long does it take for an instruction at levels 2, 3, and 4.

My work:
Level 4 - n^4
Level 3 - n^3
Level 2 - n^2
Level 1 - n^1 or n (takes k nanoseconds)

n = number of instructions it takes to fetch, examine, and execute one instruction

k = nanoseconds to execute a level 1 instruction

Does anyone know if I set the problem up correctly? The question in general really confuses me.

"Level"?

What is a "level"? This question makes no sense.

A level as in each layer or stage a set of instructions or "code" go through. Like you have your base level (Lvl 0) which is the most basic of code, like binary numbers. Then you would have an OS and then JVM. That sort of thing. I hope that clears the question up.

I guess you have not copied your full homework description , level 2 should take k^2 time without further information.

A level as in each layer or stage a set of instructions or "code" go through. Like you have your base level (Lvl 0) which is the most basic of code, like binary numbers. Then you would have an OS and then JVM. That sort of thing. I hope that clears the question up.

Your answer makes sense, in terms of stacking naive interpreters atop one another.

Your examples of levels are completely nonsensical though, justsoyouknow. "Binary numbers" is not a programming language. If you mean "machine code" or assembly, then you're at the bottom level of indirection that you can access on your computer. Most OSes and typical applications are at that level, not above it -- they are compiled down to machine code. Then code interpreted by an interpreter would be running at the level one greater than whatever the interpreter's running at, of course.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.