Sunday, October 18, 2009

Codes Codes !!

So much for the title. Well how many times i code a certain algorithm i always lost it in the mess of my laptops Hard drive, so finally thinking of organizing all my work and liking the codes in the blog :)
Here are few of them. Needless to say no matter how compacted i code there is always a scope of optimizing it, i agree.

1. Merge sort , Sorting problem time complexity O(NlogN)
2. Binary Search , using recursion
3. Binary Search , using iterative method
4. grade school multiplication , (how ever the code can be implemented using D & C this is the basic idea of it
5. Binary Search Tree , (well, if you check out the output at the bottom of the page you can find a seg fault (I wonder) The code runs perfectly fine on my machine.
6. Red Black Tree , This one took a lot of time for me to code.. huh!? It has in it the implementation of insert operation on red black trees. Doesn't include the delete()
7. Longest Common Subsequence, an exhaustive version using backtracking - non DP code
8. The whole bunch of Link list operations
9. Depth First search, the raw code, source, introduction to algorithms, useful in determining # of paths b/w given pair of vertices* and detecting cycles in a graph* (topological sorting)
I'd update the list after coding more..:)

Friday, October 9, 2009

Some things that i should have learnt way before...

There was nothing much to keep me occupied in the past month to post about it. Creating Makefile was one of the thing that came across after idling for long time.
So here is the way you do it, how ever the complete tutorial about it could be found at
http://www.gnu.org/software/make/manual/make.html

Here are a few simple sample files for make

/**
*main.c
*/

#include "stdio.h"
int main()
{
printf("main");
two();
return 0;
}

/**
*two.c
*/

#include "stdio.h"
#include "header.h"

int two(){
printf("two %d", N);
return 0;
}


/**
*header.h
*/

#define N 100


#Makefile

objects = main.o\
two.o
edit : $(objects)
gcc -o edit $(objects)

two.o : header.h
.PHONY : clean

clean :
rm edit $(objects)

#end Makefile

how ever a better insight could be obtained by glancing through the URL though ;)