I'm trying to swap elements in my array with the following conditions
1. Scan the array elements from left to right until a uppercase
2. Scan the array element from the right to left until a lowercase
3. Swap the two letters.
4 Move all the lowercase to the left and upper case to the left
Hence, i created a swapElement function to swap element recursively by checking every single possible condition hence it will be a little lengthy
However, it is returning me an infinite loop despite having a base condition of i >= j. It is suppose to keep swapping and return me the swapped array until the condition i >= j condition is met.
Please do not ask me to try to do it iteratively as i managed to figure it out and i'm trying to practice and figure out recursive swap but was stucked.
For each call to swapElementR(), the program creates i and j as local variables to that specific call. Their values are not passed as arguments. As a result, the function essentially does the first step forever and never reaches a point where i is not zero and j is not size - 1.
You may want to look for a way to pass i and j down the chain.