<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4745361936552956375</id><updated>2011-10-15T10:20:37.175-07:00</updated><category term='Data Structure'/><category term='Stack'/><category term='Polish Notation'/><category term='Tower of hanoi'/><title type='text'>Data Structure and Algorithm</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jnudsa.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4745361936552956375/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jnudsa.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rahul Saxena</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4745361936552956375.post-4456916237472586464</id><published>2010-08-19T22:22:00.000-07:00</published><updated>2011-10-15T10:20:37.222-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tower of hanoi'/><category scheme='http://www.blogger.com/atom/ns#' term='Polish Notation'/><category scheme='http://www.blogger.com/atom/ns#' term='Stack'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Structure'/><title type='text'>Data Structure</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: center;"&gt;&lt;span style="color: #cccccc; font-size: 130%;"&gt;&lt;span style="font-family: 'lucida grande';"&gt;-:Array:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-family: times new roman; text-align: left;"&gt;&lt;h3&gt;&lt;span style="font-size: 100%;"&gt;Definition:-&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;em&gt;&lt;/em&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style="font-weight: normal;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;em&gt;An array is simply a  number of memory locations, each of which  can store an item of data of the same  data type and which are all  referenced through the same variable name.&lt;/em&gt;&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style="font-size: 100%;"&gt;How to declare an array in C?&lt;/span&gt;&lt;/h2&gt;The general form of declaring a simple (one dimensional)  array is&lt;br /&gt;&lt;pre&gt;array_type variable_name[array_size];&lt;/pre&gt;in your C/C++ program you can declare an array like&lt;br /&gt;&lt;pre&gt;int Age[10];&lt;/pre&gt;Here array_type declares base type of array which is the  type of  each element in array. In our example array_type is int and its name is   Age. Size of the array is defined by array_size i.e. 10. We can access  array  elements by index, and first item in array is at index 0. First  element of  array is called &lt;span style="font-style: italic;"&gt;lower bound(lb) &lt;/span&gt;and its always 0. Highest  element in array is  called &lt;span style="font-style: italic;"&gt;upper bound(ub)&lt;/span&gt;.If  lb is the smallest index called the lower bound and ub is the largest index called upper bound,then size of array is given by:-&lt;br /&gt;Size of Array= ub-lb+1&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="color: #cccccc; font-size: 130%;"&gt;&lt;span style="font-family: 'lucida grande';"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-:Stack:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;link href="file:///C:%5CDOCUME%7E1%5CGuest%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" style="color: #cccccc;"&gt;&lt;/link&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face  {font-family:Wingdings;  panose-1:5 0 0 0 0 0 0 0 0 0;  mso-font-charset:2;  mso-generic-font-family:auto;  mso-font-pitch:variable;  mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face  {font-family:CMR12;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;} @font-face  {font-family:CMTI12;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;} @font-face  {font-family:CMBX12;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;} @font-face  {font-family:CMMI12;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;} @font-face  {font-family:CMSY10;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;} @font-face  {font-family:CMSY6;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;} @font-face  {font-family:CMSS12;  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:0;  mso-generic-font-family:auto;  mso-font-format:other;  mso-font-pitch:auto;  mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;}  /* List Definitions */  @list l0  {mso-list-id:311980732;  mso-list-type:hybrid;  mso-list-template-ids:-366206952 67698699 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:.5in;  mso-level-number-position:left;  text-indent:-.25in;  font-family:Wingdings;} ol  {margin-bottom:0in;} ul  {margin-bottom:0in;} --&gt; &lt;/style&gt;  &lt;br /&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;b&gt;Stack:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;Stack is finite sequence of same type defined by the two end of referred to as &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;top &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;and &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;bottom&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;. Where bottom is fixed, and all stack operations are done at top end. In a stack, the element deleted from the set is most recently inserted; the stack implements a last-in-first-out or &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;LIFO &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;policy.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;b&gt;Stack ADT:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;Stack &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;S &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;is finite sequence of same type and all operations are carried out at one end called &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;top&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;Operations on Stack&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;1. &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Push&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;(&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;item x, Stack S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;) &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;! &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Stack S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;0 &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;; Insert an item &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;x &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;into top of the stack and returns new stack &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;0 &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;with &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;top &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;pointing to the &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;x&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;2. &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Pop&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;(&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Stack S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;) &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;! &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Stack S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;0 &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;; Delete the item &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;x &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;pointed by the the &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;top &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;of the stack and returns new stack &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;0 &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;with &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;top &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;is pointing to the item next down to the deleted item.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;3. &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;isEmpty&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;(&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Stack S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;) &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;! &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;TRUE/FALSE;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; Returns TRUE when &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;S &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;is empty else FALSE.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;4. isFull(Stack S) ! &lt;span style="font-size: 100%;"&gt;TRUE/FALSE;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; Returns TRUE when &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;S &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;is Full else FALSE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;4. &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Top&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;(&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Stack S&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;) &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;! &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Returns top item;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                                                &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;b&gt;Representation of A Stack Using Array:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;To implement a stack we need a variable, called top that holds the index of the top element of the stack and an array to hold the elements of the stack. For example the size of Stack is 20 (MAXSTK=20) and stack holds integers type values.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt; &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;It may be developed using following code:-&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;            &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                        &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;#define MAXSTK=20;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;            &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                            &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;typedef struct&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                                 &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                                               &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;int top;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                                               &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;int elements[MAXSTK];&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;                      &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;} stack;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;We have defined our own data type named stack, which is structure and whose first element top will be used as an index to the top elements, and an array elements of size MAXSTK whose elements are of integer type, to holds the elements of the stack.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;If top=0 or top=NULL then stack is empty (means there is no item in STACK) and in this case we can not traverse or delete item form stack. If we try to do something (delete or traverse) then this case known as Underflow.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;If top=MAXSTK then stack is full (means there is no space for new item in STACK) and in this case we can not insert item in stack. If we try to insert item in Stack then this case known as Overflow.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;Figure:---------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;b&gt;Representation of A Stack Using Linked List:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;A stack represented using a linked list is also known as &lt;i&gt;linked stack&lt;/i&gt;. The array-based representation of stack suffers from following limitation.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style="font-family: Wingdings; font-size: 100%;"&gt;Ø      &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Size of the stack must be known in advance.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-family: Wingdings; font-size: 100%;"&gt;Ø      &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;We may come across situation when an attempt to push an element causes overflow, it is always possible to push an element onto stack.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;Therefore, representing stack as an array prohibits the growth of stack beyond the finite number elements. The linked list representation allows a stack to grow to a limit of the computer’s memory.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;Following Code helps to develop Stack using linked list:-&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;                  &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;typedef&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;  &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;struct nodetype&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;{ &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in; text-indent: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;int info’&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;      &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;struct nodeType *next;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;} stack;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;We have defined our own data type named stack, which is a self-referential structure and whose first element info holds the elements of the stack and the second element next holds the address of the elements under it in the stack.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;Eg.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;Figure:---------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.25in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;b&gt;Applications of Stack:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;b&gt;A) Parenthesis matching&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;The dynamic structure stack can be used checking for balanced parenthesis in an expression. For example expression given below &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;(1+(3&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;×&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;5)&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;-&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;(2+((4&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;-&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;2)&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;×&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;8)+100)&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;-&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;22&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;×&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;(2+4)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;We can check both left and right parenthesis is balanced or not using stack structure. The following pseudo-code explains how it can be done.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;    Check parenthesis (expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;    Step:1. while&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; (not end of expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;    Step:2. &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;for each character in expression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; text-indent: 0.5in;"&gt;&lt;span style="font-size: 100%;"&gt;     if(character = ’(’ ) then&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; text-indent: 0.5in;"&gt;&lt;span style="font-size: 100%;"&gt;    push(’(’,s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; text-indent: 0.5in;"&gt;&lt;span style="font-size: 100%;"&gt;    if(character=’)’) then&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; text-indent: 0.5in;"&gt;&lt;span style="font-size: 100%;"&gt;    pop(s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;   [End of  Step 2 For loop]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;   [&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;End of while loop]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;   Step:3. Exit or Return&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;Algorithm above works as for every open parenthesis push them into the stack and closing parenthesis pop from the stack. Finally the empty stack shows the parenthesis balanced expression.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;link href="file:///C:%5CDOCUME%7E1%5CGuest%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List"&gt;&lt;/link&gt;&lt;link href="file:///C:%5CDOCUME%7E1%5CGuest%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso" rel="Edit-Time-Data"&gt;&lt;/link&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face  {font-family:Wingdings;  panose-1:5 0 0 0 0 0 0 0 0 0;  mso-font-charset:2;  mso-generic-font-family:auto;  mso-font-pitch:variable;  mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face  {font-family:Verdana;  panose-1:2 11 6 4 3 5 4 4 2 4;  mso-font-charset:0;  mso-generic-font-family:swiss;  mso-font-pitch:variable;  mso-font-signature:536871559 0 0 0 415 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";} code  {font-family:"Courier New";  mso-ascii-font-family:"Courier New";  mso-fareast-font-family:"Times New Roman";  mso-hansi-font-family:"Courier New";  mso-bidi-font-family:"Courier New";} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;}  /* List Definitions */  @list l0  {mso-list-id:986858954;  mso-list-template-ids:479351846;} @list l0:level1  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:.5in;  mso-level-number-position:left;  text-indent:-.25in;  mso-ansi-font-size:10.0pt;  font-family:Wingdings;} @list l0:level2  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:1.0in;  mso-level-number-position:left;  text-indent:-.25in;  mso-ansi-font-size:10.0pt;  font-family:Wingdings;} @list l1  {mso-list-id:1165049485;  mso-list-template-ids:-1335736726;} @list l1:level1  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:.5in;  mso-level-number-position:left;  text-indent:-.25in;  mso-ansi-font-size:10.0pt;  font-family:Symbol;} ol  {margin-bottom:0in;} ul  {margin-bottom:0in;} --&gt; &lt;/style&gt;  &lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;b&gt;b) P&lt;span style="font-size: 100%;"&gt;olish Notation:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;A notation system for digital-computer or calculator logic in which there are no parenthetical expressions and each operator is a binary or unary operator in the sense that it operates on not more than two operands. Also known as Lukasiewicz notation; parenthesis-free notation. The version of this notation in which operators precede the operands with which they are associated. Also known as prefix notation.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;span style="font-size: 85%;"&gt;&lt;b&gt;&lt;span style="font-family: Verdana;"&gt;Infix Expression :&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Verdana; font-size: 100%;"&gt;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Any expression in the standard form like "2*3-4/5" is an Infix(Inorder) expression.&lt;/span&gt;&lt;span style="font-family: Verdana; font-size: 100%;"&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;b&gt;Postfix Expression :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;The Postfix(Postorder) form of the above expression is "23*45/-".&lt;/span&gt;&lt;span style="font-family: Verdana; font-size: 100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;b&gt;Infix to Postfix Conversion :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;In normal algebra we use the infix notation like a+b*c. The corresponding postfix notation is abc*+. The algorithm for the conversion is as follows : &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style="color: white;" type="square"&gt;&lt;li class="MsoNormal" style="color: black;"&gt;&lt;span style="font-size: 100%;"&gt;Scan the &lt;code&gt;Infix string&lt;/code&gt; from left      to right.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: black;"&gt;&lt;span style="font-size: 100%;"&gt;Initialize an empty stack.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: black;"&gt;&lt;span style="font-size: 100%;"&gt;If the scanned character is an operand, add it to the &lt;code&gt;Postfix string&lt;/code&gt;. If the scanned character      is an operator and if the &lt;code&gt;stack&lt;/code&gt;      is empty &lt;code&gt;Push&lt;/code&gt; the character to &lt;code&gt;stack&lt;/code&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;ul type="square"&gt;&lt;li class="MsoNormal" style="color: black;"&gt;&lt;span style="font-size: 100%;"&gt;If the scanned character is an Operand and the &lt;code&gt;stack&lt;/code&gt; is not empty, compare the       precedence of the character with the element on top of the &lt;code&gt;stack&lt;/code&gt; (&lt;code&gt;topStack&lt;/code&gt;).       If &lt;code&gt;topStack&lt;/code&gt; has higher       precedence over the scanned character &lt;code&gt;Pop&lt;/code&gt;       the stack else &lt;code&gt;Push&lt;/code&gt; the scanned       character to &lt;code&gt;stack&lt;/code&gt;. Repeat this       step as long as &lt;code&gt;stack&lt;/code&gt; is not empty       and &lt;code&gt;topStack&lt;/code&gt; has precedence over       the character.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="MsoNormal" style="color: #cccccc; margin-left: 0.5in;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="color: white;"&gt;Repeat this step till all the characters are scanned.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style="color: #cccccc;" type="square"&gt;&lt;li class="MsoNormal" style="color: black;"&gt;&lt;span style="font-size: 100%;"&gt;(After all characters are scanned, we have to add any character      that the &lt;code&gt;stack&lt;/code&gt; may have to the &lt;code&gt;Postfix string&lt;/code&gt;.) If &lt;code&gt;stack&lt;/code&gt; is not empty add &lt;code&gt;topStack&lt;/code&gt; to &lt;code&gt;Postfix      string&lt;/code&gt; and &lt;code&gt;Pop&lt;/code&gt;      the &lt;code&gt;stack&lt;/code&gt;. Repeat this step as      long as stack is not empty.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: black;"&gt;&lt;span style="font-size: 100%;"&gt;Return the &lt;code&gt;Postfix string&lt;/code&gt;.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="color: #cccccc; font-weight: bold;"&gt;Queue&lt;/span&gt;&lt;br /&gt;&lt;link href="file:///C:%5CDOCUME%7E1%5CGuest%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" style="color: #cccccc;"&gt;&lt;/link&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;} --&gt; &lt;/style&gt;  &lt;br /&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;A &lt;i&gt;queue&lt;/i&gt; is an ordered list in which all insertions take place at one end, the &lt;i&gt;rear&lt;/i&gt;, while all deletions take place at the other end, the &lt;i&gt;front&lt;/i&gt;.&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;link href="file:///C:%5CDOCUME%7E1%5CGuest%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C03%5Cclip_filelist.xml" rel="File-List"&gt;&lt;/link&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;} --&gt; &lt;/style&gt;  &lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;b&gt;Representation of A Queue Using Array:-&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;To implement a queue we need two variables, called front and rear, that holds the index of the first and last element of the queue and an array to hold the elements of the queue. For example the size of Queue is 20 (MAXQ=20) and queue holds integers type values.&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;It may be developed using following code:-&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;#define MAXQ=20;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;typedef struct&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;{&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;int front,rear;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;int elements[MAXQ];&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;} queue;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;We have defined our own data type named queue, which is structure and the first element of the structure is front, that  will be used to hold the index of first element of the queue.The second element of the structure is rear, and it will be used to hold the last element of the queue.An array named &lt;i&gt;elements&lt;/i&gt; of size MAXFQ whose elements are of integer type, to holds the elements of the queue.&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; font-weight: bold;"&gt;Algorithm to insert an element in Queue:-&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;QInsert(Queue,Front,Rear,N,Item)&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step1.[Check for full ?]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;If Front=1 and Rear=N&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;or If  Front= Rear+1 then&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;WRITE Overflow and return.&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step2.[Calculate the new value of Rear]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;If Front = Null then [Queue initially Empty]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Set Front=1 and Rear=1&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Else if Rear=N then&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Set Rear=1&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Else&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Set Rear= Rear+1&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;[End of If Structure]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step3. Set Queue[Rear]=ITEM&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step4. Return or Exit&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc; font-weight: bold;"&gt;Algorithm to Delete element from  Queue:-&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;QDelete(Queue,Front,Rear,N,Item)&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step1.[Check for Null ?]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;If Front=NULL then&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;WRITE Overflow and return.&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step2.[Save Element]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Item=Queue[Front]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step3.[Calculate the new value of  Front]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;If Front = Rear then [Queue has only one element]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Set Front=Null and Rear=Null&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Else if Front=N then&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Set Front=1&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Else&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Set Front= Front+1&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;[End of If Structure]&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="color: #cccccc;"&gt;Step4. Return or Exit&lt;/div&gt;&lt;div style="color: #cccccc;"&gt;&lt;/div&gt;&lt;br /&gt;-------------------------------------------------------------------------------------------&lt;br /&gt;Thanks..&lt;br /&gt;Rahul Saxena&lt;br /&gt;www.facebook.com/rahulsaxenajpr&lt;br /&gt;www.twitter.com/rahulsaxenajpr&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4745361936552956375-4456916237472586464?l=jnudsa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jnudsa.blogspot.com/feeds/4456916237472586464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jnudsa.blogspot.com/2010/08/stackdata-structurepolish-notationtower.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4745361936552956375/posts/default/4456916237472586464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4745361936552956375/posts/default/4456916237472586464'/><link rel='alternate' type='text/html' href='http://jnudsa.blogspot.com/2010/08/stackdata-structurepolish-notationtower.html' title='Data Structure'/><author><name>Rahul Saxena</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
