EmbLogic's Blog

difference between malloc() and kmalloc()

Malloc can be called in user space as well as in kernel space.it allocates physically fragmented memory area .It doesnot actually allocate physical memory.Physical memory can be mapped later.

Kmalloc can be called only in kernel space.it allocates physically contiguous memory chunk.
Memory allocated by kmalloc is reserved and locked,which cannot be swapped.

Posted in Uncategorized | Leave a comment

Select Function in Socket.

Select function helps you to know  about the file descriptors which are ready for reading , writing. Basically when there is no data present in the socket during recv call it gets blocked till the data arrives so that meanwhile application can to further useful work.

int select() is also useful when there are multiple sockets and an application has to recieve data from them , select solves this problem while polling all the sockets to see if they are available for reading,writing & non-blocking operations.

Posted in Uncategorized | Leave a comment

Data Structures With C

In data structure padding some allocate space is free this case is called is padding. Like a example is as as the structure we take three variable that is int,char,float. This is structure allocate 12 byte space. At the architecture of process it read 1 word at the time.(for 32 bit process 4 byte per word and for 64 bit process 8 byte per word).

struct emblogic

{ int; char;float}blog;

 

At this avoid this structure padding in C !

we used

#pragma pack(1)

After that the size of structure this structure is only 9 byte.

My question is where is define this pragma pack(1) (like as include directory  path is /usr/include/ ). And how it works??

 

 

Posted in Data Structures with C | Leave a comment

what is 256-Bit Encryption

256-Bit Encryption is a data/file encryption technique that use a 256-bit key to encrypt and decrypt data or files.it is one of the most secure encryption method after 128 and 192-bit encryption,and is used in most modern encryption algorithms ,protocols & techniques including AES and SSL.

Posted in Project 2: Multiple Data Compression and Encryption, Uncategorized | Leave a comment

intro_shared_memory_prog.

RCS file: intro_shared_memory_by_fork.c,v
Working file: intro_shared_memory_by_fork.c
head: 1.36
branch:
locks: strict
emblogic: 1.36
access list:
symbolic names:
keyword substitution: kv
total revisions: 36; selected revisions: 36
description:
This is my frist program to know the use of shared memory.
We frist get shmid to the kernal.
—————————-
revision 1.36 locked by: emblogic;
date: 2015/10/25 08:29:39; author: emblogic; state: Exp; lines: +3 -4
Change some.
—————————-
revision 1.35
date: 2015/10/25 08:21:58; author: emblogic; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.34
date: 2015/10/25 08:21:29; author: emblogic; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.33
date: 2015/10/25 08:21:02; author: emblogic; state: Exp; lines: +0 -1
*** empty log message ***
—————————-
revision 1.32
date: 2015/10/25 08:20:34; author: emblogic; state: Exp; lines: +0 -1
*** empty log message ***
—————————-
revision 1.31
date: 2015/10/25 08:19:59; author: emblogic; state: Exp; lines: +1 -0
Print the value inside the parent which write in child.
—————————-
revision 1.30
date: 2015/10/25 08:19:25; author: emblogic; state: Exp; lines: +1 -0
Add the fork header file.
—————————-
revision 1.29
date: 2015/10/25 08:17:11; author: emblogic; state: Exp; lines: +0 -1
*** empty log message ***
—————————-
revision 1.28
date: 2015/10/25 08:17:01; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.27
date: 2015/10/25 08:16:46; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.26
date: 2015/10/25 08:15:49; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.25
date: 2015/10/25 08:15:24; author: emblogic; state: Exp; lines: +3 -3
*** empty log message ***
—————————-
revision 1.24
date: 2015/10/25 08:14:55; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.23
date: 2015/10/25 08:14:41; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.22
date: 2015/10/25 08:14:19; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.21
date: 2015/10/25 08:14:01; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.20
date: 2015/10/25 08:13:39; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2015/10/25 08:13:13; author: emblogic; state: Exp; lines: +2 -2
Print the data.
—————————-
revision 1.18
date: 2015/10/25 08:12:35; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.17
date: 2015/10/25 08:12:04; author: emblogic; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.16
date: 2015/10/25 08:11:42; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.15
date: 2015/10/25 08:10:29; author: emblogic; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.14
date: 2015/10/25 08:10:08; author: emblogic; state: Exp; lines: +1 -2
*** empty log message ***
—————————-
revision 1.13
date: 2015/10/25 08:09:07; author: emblogic; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.12
date: 2015/10/25 08:08:08; author: emblogic; state: Exp; lines: +2 -1
*** empty log message ***
—————————-
revision 1.11
date: 2015/10/25 08:07:34; author: emblogic; state: Exp; lines: +0 -1
*** empty log message ***
—————————-
revision 1.10
date: 2015/10/25 08:06:25; author: emblogic; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.9
date: 2015/10/25 08:05:29; author: emblogic; state: Exp; lines: +5 -5
*** empty log message ***
—————————-
revision 1.8
date: 2015/10/25 08:04:50; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.7
date: 2015/10/25 08:04:23; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.6
date: 2015/10/25 08:02:52; author: emblogic; state: Exp; lines: +2 -1
Move index the shared memory because data do not overwrite on that data which write inicially.
—————————-
revision 1.5
date: 2015/10/25 08:02:15; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2015/10/25 08:00:38; author: emblogic; state: Exp; lines: +11 -0
Use the signal
By the help of signal we write data in shared memory in child.
Print the value of ptr inside the signal and also print the data.
—————————-
revision 1.3
date: 2015/10/25 07:57:04; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2015/10/25 07:55:59; author: emblogic; state: Exp; lines: +20 -1
here print the value of ptr.
Also supply some value at ptr and print the value of ptr in parent using fork call.
—————————-
revision 1.1
date: 2015/10/25 07:51:13; author: emblogic; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

massage_queue_one_send_other_receive

THIS IS SEND DATA RCS

RCS file: msg_send.c,v
Working file: msg_send.c
head: 1.11
branch:
locks: strict
emblogic: 1.11
access list:
symbolic names:
keyword substitution: kv
total revisions: 11; selected revisions: 11
description:
Here use the msg_queue to send the data.
We print the msgid which provide by the kernal.
Print the value of this id.
—————————-
revision 1.11 locked by: emblogic;
date: 2015/10/24 15:56:13; author: emblogic; state: Exp; lines: +0 -1
Here we write the data in msg_que
—————————-
revision 1.10
date: 2015/10/24 15:55:31; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.9
date: 2015/10/24 15:54:43; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.8
date: 2015/10/24 15:54:27; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.7
date: 2015/10/24 15:54:03; author: emblogic; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.6
date: 2015/10/24 15:52:57; author: emblogic; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.5
date: 2015/10/24 15:52:10; author: emblogic; state: Exp; lines: +3 -2
*** empty log message ***
—————————-
revision 1.4
date: 2015/10/24 15:48:39; author: emblogic; state: Exp; lines: +7 -2
*** empty log message ***
—————————-
revision 1.3
date: 2015/10/24 15:41:14; author: emblogic; state: Exp; lines: +16 -1
Here enter the text from user.
Put this text inside the queue.
By the help of fgets().
We apply stdin i.e it takes input from the keyboard.
Copy that data in struct buff.
—————————-

revision 1.2
date: 2015/10/24 15:28:21; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.1
date: 2015/10/24 15:28:03; author: emblogic; state: Exp;
Initial revision
=============================================================================
THIS IS RECEIVE DATA RCS

RCS file: msg_receive.c,v
Working file: msg_receive.c
head: 1.6
branch:
locks: strict
emblogic: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
Here we make a prog. which receive the data by the help opf massge queue.
This messge queue read data as the other end.
—————————-
revision 1.6 locked by: emblogic;
date: 2015/10/24 16:25:41; author: emblogic; state: Exp; lines: +1 -0
Here we only read data which send trough send prog.
This is use to know how massage queue work.
—————————-
revision 1.5
date: 2015/10/24 16:21:55; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2015/10/24 16:21:31; author: emblogic; state: Exp; lines: +1 -1
,
—————————-
revision 1.3
date: 2015/10/24 16:19:36; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2015/10/24 16:17:44; author: emblogic; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.1
date: 2015/10/24 16:17:23; author: emblogic; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Difference between Kmalloc() and Vmalloc()

In order to allocate memory from kernel various types of API(application programming interfaces) are used.Two such API’s are Kmalloc() and Vmalloc().

SYNTAX:

void * kmalloc(size_t size , int flags);

void * vmalloc(unsigned long size);

Kmalloc() is use to allocate memory requested from the kernel.The memory allocated is returned by the API and it is physically as well virtually contiguous.Generally we need this physically contiguous memory when we have to implement some driver which will be used to interface some hardware or device.In kmalloc we can define the size,how much memory is needed and also we can give flags as GFP_ATOMIC and GFP_KERNEL.GFP_ATOMIC means get free pages from kernel in atomic fashion means the allocation will never sleep in between and the priority is also highest.This is generally used in interrupt handlers,and in those situation where sleep is not permitted as in the case with spinlocks.Another flag is GFP_KERNEL means get free pages from kernel,here sleep is allowed and it is normal allocation.The major disadvantage of kmalloc is that in certain cases when not enough physical memory is present,the API will return error usually NULL is returned and wastage of memory is there.There are other flags also GFP_WAIT,GFP_MASK depending on various features and requirements.The defintion of kmalloc is usually found in <slab.h> header file.

Vmalloc() is used to allocate memory from the kernel.The memory allocated is virtually contiguous but not physically contiguous.This API works in the similar manner as the user level malloc() works.It means vmalloc ensures memory is allocated from vitual address space.In vmalloc there is no option to define flag.We can give the amount of size we required in the argument.The user will not be able to distinguish the difference in memory allocated by vmalloc and kmalloc since it will be virtually contiguous but in real manner at the backend that memory will be in chunks /blocks.Every page table of the block will be having details of the another page table linked to it.If not enough memory is available then NULL will be returned.we can find vmalloc in header file<vmalloc.h>.The major advantage of vmalloc is that if enough physical contiguous memory is not available then it will allocate memory virtually in chunks and will link that memory so it appears to be virtually contiguous.

Posted in Uncategorized | Leave a comment

Message_queue

RCS file: msg_que_fork.c,v
Working file: msg_que_fork.c
head: 1.22
branch:
locks: strict
emblogic: 1.22
access list:
symbolic names:
keyword substitution: kv
total revisions: 22;    selected revisions: 22
description:
This is my frist prog. on mag queue.
—————————-
revision 1.22    locked by: emblogic;
date: 2015/10/24 14:53:29;  author: emblogic;  state: Exp;  lines: +0 -1
*** empty log message ***
—————————-
revision 1.21
date: 2015/10/24 14:52:39;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.20
date: 2015/10/24 14:52:19;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2015/10/24 14:51:57;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.18
date: 2015/10/24 14:51:31;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.17
date: 2015/10/24 14:51:09;  author: emblogic;  state: Exp;  lines: +3 -1
*** empty log message ***
—————————-
revision 1.16
date: 2015/10/24 14:50:33;  author: emblogic;  state: Exp;  lines: +0 -1
remove the wait.
—————————-
revision 1.15
date: 2015/10/24 14:49:42;  author: emblogic;  state: Exp;  lines: +1 -0
Print the value at child as well as parent.
—————————-
revision 1.14
date: 2015/10/24 14:48:55;  author: emblogic;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.13
date: 2015/10/24 14:46:47;  author: emblogic;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.12
date: 2015/10/24 14:46:07;  author: emblogic;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.11
date: 2015/10/24 14:41:01;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.10
date: 2015/10/24 14:40:38;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.9
date: 2015/10/24 14:40:13;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.8
date: 2015/10/24 14:37:48;  author: emblogic;  state: Exp;  lines: +18 -1
We call the foek and genrate the child or parent process.
In child we write the data in msg_queue.
In parent also write data in msg_queue.
When child make own structure then it send data to the queue.
Same process use parent and data pass block by block in msg queue.
—————————-
revision 1.7
date: 2015/10/24 14:20:37;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.6
date: 2015/10/24 14:19:59;  author: emblogic;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.5
date: 2015/10/24 14:17:42;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2015/10/24 14:16:52;  author: emblogic;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2015/10/24 14:16:06;  author: emblogic;  state: Exp;  lines: +1 -0
Define the size of buff.
—————————-
revision 1.2
date: 2015/10/24 14:14:14;  author: emblogic;  state: Exp;  lines: +15 -0
Generate the kernal id by the help of msgget().
Print that id .
—————————-
revision 1.1
date: 2015/10/24 13:31:39;  author: emblogic;  state: Exp;
Initial revision
=============================================================================

Posted in Project 03: Client Server Communication using Linux and IPC | Leave a comment

Toolchain

i m doing toolchain. There is an error in glibc. When im doing make check, then following errors occures.
============== ************* ================
libgcc_s.so.1 must be installed for pthread_cancel to work
Didn’t expect signal from child: got `Aborted’
make[2]: *** [/home/emblogic/sachin_jangid/abhishek_toolchain/build_tools/build_glibc/nptl/tst-mutexpi8.out] Error 1
make[2]: Leaving directory `/home/emblogic/sachin_jangid/abhishek_toolchain/build_tools/glibc-2.13/nptl’
make[1]: *** [nptl/tests] Error 2
make[1]: Leaving directory `/home/emblogic/sachin_jangid/abhishek_toolchain/build_tools/glibc-2.13′
make: *** [check] Error 2
============== ************* ================

plz help me to over come this.

Posted in ARM Embedded Processors, Project 9: Embedded Linux on ARM | Tagged | Leave a comment

Inter Process Communication

As it’s name Inter Process Communication(IPC) , this mechanism is use to communicate between different unrelated processes. In IPC, we set up a way to communicate between  different clients &  one server that’s our objective. Clients are of two types , req_client(requesting client)   send request to the server to do a specific task like addition, subtraction , multiplication or  division . Server receive the req_client request and pass it to the  proc_client(processing client). proc_client then do that task and gave the result to the server. server then provide result to the req_client according to their requests. This complete mechanism of communication between unrelated processes is known as IPC.

Posted in Uncategorized | Leave a comment

How to read space by scanf in c?

rvrs_of_string

Generally scanf() ignores the spaces,backslash n,tabs etc while taking input from the user, but by using scanset specifiers we are able to deal with this problem.
scanset specifiers are represented by %[].
whether we want to right a character or a string, both can be done by specifying it in these square brackets.

Let us take some cases:
char arr[15];
1. scanf(“%[a-z]c”,&arr);
2. scanf(“%[a-z]s”,&arr);

According to this- %[]is a scanset specifier & by writing a-z means only a-z characters can be given as input, nothing else.
c is specifying that only a character can be taken at a time as an input.
Whereas in 2nd case by writing s we are allowing a string to be taken as input.

3. scanf(“%[^\n]s”,&arr);
By using ^ we are telling that while writing a string, the time when we enter,scanf only takes a string upto that enter.That means it will allow all things as n input except newline. It can count spaces, tabs etc.

4. scanf(“%[^\t]s”, &arr);
this will stop taking input when it gets a tab.

5. scanf(“%[^24]“, &arr);
this would take input till 24 or 2 or 4 not encountered.

Posted in Uncategorized | Leave a comment

Linklist Operations : Creation,Insertion,display,searching,sorting,reversing using data,reversing using node,removes duplicates, comparision.

RCS file: insertion.c,v
Working file: insertion.c
head: 1.28
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 28;	selected revisions: 1
description:
it contains function for insertion
isertion at end
insertion at begin
insertion after key elemnt()
insertion before key element()
----------------------------
revision 1.28
date: 2015/07/25 04:21:12;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
=============================================================================

RCS file: insertion.c,v
Working file: insertion.c
head: 1.28
branch:
locks: strict
	root: 1.28
access list:
symbolic names:
keyword substitution: kv
total revisions: 28;	selected revisions: 1
description:
it contains function for insertion
isertion at end
insertion at begin
insertion after key elemnt()
insertion before key element()
----------------------------
revision 1.28	locked by: root;
date: 2015/07/25 04:21:12;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
=============================================================================

RCS file: insertion.c,v
Working file: insertion.c
head: 1.28
branch:
locks: strict
	root: 1.28
access list:
symbolic names:
keyword substitution: kv
total revisions: 28;	selected revisions: 28
description:
it contains function for insertion
isertion at end
insertion at begin
insertion after key elemnt()
insertion before key element()
----------------------------
revision 1.28	locked by: root;
date: 2015/07/25 04:21:12;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.27
date: 2015/07/24 06:36:49;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.26
date: 2015/07/24 06:27:22;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.25
date: 2015/07/23 12:40:56;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.24
date: 2015/07/23 12:39:16;  author: root;  state: Exp;  lines: +2 -6
*** empty log message ***
----------------------------
revision 1.23
date: 2015/07/23 10:52:47;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
----------------------------
revision 1.22
date: 2015/07/22 07:34:04;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.21
date: 2015/07/22 06:42:38;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.20
date: 2015/07/22 06:00:25;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.19
date: 2015/07/20 09:53:15;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.18
date: 2015/07/20 06:35:01;  author: root;  state: Exp;  lines: +4 -4
*** empty log message ***
----------------------------
revision 1.17
date: 2015/07/20 06:30:22;  author: root;  state: Exp;  lines: +4 -0
*** empty log message ***
----------------------------
revision 1.16
date: 2015/07/20 06:12:14;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.15
date: 2015/07/20 06:06:55;  author: root;  state: Exp;  lines: +4 -3
*** empty log message ***
----------------------------
revision 1.14
date: 2015/07/19 10:17:44;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.13
date: 2015/07/19 10:09:37;  author: root;  state: Exp;  lines: +13 -7
*** empty log message ***
----------------------------
revision 1.12
date: 2015/07/19 10:05:46;  author: root;  state: Exp;  lines: +6 -6
*** empty log message ***
----------------------------
revision 1.11
date: 2015/07/19 09:58:10;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2015/07/19 09:57:32;  author: root;  state: Exp;  lines: +5 -2
*** empty log message ***
----------------------------
revision 1.9
date: 2015/07/19 09:53:38;  author: root;  state: Exp;  lines: +7 -4
#[A#[A#[A.
----------------------------
revision 1.8
date: 2015/07/19 09:50:05;  author: root;  state: Exp;  lines: +4 -2
*** empty log message ***
----------------------------
revision 1.7
date: 2015/07/19 09:44:39;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.6
date: 2015/07/19 08:49:39;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.5
date: 2015/07/19 08:21:36;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.4
date: 2015/07/19 08:20:42;  author: root;  state: Exp;  lines: +45 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/19 08:17:05;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.2
date: 2015/07/19 07:54:38;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2015/07/19 07:51:23;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.15
branch:
locks: strict
	root: 1.15
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;	selected revisions: 15
description:
It contains all header files.
also contains all function declareation and definations
----------------------------
revision 1.15	locked by: root;
date: 2015/07/24 06:01:44;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.14
date: 2015/07/24 05:07:22;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.13
date: 2015/07/23 12:39:12;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.12
date: 2015/07/22 06:41:44;  author: root;  state: Exp;  lines: +2 -0
gave the prototype for reverse_linklist ()
----------------------------
revision 1.11
date: 2015/07/20 09:52:22;  author: root;  state: Exp;  lines: +1 -0
prtotype for searching() is given
----------------------------
revision 1.10
date: 2015/07/20 08:55:44;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.9
date: 2015/07/20 06:58:42;  author: root;  state: Exp;  lines: +1 -0
the prototype of deletion after key element
function is given
----------------------------
revision 1.8
date: 2015/07/20 06:29:21;  author: root;  state: Exp;  lines: +1 -0
give the prototype for deletion from end function
----------------------------
revision 1.7
date: 2015/07/20 06:06:05;  author: root;  state: Exp;  lines: +1 -1
modify the insert after an element();
----------------------------
revision 1.6
date: 2015/07/19 08:48:35;  author: root;  state: Exp;  lines: +2 -1
prototype for delete_begin() funation is given
----------------------------
revision 1.5
date: 2015/07/19 08:18:53;  author: root;  state: Exp;  lines: +0 -47
*** empty log message ***
----------------------------
revision 1.4
date: 2015/07/19 08:09:10;  author: root;  state: Exp;  lines: +8 -0
\.
----------------------------
revision 1.3
date: 2015/07/19 07:49:51;  author: root;  state: Exp;  lines: +0 -101
sparate the insertion function from header
----------------------------
revision 1.2
date: 2015/07/19 07:23:30;  author: root;  state: Exp;  lines: +1 -3
insertion after the key element function defination
defination of insert before key element defination
----------------------------
revision 1.1
date: 2015/07/19 07:17:17;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: reverse_node.c,v
Working file: reverse_node.c
head: 1.9
branch:
locks: strict
	root: 1.9
access list:
symbolic names:
keyword substitution: kv
total revisions: 9;	selected revisions: 9
description:
----------------------------
revision 1.9	locked by: root;
date: 2015/07/24 04:31:12;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.8
date: 2015/07/24 04:28:23;  author: root;  state: Exp;  lines: +4 -3
*** empty log message ***
----------------------------
revision 1.7
date: 2015/07/24 04:26:44;  author: root;  state: Exp;  lines: +2 -3
*** empty log message ***
----------------------------
revision 1.6
date: 2015/07/23 13:23:19;  author: root;  state: Exp;  lines: +7 -0
*** empty log message ***
----------------------------
revision 1.5
date: 2015/07/23 13:13:54;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.4
date: 2015/07/23 13:01:17;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/23 12:59:40;  author: root;  state: Exp;  lines: +6 -0
*** empty log message ***
----------------------------
revision 1.2
date: 2015/07/23 12:56:29;  author: root;  state: Exp;  lines: +8 -9
*** empty log message ***
----------------------------
revision 1.1
date: 2015/07/23 12:39:17;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: reverse.c,v
Working file: reverse.c
head: 1.22
branch:
locks: strict
	root: 1.22
access list:
symbolic names:
keyword substitution: kv
total revisions: 22;	selected revisions: 22
description:
this file contains a program to reverse a linklist.
----------------------------
revision 1.22	locked by: root;
date: 2015/07/25 04:21:13;  author: root;  state: Exp;  lines: +9 -1
*** empty log message ***
----------------------------
revision 1.21
date: 2015/07/24 06:27:24;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.20
date: 2015/07/24 05:07:25;  author: root;  state: Exp;  lines: +129 -0
*** empty log message ***
----------------------------
revision 1.19
date: 2015/07/23 10:42:58;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.18
date: 2015/07/22 08:03:16;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.17
date: 2015/07/22 07:59:03;  author: root;  state: Exp;  lines: +4 -4
*** empty log message ***
----------------------------
revision 1.16
date: 2015/07/22 07:57:50;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.15
date: 2015/07/22 07:55:45;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
----------------------------
revision 1.14
date: 2015/07/22 07:43:38;  author: root;  state: Exp;  lines: +4 -0
*** empty log message ***
----------------------------
revision 1.13
date: 2015/07/22 07:41:32;  author: root;  state: Exp;  lines: +8 -0
*** empty log message ***
----------------------------
revision 1.12
date: 2015/07/22 07:31:26;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.11
date: 2015/07/22 07:29:10;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2015/07/22 07:20:34;  author: root;  state: Exp;  lines: +5 -8
*** empty log message ***
----------------------------
revision 1.9
date: 2015/07/22 07:17:49;  author: root;  state: Exp;  lines: +3 -5
*** empty log message ***
----------------------------
revision 1.8
date: 2015/07/22 07:15:23;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.7
date: 2015/07/22 07:13:57;  author: root;  state: Exp;  lines: +4 -3
*** empty log message ***
----------------------------
revision 1.6
date: 2015/07/22 07:11:45;  author: root;  state: Exp;  lines: +16 -0
*** empty log message ***
----------------------------
revision 1.5
date: 2015/07/22 07:05:50;  author: root;  state: Exp;  lines: +6 -2
*** empty log message ***
----------------------------
revision 1.4
date: 2015/07/22 07:02:35;  author: root;  state: Exp;  lines: +2 -21
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/22 06:55:20;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.2
date: 2015/07/22 06:51:27;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.1
date: 2015/07/22 06:42:43;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: linklist.c,v
Working file: linklist.c
head: 1.48
branch:
locks: strict
	root: 1.48
access list:
symbolic names:
keyword substitution: kv
total revisions: 48;	selected revisions: 48
description:
This is the main program.
the node is created.
----------------------------
revision 1.48	locked by: root;
date: 2015/07/25 04:15:56;  author: root;  state: Exp;  lines: +1 -2
*** empty log message ***
----------------------------
revision 1.47
date: 2015/07/25 03:42:51;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.46
date: 2015/07/25 03:37:50;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.45
date: 2015/07/25 03:37:10;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.44
date: 2015/07/25 03:34:57;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.43
date: 2015/07/25 03:30:47;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
----------------------------
revision 1.42
date: 2015/07/25 03:26:41;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
----------------------------
revision 1.41
date: 2015/07/25 03:24:51;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.40
date: 2015/07/25 03:22:19;  author: root;  state: Exp;  lines: +18 -6
*** empty log message ***
----------------------------
revision 1.39
date: 2015/07/25 03:07:09;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.38
date: 2015/07/24 06:36:46;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
----------------------------
revision 1.37
date: 2015/07/24 06:32:55;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.36
date: 2015/07/24 06:27:21;  author: root;  state: Exp;  lines: +7 -2
*** empty log message ***
----------------------------
revision 1.35
date: 2015/07/24 06:18:14;  author: root;  state: Exp;  lines: +6 -4
*** empty log message ***
----------------------------
revision 1.34
date: 2015/07/24 06:10:27;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.33
date: 2015/07/24 06:01:47;  author: root;  state: Exp;  lines: +5 -1
*** empty log message ***
----------------------------
revision 1.32
date: 2015/07/24 05:30:04;  author: root;  state: Exp;  lines: +8 -1
*** empty log message ***
----------------------------
revision 1.31
date: 2015/07/24 05:24:59;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.30
date: 2015/07/24 05:24:25;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.29
date: 2015/07/24 05:15:36;  author: root;  state: Exp;  lines: +9 -2
*** empty log message ***
----------------------------
revision 1.28
date: 2015/07/24 05:07:25;  author: root;  state: Exp;  lines: +2 -122
*** empty log message ***
----------------------------
revision 1.27
date: 2015/07/24 04:31:10;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.26
date: 2015/07/23 12:39:14;  author: root;  state: Exp;  lines: +8 -0
*** empty log message ***
----------------------------
revision 1.25
date: 2015/07/22 06:48:43;  author: root;  state: Exp;  lines: +22 -4
*** empty log message ***
----------------------------
revision 1.24
date: 2015/07/22 06:42:18;  author: root;  state: Exp;  lines: +2 -0
call the reverse_linklist() in case 7
----------------------------
revision 1.23
date: 2015/07/22 06:00:24;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.22
date: 2015/07/20 09:52:41;  author: root;  state: Exp;  lines: +2 -1
calling search_linklist() in switch statement
----------------------------
revision 1.21
date: 2015/07/20 08:55:47;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
----------------------------
revision 1.20
date: 2015/07/20 06:59:32;  author: root;  state: Exp;  lines: +2 -0
calling the eletion after key element function
----------------------------
revision 1.19
date: 2015/07/20 06:35:00;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.18
date: 2015/07/20 06:31:51;  author: root;  state: Exp;  lines: +1 -1
remove the minor error.
----------------------------
revision 1.17
date: 2015/07/20 06:29:53;  author: root;  state: Exp;  lines: +3 -5
call deletion from end() inside switch.

/
----------------------------
revision 1.16
date: 2015/07/20 06:06:31;  author: root;  state: Exp;  lines: +1 -1
modify insert_after_element() call
----------------------------
revision 1.15
date: 2015/07/20 05:34:05;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.14
date: 2015/07/20 05:31:21;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.13
date: 2015/07/20 05:30:05;  author: root;  state: Exp;  lines: +21 -1
*** empty log message ***
----------------------------
revision 1.12
date: 2015/07/20 05:20:56;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.11
date: 2015/07/20 05:19:16;  author: root;  state: Exp;  lines: +1 -16
*** empty log message ***
----------------------------
revision 1.10
date: 2015/07/20 05:16:48;  author: root;  state: Exp;  lines: +2 -10
*** empty log message ***
----------------------------
revision 1.9
date: 2015/07/20 05:10:54;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.8
date: 2015/07/19 10:28:48;  author: root;  state: Exp;  lines: +6 -3
*** empty log message ***
----------------------------
revision 1.7
date: 2015/07/19 10:26:05;  author: root;  state: Exp;  lines: +7 -1
*** empty log message ***
----------------------------
revision 1.6
date: 2015/07/19 10:14:02;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
----------------------------
revision 1.5
date: 2015/07/19 08:49:07;  author: root;  state: Exp;  lines: +17 -1
the deletion funation is called with in a switch statement
----------------------------
revision 1.4
date: 2015/07/19 08:17:02;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/19 07:16:35;  author: root;  state: Exp;  lines: +36 -22
insert after a element or before a element function called
----------------------------
revision 1.2
date: 2015/07/19 05:02:56;  author: root;  state: Exp;  lines: +1 -0
insertion at the begining and insertion at the end functions are calling
----------------------------
revision 1.1
date: 2015/07/19 05:00:11;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deletion.c,v
Working file: deletion.c
head: 1.30
branch:
locks: strict
	root: 1.30
access list:
symbolic names:
keyword substitution: kv
total revisions: 30;	selected revisions: 30
description:
----------------------------
revision 1.30	locked by: root;
date: 2015/07/20 09:37:37;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.29
date: 2015/07/20 09:35:16;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
----------------------------
revision 1.28
date: 2015/07/20 09:33:07;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.27
date: 2015/07/20 09:31:16;  author: root;  state: Exp;  lines: +10 -12
*** empty log message ***
----------------------------
revision 1.26
date: 2015/07/20 09:20:09;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
----------------------------
revision 1.25
date: 2015/07/20 09:06:17;  author: root;  state: Exp;  lines: +10 -8
*** empty log message ***
----------------------------
revision 1.24
date: 2015/07/20 08:56:59;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.23
date: 2015/07/20 08:55:48;  author: root;  state: Exp;  lines: +31 -0
*** empty log message ***
----------------------------
revision 1.22
date: 2015/07/20 08:36:39;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.21
date: 2015/07/20 07:54:52;  author: root;  state: Exp;  lines: +5 -0
*** empty log message ***
----------------------------
revision 1.20
date: 2015/07/20 07:50:59;  author: root;  state: Exp;  lines: +7 -11
*** empty log message ***
----------------------------
revision 1.19
date: 2015/07/20 07:45:17;  author: root;  state: Exp;  lines: +2 -5
*** empty log message ***
----------------------------
revision 1.18
date: 2015/07/20 07:30:18;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.17
date: 2015/07/20 07:22:24;  author: root;  state: Exp;  lines: +8 -6
*** empty log message ***
----------------------------
revision 1.16
date: 2015/07/20 07:21:05;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.15
date: 2015/07/20 07:20:04;  author: root;  state: Exp;  lines: +4 -0
*** empty log message ***
----------------------------
revision 1.14
date: 2015/07/20 07:17:37;  author: root;  state: Exp;  lines: +6 -1
*** empty log message ***
----------------------------
revision 1.13
date: 2015/07/20 07:14:58;  author: root;  state: Exp;  lines: +6 -7
*** empty log message ***
----------------------------
revision 1.12
date: 2015/07/20 07:11:23;  author: root;  state: Exp;  lines: +11 -10
*** empty log message ***
----------------------------
revision 1.11
date: 2015/07/20 07:04:38;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2015/07/20 07:00:00;  author: root;  state: Exp;  lines: +28 -0
gave the defination of deletion after element ()
----------------------------
revision 1.9
date: 2015/07/20 06:38:02;  author: root;  state: Exp;  lines: +8 -3
*** empty log message ***
----------------------------
revision 1.8
date: 2015/07/20 06:30:34;  author: root;  state: Exp;  lines: +19 -1
give the defination for the deletion_end().
----------------------------
revision 1.7
date: 2015/07/20 05:38:08;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.6
date: 2015/07/20 05:37:31;  author: root;  state: Exp;  lines: +8 -1
*** empty log message ***
----------------------------
revision 1.5
date: 2015/07/20 05:31:22;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
----------------------------
revision 1.4
date: 2015/07/19 10:26:06;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/19 10:17:46;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.2
date: 2015/07/19 10:14:04;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2015/07/19 08:54:35;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: search_sort.c,v
Working file: search_sort.c
head: 1.11
branch:
locks: strict
	root: 1.11
access list:
symbolic names:
keyword substitution: kv
total revisions: 11;	selected revisions: 11
description:
this file contain function defination for searching and sorting a link list
----------------------------
revision 1.11	locked by: root;
date: 2015/07/22 06:13:17;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.10
date: 2015/07/22 06:11:27;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.9
date: 2015/07/22 06:09:45;  author: root;  state: Exp;  lines: +6 -6
,
----------------------------
revision 1.8
date: 2015/07/22 06:05:56;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.7
date: 2015/07/22 06:03:18;  author: root;  state: Exp;  lines: +12 -0
*** empty log message ***
----------------------------
revision 1.6
date: 2015/07/22 05:55:16;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.5
date: 2015/07/22 05:54:11;  author: root;  state: Exp;  lines: +22 -0
writing a program to sort a linklist
----------------------------
revision 1.4
date: 2015/07/20 09:59:20;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/20 09:58:00;  author: root;  state: Exp;  lines: +8 -2
*** empty log message ***
----------------------------
revision 1.2
date: 2015/07/20 09:54:07;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
----------------------------
revision 1.1
date: 2015/07/20 09:53:21;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: duplicates.c,v
Working file: duplicates.c
head: 1.4
branch:
locks: strict
	root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;	selected revisions: 4
description:
this file contains program for duplication of node in a sorted linklist
----------------------------
revision 1.4	locked by: root;
date: 2015/07/25 04:38:00;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
----------------------------
revision 1.3
date: 2015/07/25 04:35:53;  author: root;  state: Exp;  lines: +5 -2
*** empty log message ***
----------------------------
revision 1.2
date: 2015/07/25 04:23:30;  author: root;  state: Exp;  lines: +26 -0
*** empty log message ***
----------------------------
revision 1.1
date: 2015/07/25 04:21:14;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compare_linklist.c,v
Working file: compare_linklist.c
head: 1.1
branch:
locks: strict
	root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
----------------------------
revision 1.1	locked by: root;
date: 2015/07/24 06:01:47;  author: root;  state: Exp;
Initial revision
=============================================================================
Posted in Data Structures with C | Leave a comment

master_array creation

RCS file: fun.c,v
Working file: fun.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
rcs initiallised
—————————-
revision 1.1
date: 2015/07/26 06:38:44; author: saroj; state: Exp;
Initial revision
=============================================================================

RCS file: master_array.c,v
Working file: master_array.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is the function of master array.
—————————-
revision 1.1
date: 2015/07/25 10:17:29; author: saroj; state: Exp;
Initial revision
=============================================================================

RCS file: open_file.c,v
Working file: open_file.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is the open file.
—————————-
revision 1.1
date: 2015/07/25 10:18:12; author: saroj; state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
—————————-
revision 1.2
date: 2015/07/26 06:42:46; author: saroj; state: Exp; lines: +1 -0
unistd,h is added
—————————-
revision 1.1
date: 2015/07/26 05:50:41; author: saroj; state: Exp;
Initial revision
=============================================================================

Posted in Project 2: Multiple Data Compression and Encryption | Leave a comment

pointer

pointer6

Posted in Uncategorized | Leave a comment

Quick Sort using recursion

//Quick sorting using Recursion
#include<stdio.h>
#include<stdlib.h>
//Prototypes of functions used
int * input(int *,int);
int * sort(int *,int);
void display(int*,int);
int main()
{
int *a,n;
printf(“Enter number of numbers you want to sort?\n”);
scanf(“%d”,&n);
a = input(a,n);
a = sort(a,n);//call to quick sort
display(a,n);
return 0;
}
//Function to input an array
int * input(int *a,int n)
{
int i;
printf(“Enter %d elements\n”,n);
a = (int *)malloc(sizeof(int)*n);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
return a;
}
//Function to Quick Sort
int * sort(int *data,int n)
{
int too_small_index,too_big_index,pivot,temp;
pivot = 0;//Index of pivot element
too_big_index = pivot + 1;
too_small_index = n – 1;
//Terminating condition for recursive call
if(too_big_index>too_small_index)
return data;
do
{
//Step 1
while(*(data + too_big_index)<=*(data + pivot))
++too_big_index;
//Step 2
while(*(data + too_small_index)>*(data + pivot))
–too_small_index;
//Step 3
if(too_big_index<too_small_index)
{
temp = *(data + too_big_index);
*(data + too_big_index) = *(data + too_small_index);
*(data+too_small_index) = temp;
}
}while(too_small_index>too_big_index);//Step 4
//Step 5
temp = *(data + too_small_index);
*(data + too_small_index) = *(data+pivot);
*(data+pivot) = temp;
//Sorting left side of array
if(too_small_index!=too_big_index)
data = sort(data,too_small_index);
//sorting right side of array
sort((data+too_small_index+1),n-too_small_index-1);
return data;
}
//Function to display the array
void display(int*a,int n )
{
int i;
printf(“\nSorted list\n”);
for(i=0;i<n;i++)
printf(“%d\t”,*(a+i));
}

Posted in Data Structures with C | Tagged , , , , | Leave a comment