Skip to main content

All Questions

Tagged with
9 votes
3 answers
601 views

Form all possible well-formed strings of 'n' nested pairs of 2 types of ASCII brackets

Taking an interest in the challenge presented in this recent Code Review question, I've concocted a C solution (valid as C++, if I'm not mistaken) seeking to reduce both the lines of code and the ...
Fe2O3's user avatar
  • 4,657
2 votes
3 answers
279 views

Prevent stack memory usage for recursive function in C

This C code does DBSCAN - Density-based spatial clustering of applications with noise. It's a cluster algorithm for turining unsupervised (no labels) data to become ...
euraad's user avatar
  • 183
6 votes
1 answer
61 views

Chessboard configuartions with no possible capture on the next move

THE TASK: Given an NxM "chess"board and Q,R,B,K where Q is the number of queens, R the number of rooks, B the number of bishops, and K the number of knights find out how many possible ...
Wow1345's user avatar
  • 121
5 votes
5 answers
594 views

Find the 10 largest files in a directory tree

I've recently finished a small project intended to better understand C. The program will output the ten largest files found (recursively in the event of subdirectories) in a specified directory. I've ...
John Harrington's user avatar
1 vote
3 answers
233 views

Recursive power (mathematical operation) function in C

How to make a C recursive exponentiation (power) function better? I developed a pretty simple (yet decent, imo) power function for the sake of learning. I'm not quite trying to compete with ...
Gustavo Duarte's user avatar
7 votes
2 answers
5k views

C delete files and directories, recursively if directory

This is my function that uses recursion to recursively delete a directory. I like my way of skipping entries . and ... But ...
user244272's user avatar
5 votes
3 answers
1k views

Separating the even and odd numbers in an array in C

I wrote a working program in C that takes an array with size 2ⁿ, and separates all the even numbers from the odd numbers. For example: Input: {1,2,3,4,5,6,7,8}, Output: {8,2,6,4,5,3,7,1} I want my ...
Coder48's user avatar
  • 171
1 vote
2 answers
178 views

A recursive function to reverse string

Write a recursive version of the function reverse(s), which reverses the string s in place. I'm studying K&R and wrote a code for the question. ...
op ol's user avatar
  • 207
1 vote
1 answer
173 views

Find a powerset of a set in C

The code below is an implementation of purely recursive solution to find a powerset of any given set. The input set is a string, and the output - array of strings. Both of them are wrapped into a ...
anfauglit's user avatar
  • 113
4 votes
2 answers
93 views

Primality Test Refactoring

I devised a new primality test isPrimeNumber() below which determines if 1000000007 is prime. It works fine but the code looks unprofessional in my opinion. Is there any way to refactor it to make it ...
vengy's user avatar
  • 203
-4 votes
4 answers
134 views

Get the prime factors of a number

My solution runs properly and I have tested it against various test cases. Is this the best approach? ...
Subhadeep Banerjee's user avatar
1 vote
2 answers
259 views

Recursive Matrix Multiplication Algorithm

Can I improve on this any further. Is there a prettier way of passing the array sizes? ...
Ivor Denham-Dyson's user avatar
2 votes
1 answer
179 views

recursive file search, C , linux

hi guys this script recursively searches for files with a certain extension and possibly in a directory passed by the terminal ....(In case no directory has been passed, search from the current one) I ...
checcasio 's user avatar
2 votes
3 answers
2k views

Counting the number of digits with a recursion algorithm in c

I'm learning recursion and I think that I can finally wrap my head around it. I had to write a program that given an integer would print out its number of digits and I wanted to know if it is ...
Duarte Arribas's user avatar
4 votes
2 answers
91 views

User defined function call on a stack based interpreter for concatenative language

I would like to receive some advice on how to improve a small concatenative stack-based interpreter, executing a joy-like programming language. It is really minimal, and is in fact a subset of a ...
Foxy's user avatar
  • 143

15 30 50 per page