Tuesday 25 September 2012

Double Link List Using C Language

Double Link List..

a doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous and to the next node in the sequence of nodes. The beginning and ending nodes' previous and next links, respectively, point to some kind of terminator

Advantage

A doubly linked list can be traversed in both directions (forward and backward). A singly linked list can only be traversed in one direction. 

A node on a doubly linked list may be deleted with little trouble, since we have pointers to the previous and next nodes. A node on a singly linked list cannot be removed unless we have the pointer to its predecessor.
On the flip side however, a doubly linked list needs more operations while inserting or deleting and it needs more space (to store the extra pointer).
Implementation: Complete menu base code
#include<stdio.h>
#include<conio.h>
/*   Double Link List Example
     Developed By Girfa
     do not use it on any other website
*/
typedef struct st_dlist
{
struct st_list *pre;
int data;]
struct st_list *next;
}dnode;
/* Function Prototype */
dnode * create(int);
void addbegin(int,dnode**,dnode**);
void addlast(int,dnode**,dnode**);
void addbefore(int,int,dnode**,dnode**);
void addafter(int,int,dnode**,dnode**);
void del(int,dnode**,dnode**);
void print(dnode*);
void main()
{
dnode *head=NULL,*tail=NULL;
int n,s,opt;

Queue Using Single Link List Using C Language

Queue

a queue is a particular kind of abstract data type or collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed.

Queue Implementation Using Single link list

#include<stdio.h>
#include<conio.h>
/* Queue Implementation using single link list
   Develop By Girfa
   do not use it on any other website
*/
typedef struct st_que
{
int data;
struct st_que *next;
}que;
/* Function Prototype */
que* create(int);
void enque(int,que **,que **);
void deque(que**,que**);
void print(que*);

Stack Operation using C Language


Stack......
a stack is an area of memory that holds all local variables and parameters used by any function
One way of describing the stack is as a last in, first out (LIFO)
The push operation adds a new item to the top of the stack, or initializes the stack if it is empty
 If the stack is full and does not contain enough space to accept the given item, the stack is then considered to be in an overflow state. The pop operation removes an item from the top of the stack. A pop either reveals previously concealed items, or results in an empty stack, but if the stack is empty then it goes into underflow state (It means no items are present in stack to be removed)


Stack Operation Using Single Link List 

#include<stdio.h>
#include<conio.h>
typedef struct st_stack
{
int data;
struct st_stack *next;
}stack;
/* Function Prototype */
stack* create(int);
void push(stack**,int);
void pop(stack**);
void print(stack*);
void main()
{
stack *start=NULL;
int n,s,opt;

Monday 24 September 2012

Singal Link List Operation using C Language


In computer science, a linked listis a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.
#include<stdio.h>
#include<conio.h>
typedef struct st_tag
{
int data;
struct st_tag *next;
}node;
/* Function Prototype */
node* create(int);
void addbegin(node**,int);
void addlast(node**,int);
void addbefore(node**,int,int);
void addafter(node**,int,int);
void del(int,node**);
void print(node*);
void main()
{
node *start=NULL;
int n,s,opt;