In: Computer Science
Now say you wish to write a program that, given a natural number input n, finds another program (e.g. in Java or C) which prints out n. The discovered program should have the minimum execution-time-plus-length of all the programs that print n. Execution time is measured by the number of CPU instructions executed, while “length” is the number of characters in the source code. Can this be done?
(Hint: Is it possible to tell whether a program halts on a given input within t steps? What can you say about the execution-time-plus-length of the program if you know that it does not halt within t steps?)
Solution: See, the complexity of a given program does not always depend upon the size of the program, it also depends upon the logic that is getting implemented through the program. If you write three lines of code and the logic of the program is just way too complex then your program would actually take longer to execute and if your program has more lines of code but if the logic is simple and efficient then even the size of your program is more but it would still take less time to execute because the logic is simple and efficient.
So yeah, it can be done that you write a code that has more lines but does not contain any logic block that is complex in nature and requires more time to get implemented, and hence it would be executed by the system in a lesser amount of time. In that case, the execution time of the code would be less but its size is actually more.
Here's the solution to your question and it is absolutely correct, please please please provide it a 100% rating. Thanks for asking and happy learning!!