Skip to content

Instantly share code, notes, and snippets.

View leonmavr's full-sized avatar
🎯
Focusing

Leo Mav leonmavr

🎯
Focusing
View GitHub Profile
@leonmavr
leonmavr / count_spaces.c
Created October 25, 2015 04:32
Count spaces in a file line
int count_spaces (FILE* f) {
int spaces = 0;
char chIn;
for ( chIn = '\0'; chIn != '\n'; spaces += ( chIn = fgetc(f) ) == ' ' );
return spaces;
}
@leonmavr
leonmavr / tree_glp.c
Last active September 17, 2015 02:51
tree_glp is a function to get the last added parent in a balanced ordered heap
/*
takes the root of the tree, a new node
where the last parent will be written to,
a counter passed as 0, and max = inf
The recursions can be unwrapped in the
following pseudocode, based on Depth
First Search
visited = {}