Tagged Questions
11
votes
1answer
126 views
Recursive calculator in C
This is a calculator I wrote for a student's project.
It still has a problem (one that I know of), where it can't handle inputs of the form 2*2*2... (more than one ...
10
votes
2answers
120 views
Printing permutations of a given string
I want some feedback on the program I developed in C for printing the permutations of a given string.
...
8
votes
3answers
362 views
Integer-to-string conversion using recursion
Adapt the ideas of printd to write recursive version of itoa; that is, convert integer into a string by calling a recursive ...
8
votes
2answers
664 views
Recursive string reverse function
I'm studying C on K&R and now I'm facing a recursion exercise that states:
Write a recursive version of the function reverse(s), which reverses the string s ...
7
votes
2answers
421 views
Can this recursive binary search in C be made more concise?
Can someone please let me know if they see glaring issues with this code? I tested a handful of cases and it seems to work but in other threads. I often see much more concisely written versions of ...
6
votes
1answer
652 views
Maximum Subarray Problem - Recursive O(n log n) algorithm
I have implemented a recursive O(n log n) algorithm for solving the maximum sub-array problem. I would like a general review for it.
Here the ...
5
votes
2answers
108 views
Recursive reverse function
Write a recursive version of the function reverse(s), which reverses the string s in place.
Here is my solution:
...
5
votes
2answers
2k views
Reversing a linked list by iteration and recursion
From my original question on Stack Overflow: Is my implementation of reversing a linked list correct?
I'm a beginner at C and I'd like to know about style, and correctness of the reverse algorithms. ...
4
votes
1answer
114 views
Using a function recursively to calculate higher-order derivatives
I am writing a code to do some numerical task using the routines of Numerical Recipes book. One of my objectives is to calculate the second derivative of a function and I have a routine that ...
4
votes
1answer
55 views
Optimization of matrix determinant calculation
I have this algorithm that calculates the matrix determinant using recursive divide-and conquer-approach:
...
3
votes
2answers
121 views
Recursive a+b function
I am practising recursion and have written the small code for summing a+b as below:
...
3
votes
1answer
116 views
Recursive Implementation of merge sort
Information about my code:
I am following this MIT OCW algorithms course. The first lecture described insertion sort and merge sort. I implemented merge sort in C.
The algorithm is structured as a ...
3
votes
1answer
105 views
Is a Recursive-Iterative Method Better than a Purely Iterative Method to find out if a number is prime?
I made this program in C that tests if a number is prime. I'm as yet unfamiliar with Algorithm complexity and all that Big O stuff, so I'm unsure if my approach, which is a combination of iteration ...
2
votes
3answers
234 views
To check if a string C is an interleaving of A and B Code
This is my code to check if a string C is an interleaving of Strings A and B. Please suggests optimizations, and where I can improve.
...
2
votes
1answer
29 views
Optimizing string replacement program that uses recursion
I have the following string replacement program for a string of size 256:
I am replacing the string
"\'"
with the string
'
Please suggest any modifications if needed or any ...
2
votes
1answer
29 views
Multiplying a numeric string with the “vedic method”
This is vedic method multiplication. This code takes time on a very long numeric string, and I want to optimize it. I also apply recursion on multIndices (this ...
1
vote
1answer
492 views
recursion using pipes [closed]
So hi,
my goal with my code is to have a program similar to pipes in unix like
$printenv | sort | less
using recursion. I'm pretty new to pipes and file descriptor manipulation so I don't know ...
1
vote
2answers
529 views
Confusing program for reversing link List using recursion? [closed]
I was trying to reverse the link list using recursion and somehow I did it?
But one think is bothering me how the head in the last line finally points to the element 4 (i.e. the first element after ...
-3
votes
1answer
73 views
whats wrong with my recursion? [closed]
I am working on trying to create a tree in a recursive fashion. I have gotten constructive feedback on my previous questions so I try once more. I dont want to use malloc, and please dont post ...