Category Archives: data structure

  • 0
while loop

While Loop in C#

The while loop will check a condition and then continue to execute block of code as long as the condition  evaluates to a Boolean value of true. Its  syntax is as follow: while (<Boolean expression>) {<statement>} .The statements can be any valid in C# statements the Boolean expression is evaluate before any code in the following block has executed.

 

EXP –

 

Class While Loop

{

Public static void main ()

{

Int myInt  = 0;

While (my Int<10)

{

Console Write “{0}”,myint);

myInt++;

}

Console Write Line ();

}

}




  • 0
Deletion operation

Deletion Operation

Category : data structure

Before deletion operation we must check for emptiness of the queue. For the contiotion of the empty queue. when queue is empty.

Example-

 

Front ==+1

It also called queue underflow condition.

Int delete”(queue*qp)

{

Int   x;

If ( qp – front = =qp-rear+1)

Printf (“queue underflow condition “);

Else

{

X=qp- else [qp – front ++];

Return  x;

}

}


  • 0

Addition operation of Queue

Category : data structure

Before addiotion  opration we must check for fullness of the queue,the maximum valid value of rear pointer is max-1 if rear get this value the queue is full .it is also called queue overflow condition .

 

Void Add (queue*qp,int x)

{

If  (qp-rear==max-1)

Printf(“queue overflow”);

Else

Qp-else(++qp-rear)=x;

}


  • 0
drawback queue

Drawback of Queue

Category : data structure

Queue has drawback that, after certain operations, we cannot insert item in the even if there is space in the Queue.
Moves to words the end of the array ,so it that rear will reach at the minimum limit of the array and there may be space before front but no additional can be done at the front end because it will destroy (FIFO) first in first out nature of queue.
This situation there is no space after rear hence no additional can be done even there is no empty space in the queue.
Solution
There are two solutions to the above problem.
Maintaining linearity of the queue .
Queue Declaration
# define max 8
Start queue
{
Int front rear;
Int ele [max];
};


  • 0
Queue

What is Queue

Category : data structure

Queue is a liner list of element in which deletion can take place only at on end, called front and insertion can take place only at one end, called rear. It uses first in first out (FIFO) policy. A queue can be considered as a sequence of item.

A queue has following essential property.

A- A container of items , that contains queue elements.
B- A pointer front, that point the first element of the queue.
C- A pointer rear ,that point the last element of the queue.

1- There is an add operation. It means to add a item in the queue. Addition is only at the rear end of the queue.
2- There is an deletion operation it means to remove an item from the queue. deletion is only at the front end of the queue.
3- Only the end items (front –rear) are visible and accessible .


  • 0
featured-stack

What is Stack

Category : data structure

Stack is an ordered collection of item into which new items may inserted and from which items may be deleted at one end , called the top of stack. It holds last in first out (LIFO) method.