There is still some room for improvement.
Try going over this code line by line with some example input and see if you can find what is obsolete.
If you really can't find it, I could provide you with some more hints.
Well to me the code looks like a converted loop (replace if by while and remove everything starting from else and it would work, however I guess you want to keep it recursive here), so try thinking about something you would need in a loop, but not necessarily in a function.
If you look closely at the code, you see that i only takes the values '0' and '1', because every time the function is called, it is initialised back to '0'.
So in this case, i can be replaced with constants throughout the code.
Where you recursively call PROMPT ask yourself under what condition you get there? There are 2 return points from this function, they could be reduced to 1.
The function has 2 execution paths when *T != '\0' and when *T == '\0'. It also has 1 explicit return (and i implicit return). Obviously you can not remove the implicit return so examine the 2 execution paths to see which statements get executed for the 2 conditions and see if you can simplify the 2 paths and reduce to a single implicit return.
I'm trying to create Python parser/interpreter using ANTLR.
Reading grammar from language refference I found:
or_expr::= xor_expr | or_expr "|" xor_expr
For me it looks like infinite recursion....
Greetings.
I want to get everyone's opinion on the use of recursion.
We covered it in class tonight and I want a good solid answer from
people in the "know" on how well recursion is accepted...
I suppose spring fever has hit at alt.math.undergrad since I didn't get
any rise from
them when I posted this a week ago, so I am reposting this to some of
my favorite
programming groups:
I'm...
Can every problem that has an iterative solution also be expressed in
terms of a recursive solution?
I tried one example, and am in the process of trying out more examples,
increasing their...
Hello all,
I've been messing about for fun creating a trial division factorizing
function and I'm naturally interested in optimising it as much as
possible.
I've been told that iteration in...
My code does recursion loops through a couple of functions. Due to problematic I/O input this leads sometimes to "endless" recursions and after expensive I/O to the Python recursion exception.
What...
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...