Friday 23 January 2015

General Purpose Merge-Sort

Here is a C program for sorting different types of data in Merge-Sort paradigm . You have to include this program in your application program to use it. And important thing is that you have to specify the type of data you are going to use( Don't worry there is an example). You can sort int,char,char*,float,double,unsigned int,unsigned long types.

Merge-Sort.c contains two useful functions ,those are MergeSort(array,startindex,endindex) and a utility function to print sorted data . Below example uses these .

Here is a C program that uses this program to sort strings ( array of character pointers)

#define type string
#include "MergeSort.c"
int main(void)
    {
    char* array[]={"C programming","Python Programming","Operating System","Unix","Programs for you","How are you"};
    MergeSort(array,0,5);// starting index to last index
    PrintArray(array,0,5);
    return 0;
    }

Here is MergeSort.c .
Let me know if you have any different methods to do this or any questions .

Wednesday 7 January 2015

A Difficult Thing For Beginner

           I feel that a programmer finds it difficult to adopt to certain language constructs that are low-level when compared to a high-level language he/she has worked with.
  Consider a person who learnt Python as one's first computer language and practiced most of the language constructs,  begins to learn C programming. One may feel difficult at the beginning because one's first language has very flexible built-in data-structures and functions than when compared to C.
             The fact that I am one of the examples for the above supports my statement . After I learnt Python, I started experimented with  C. It took me a considerable amount of time to realize how  valuable C is. I kept on wishing that C should've had simple constructs as Python, till I got to know that in fact, Python is a C program.
 Thanks to Mr. Guido Van Rossum for that flexible, general purpose, object oriented, scripting language . If we consider complexities of the programs written in Python and C , compared to C programs, a Python program has a high time and space complexity. We need to know that there is a trad-off between efficiency and flexibility and internal complexity is proportional to flexibility .

Tuesday 6 January 2015

Program To Search A Word In Given Files : C language

Hi,
Here is a C program to search for a string-of-characters in given files line-by-line. That is, it searches for the required search key in each line of the file and prints the no. of occurrences in that line.
It takes a string-of-characters and any number of files separated with space as input via arguments. It uses ANSI C  standard library functions.

NOTE: During execution, if the string-of-characters or file-names has white-spaces in its name, QUOTE that.
 Ex: file-name.exe "I am" "file1.txt" "file2.txt" 
Download file from here

An Inspirational Article

 I found an inspirational article by Erica Heidi. Its wonderful and  inspires those of us who are the creative geniuses (as I'd like to name them, the creators).
 Felt like sharing this because it inspired me a lot.

About This Blog

Dear reader,
I being a Computer Science student, love programming and am keen to know programming methods based on different efficient algorithms. This blog is just my share of the vast ocean of knowledge, mine being only a droplet.