<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>data structure Archives -</title>
	<atom:link href="https://mitindia.in/tag/data-structure/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/data-structure/</link>
	<description></description>
	<lastBuildDate>Sat, 31 Dec 2016 06:05:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>data structure Archives -</title>
	<link>https://mitindia.in/tag/data-structure/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Storage Management</title>
		<link>https://mitindia.in/storage-management/</link>
					<comments>https://mitindia.in/storage-management/#comments</comments>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Tue, 27 Dec 2016 04:52:03 +0000</pubDate>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data storage management]]></category>
		<category><![CDATA[data structure]]></category>
		<category><![CDATA[storage management]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=657</guid>

					<description><![CDATA[<p>Storage Management [Data Structure] In case of large voluminous data, every byte of space is important and plays a major factor in determining the cost of the resources. Programs that are run on computer systems will use variables that are stored in main memory for manipulation of data. When a variable is defined, a calculated [&#8230;]</p>
<p>The post <a href="https://mitindia.in/storage-management/">Storage Management</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><span style="color: #ff0000;">Storage Management [Data Structure]</span></h2>
<hr />
<p><strong>In case of large voluminous data, every byte of space is important and plays a major factor in determining the cost of the resources.</strong></p>
<p><strong>Programs that are run on computer systems will use variables that are stored in main memory for manipulation of data.</strong></p>
<p><strong>When a variable is defined, a calculated amount of contiguous space is allocated to the variable, depending on its type.</strong></p>
<p><img fetchpriority="high" decoding="async" class="size-medium wp-image-658 alignright" src="http://www.mitindia.in/wp-content/uploads/2016/12/sm-300x194.jpg" alt="Storage Management " width="300" height="194" srcset="https://mitindia.in/wp-content/uploads/2016/12/sm-300x194.jpg 300w, https://mitindia.in/wp-content/uploads/2016/12/sm-270x175.jpg 270w, https://mitindia.in/wp-content/uploads/2016/12/sm.jpg 525w" sizes="(max-width: 300px) 100vw, 300px" /><br />
<em><strong>Compaction</strong></em>:- is the process of eliminating waste spaces so that there is no block of memory unusable.</p>
<p><strong> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- mylink -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-1696390399604457"
     data-ad-slot="7690934410"
     data-ad-format="link"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></strong></p>
<p><em><strong>Disadvantages:</strong></em><br />
The programs performing operations on memory are suspended while compaction is performed</p>
<p><strong>Reallocation Method</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<strong><em>First fit method</em></strong>: In the first-fit method, each block from the beginning is searched for a free block. The requested block of memory is allocated in the first possible free block.</p>
<p>freeblock *alloc,*y;<br />
x = fbhead;<br />
y = NULL;<br />
alloc = NULL;<br />
while( (x != NULL) &amp;&amp; (x-&gt;size &lt; n) )<br />
{<br />
y = x;<br />
x = x-&gt;next;<br />
}<br />
if( x != NULL )<br />
{ s = x-&gt;size;<br />
alloc = x + s &#8211; n;<br />
if( s == n )<br />
if( y == NULL )<br />
fbhead = x-&gt;next;<br />
else<br />
y-&gt;next = x-&gt;next;<br />
else<br />
x-&gt;size = s &#8211; n;<br />
}</p>
<p><strong><em>Best fit method</em></strong>: In the best-fit method, the entire list of free blocks is traversed and the smallest free block where allocation can be done is found out.</p>
<p>freeblock *alloc,*y;<br />
x = fbhead;<br />
y = NULL;<br />
z = NULL;<br />
alloc = NULL;<br />
bz = NULL;<br />
zsize = MAXMEM + 1;<br />
if( z != NULL )<br />
{<br />
alloc = z + zsize &#8211; n;<br />
if( zsize == n )<br />
if( bz == NULL )<br />
fbhead = z-&gt;next;<br />
else<br />
bz-&gt;next = z-&gt;next;<br />
else<br />
z-&gt;size = zsize &#8211; n;<br />
}</p>
<p><em><strong>Garbage collection</strong> </em><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Two phases of garbage collection are:<br />
<strong><em>-Marking phase</em></strong><br />
<strong><em>-Collection phase</em></strong></p>
<p><strong><em>Marking phase</em></strong>: A node is marked if it can be accessed from a given pointer. The nodes in the memory are sequentially checked.</p>
<p>If there are any nodes that can be accessed<br />
from the current node, then the nodes are all marked.<br />
In case the second node’s address is less than the<br />
previous node, the process continues from the second<br />
node. The process continues until all nodes are marked.</p>
<p>Node structure created for the example of Marking<br />
Phase</p>
<p>struct listnode<br />
{<br />
int info;<br />
int mark;<br />
int next;<br />
}list [50];<br />
int arptr[10];<br />
for( i=0; i&lt;10 ; i++)<br />
list[ arptr[i] ].mark = TRUE;<br />
i = 1;<br />
while( i &lt; 50 )<br />
{<br />
k = i + 1;<br />
if( list[i].mark )<br />
{<br />
if( list[ list[i].next].mark != TRUE )<br />
{<br />
list[ list[i].next].mark = TRUE;<br />
if( list[i].next &lt; k )<br />
k = list[i].next;<br />
}<br />
}<br />
i = k;<br />
}</p>
<p><strong><em>Collection phase</em></strong>: After the required nodes are marked, the collection phase begins. In the collection phase all the nodes that are not marked are added to a separate list. Then the space allocated for these nodes are reclaimed and assigned to newer nodes.</p>
<p>for( i = 0; i&lt; 50; i++ )<br />
{<br />
if( list[i].mark != TRUE )<br />
{<br />
list[i].next = glist;<br />
glist = i;<br />
}<br />
list[i].mark = FALSE;<br />
}<br />
<strong><em>The Big O Notation</em></strong>: is a popular mathematical tool used to calculate time complexities for different algorithms.<br />
The Big O notation is represented as:<br />
f(n) = O( g((n) )<br />
f(n) &#8211; the computing time of the algorithm when<br />
it is run for an input size of n.<br />
g(n) &#8211; standard function, whose value is<br />
determined prior to the execution of the algorithm.</p>
<p><em><strong>Standard functions</strong></em><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
n: An algorithm having a time complexity of order n, is said to be linear. The time taken is said to be linearly proportional to n.<br />
n2: The algorithm is said to be quadratic if the time complexity is of order n2.<br />
n3: If the time complexity of an algorithm is of order n3, then the algorithm is said to be cubic.<br />
Log n: If the time complexity of an algorithm matches the function log n, then the algorithm is said to be logarithmic.<br />
nlogn: If the time complexity of an algorithm is n log n, then it can be said that the algorithm solves a problem by breaking it into smaller sub-problems and solving them independently.</p>
<h3><strong><em>Conclusion:</em></strong><br />
When a variable is defined, a calculated amount of contiguous space is allocated to the variable<br />
Collecting unused space towards on one end in memory is called compaction<br />
A pointer is used to store the first location of the free block initially<br />
The disadvantage of compaction is the programs performing operations on memory are suspended, while compaction is performed</h3>
<h3>A linear list is used to keep track of list of free blocks<br />
The process of detecting unused nodes and collecting them together is known as Garbage Collection<br />
Garbage collection is done in two phases – marking phase and collection phase<br />
The garbage collection routine is called when there are only few spaces left in memory</h3>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fstorage-management%2F&amp;linkname=Storage%20Management" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fstorage-management%2F&amp;linkname=Storage%20Management" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fstorage-management%2F&#038;title=Storage%20Management" data-a2a-url="https://mitindia.in/storage-management/" data-a2a-title="Storage Management"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/storage-management/">Storage Management</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mitindia.in/storage-management/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Searching techniques</title>
		<link>https://mitindia.in/searching-techniques/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Fri, 16 Dec 2016 12:12:59 +0000</pubDate>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data structure]]></category>
		<category><![CDATA[searching]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=647</guid>

					<description><![CDATA[<p>Searching Techniques Files and Records: A record is a collection of related information and Collection of records is called a file. Ordered and unordered &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; Unordered&#8211; There is no relation between the records Ordered –The keys are ordered in a specific fashion to enhance searching. Keys: Specific field in a record to differentiate each record [&#8230;]</p>
<p>The post <a href="https://mitindia.in/searching-techniques/">Searching techniques</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Searching Techniques</h3>
<hr />
<p>Files and Records: A record is a collection of related information and Collection of records is called a file.</p>
<figure id="attachment_648" aria-describedby="caption-attachment-648" style="width: 300px" class="wp-caption alignright"><img decoding="async" class="size-medium wp-image-648" src="http://www.mitindia.in/wp-content/uploads/2016/12/st-300x225.png" alt="searching technique" width="300" height="225" srcset="https://mitindia.in/wp-content/uploads/2016/12/st-300x225.png 300w, https://mitindia.in/wp-content/uploads/2016/12/st-768x576.png 768w, https://mitindia.in/wp-content/uploads/2016/12/st.png 1024w, https://mitindia.in/wp-content/uploads/2016/12/st-233x175.png 233w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-648" class="wp-caption-text">searching technique</figcaption></figure>
<p><strong>Ordered and unordered</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<em>Unordered</em>&#8211; There is no relation between the records</p>
<p><strong> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- mylink -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-1696390399604457"
     data-ad-slot="7690934410"
     data-ad-format="link"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></strong></p>
<p><em>Ordered</em> –The keys are ordered in a specific fashion to enhance searching.</p>
<p><em>Keys</em>: Specific field in a record to differentiate each record</p>
<blockquote><p><strong>Internal and External searches</strong></p></blockquote>
<p><em><strong>1. Internal search</strong></em> –When the searching is performed the entire database or table is copied to the main memory.</p>
<p><strong><em>2. External search</em></strong>&#8211; When only a part of database is copied to the main memory due to huge size of database.</p>
<p><em><strong>Sequential search</strong></em><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Simple and easiest method to implement.<br />
The key field in each record is compared with the given key value starting from the first record. If there is a match the index of the key field is returned.</p>
<p>int seqSearch( int key, int array[ ], int n )<br />
{</p>
<p>for ( int i=0; i&lt;n; i++ )<br />
if ( array[i] == key )<br />
return i;<br />
return -1;<br />
}<br />
<strong><em>Sequential search on a sorted array</em></strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Sequential search if applied on a sorted array reduces the number of comparisons if some modifications are made.</p>
<p>This is faster than the ordinary sequential searches.</p>
<p><strong>Sequential search on a sorted array</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
int seqSearchsorted( int key, int array[ ], int n )<br />
{<br />
for ( int i=0; i&lt;n; i++ )<br />
{<br />
if ( array[i] == key )<br />
return i;<br />
else if( array[i] &gt; key )<br />
return -1;<br />
}<br />
}</p>
<p><strong>Indexed sequential search</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Procedure: The index table and the records must be sorted on the key. Not all keys are indexed in to the index table. The record table is divided equally and the key in the record, in the beginning of each division along with a pointer to that record is entered in to the index table.</p>
<p>int indseqSearch( int key, int indexsize, int indtable[ ], int *indpointer[ ] int array[ ] )<br />
{<br />
int llimit,hlimit;<br />
for( int i=0; indtable[i] &lt;= key &amp;&amp; i&lt;indexsize; i++);<br />
llimit = (i==0) ? 0 : indpointer[i-1];<br />
hlimit = (i==indexsize) ? n-1 : indpointer[i-1];<br />
for( int llimit; j &lt;= hlimit &amp;&amp; array[j] != key; j++);<br />
return ( ( j &gt; hlimit ) ? -1 : j );<br />
}<br />
<strong>Advantages: Fastest search among all</strong></p>
<p><strong>Disadvantages: Uses an extra table to store indexes,which may consume spaces for large databases.</strong></p>
<p><em><strong>Binary search Technique</strong></em><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Procedure: The given sorted records are divided into two halves. The key is first compared with the key field of the middle record. If a match is found, the key index is returned. If it does not match, then required key must be either in the lower or upper half. If the key is less than the key field of the middle record, the key is searched in the lower half otherwise it is checked in the upper half.</p>
<p>int binsearch(int records[], int key, int llimit, int hlimit)<br />
{<br />
int middle;<br />
if( llimit &gt; hlimit)<br />
return (-1);<br />
middle = (llimit + hlimit) / 2;<br />
if( key == records[middle] )<br />
return (middle);<br />
else<br />
{<br />
if( key &lt; records[middle] )<br />
return (binsearch( records, key , llimit ,middle &#8211; 1) );<br />
else<br />
return (binsearch( records, key, middle + 1, hlimit) );<br />
}<br />
}</p>
<p>Advantages of Binary search: Most effective technique applied on sorted arrays.</p>
<p>Disadvantages: Cannot be implemented on unsorted array.</p>
<p><em><strong>Hashing</strong></em>: Process to develop a hash function to determine where the records can be stored<br />
Example : r=h(k)<br />
h(k)- Hash function<br />
k &#8211; Key<br />
r &#8211; an offset when added to the starting address of the block of memory, where the records are to be stored, yields the particular record.</p>
<p>Properties of Hashing: Any hash function developed should return a unique value Must be able to minimize the number of collisions.</p>
<p>Hash collision: If the hash function returns the same value for two different records it is called hash collisions.</p>
<p>Mid square method: In this method, the key is squared first. Then required number of digits is chosen from the middle of the squared number. The number of digits to be chosen depends on the size of the record.</p>
<p><strong><em>Resolving Hash Collisions</em></strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Methods for minimizing the collisions<br />
Open address method<br />
Method of finding the next available space to store the record<br />
Also known as rehashing</p>
<p>The two types of probing are<br />
<strong><em>Linear Probing</em></strong><br />
<strong><em>Quadratic probing</em></strong></p>
<p>Double Hashing: Solves the problem of double clustering<br />
Two hashing methods used h1(k) and h2(k)-One is primary and the other is secondary.</p>
<p><a href="http://www.mitindia.in/2016/12/14/sorting-technique/" target="_blank">click here for sorting technique</a></p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fsearching-techniques%2F&amp;linkname=Searching%20techniques" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fsearching-techniques%2F&amp;linkname=Searching%20techniques" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fsearching-techniques%2F&#038;title=Searching%20techniques" data-a2a-url="https://mitindia.in/searching-techniques/" data-a2a-title="Searching techniques"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/searching-techniques/">Searching techniques</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Data structure &#8211; Advanced Trees</title>
		<link>https://mitindia.in/data-structure-advanced-trees/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Thu, 01 Dec 2016 05:44:13 +0000</pubDate>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[advanced trees]]></category>
		<category><![CDATA[data insertion]]></category>
		<category><![CDATA[data structure]]></category>
		<category><![CDATA[trees]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=621</guid>

					<description><![CDATA[<p>Advanced Trees &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Definition of an AVL tree: An AVL tree is a binary search tree which has the following properties: 1. The sub-trees of every node differ in height by at most one. 2. Every sub-tree is an AVL tree. Named after their inventors, Adelson-Velskii and Landis, they were the first dynamically balanced trees [&#8230;]</p>
<p>The post <a href="https://mitindia.in/data-structure-advanced-trees/">Data structure &#8211; Advanced Trees</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1><span style="color: #993300;">Advanced Trees</span><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</h1>
<p>Definition of an AVL tree: An AVL tree is a binary search tree which has the following properties:</p>
<p>1. The sub-trees of every node differ in height by at most one.<br />
2. Every sub-tree is an AVL tree.</p>
<p>Named after their inventors, Adelson-Velskii and Landis, they were the first dynamically balanced trees to be proposed.</p>
<p><strong> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- mylink -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-1696390399604457"
     data-ad-slot="7690934410"
     data-ad-format="link"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></strong></p>
<h2><strong>Features of AVL Trees</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</h2>
<p style="text-align: justify;">AVL Trees are derived from binary search trees by applying one condition; the difference of height between the left and right sub-trees should not exceed 1.<br />
These types of binary trees are also called Balanced binary trees.</p>
<p>The balance factor can have values of –1, 0 and 1. If the balance factor holds any other values, then it is not considered as an AVL tree. The three values given above represent different conditions of AVL trees. They are –<br />
1. balance = -1: the height of the left sub-tree of the current node is less than its right sub-tree by 1.<br />
2. balance = 0: the heights of the left and right sub-trees of the current node are equal<br />
3. balance = 1: the height of the left sub-tree is one more than the right sub-tree</p>
<p><strong>Representation of AVL Trees</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
struct AVL<br />
{<br />
struct AVL *left;<br />
int value;<br />
struct AVL *right;<br />
int balance;<br />
};<br />
<strong>Insertion of a Node</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Inserting a node in an AVL tree is similar to the binary search tree.</p>
<p>To balance a tree, an operation called rotation is performed<br />
Inserting a node may change the balancing factor of other nodes and thus may not satisfy the conditions of the AVL tree.</p>
<p>To balance a tree, an operation called rotation is performed.<br />
To rotate the tree about a node is to move the nodes either left or right so that the inorder traversal remains the same.<br />
<strong>Deletion of a node</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
The deletion performed on a node in AVL tree is the same as that of the deletion process of the Binary search tree.</p>
<p>First the node to be deleted is searched using the binary search method.</p>
<p>The node is deleted and other nodes are adjusted to maintain the inorder traversal.</p>
<p>After the node is deleted, balancing operation is performed which is the same as of that done during the insertion operation.<br />
<strong>Definition of a B tree</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
A B-tree is a data structure that maintains an ordered set of data and allows efficient operations to find, delete, insert, and browse the data. In this discussion, each piece of data stored in a B-tree will be called a &#8220;key&#8221;, because each key is unique and can occur in the B-tree in only one location</p>
<p><strong>Representation of B Trees</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
struct Bnode<br />
{<br />
int n;<br />
int value[MAX + 1];<br />
struct Bnode *child[MAX + 1];<br />
};<br />
<strong>Operations on B-Trees</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
When the tree is large and stored in secondary storage medium, the searching operation may consume time.</p>
<p>One way of reducing the time is to take up many nodes for comparison. As a result Multi-way search trees were developed.</p>
<p>1. Insertion operation in B-tree</p>
<p>2. Deletion process in B-tree</p>
<p>Insertion operation in B-tree: To insert a value in a B-tree, the node in the tree after which it can be inserted is searched first. Once the node is found, insertion process begins.</p>
<p>Deletion operation in B-tree: To delete a node, first the value to be deleted is searched. Once the node, which contains the value, is found the deletion process starts. There are some conditions that has to be taken care after deleting a node.<br />
<strong>Conditions on Deletions</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
When the number of values in the current node is greater or equal to the minimum number the node has to hold. In this case, the deletion of the node does not violate the conditions for the B-tree</p>
<p>When the number of values in the current node is less than the minimum number the node has to hold. Here the tree has to be adjusted so that the conditions for the B-tree is not violated.</p>
<p><span style="color: #000000;"><a style="color: #000000;" href="http://www.mitindia.in/2016/11/24/trees-data-structure/">Introduction to Trees [data structure]</a></span></p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fdata-structure-advanced-trees%2F&amp;linkname=Data%20structure%20%E2%80%93%20Advanced%20Trees" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fdata-structure-advanced-trees%2F&amp;linkname=Data%20structure%20%E2%80%93%20Advanced%20Trees" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fdata-structure-advanced-trees%2F&#038;title=Data%20structure%20%E2%80%93%20Advanced%20Trees" data-a2a-url="https://mitindia.in/data-structure-advanced-trees/" data-a2a-title="Data structure – Advanced Trees"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/data-structure-advanced-trees/">Data structure &#8211; Advanced Trees</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>List-Stack-Queues</title>
		<link>https://mitindia.in/list-stack-queues/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Tue, 22 Nov 2016 11:26:21 +0000</pubDate>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data structure]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[queues]]></category>
		<category><![CDATA[stack]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=608</guid>

					<description><![CDATA[<p>Data Structure : Linked List, Stack and queues Creating and Managing Linked Lists &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; List generally refers to a sequential organization of items like an array. Array allocates memory of size, which we determine in the beginning itself. Later this can be used for storing values. A linked list is a chain of structures in [&#8230;]</p>
<p>The post <a href="https://mitindia.in/list-stack-queues/">List-Stack-Queues</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Data Structure : Linked List, Stack and queues</h2>
<h4>Creating and Managing Linked Lists<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
List generally refers to a sequential organization of items like an array.<br />
Array allocates memory of size, which we determine in the beginning itself. Later this can be used for storing values.<br />
A linked list is a chain of structures in memory. These structures contain data as well as a pointer to the next logical structure in the list</h4>
<p>struct list {<br />
datatype data;<br />
………<br />
………<br />
struct list *next;<br />
/* next is a pointer of type struct list, pointing to the next logical structure in the list */<br />
};<br />
Advantages of Linked Lists<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Linked lists have several advantages over arrays-<br />
One does not have to decide on the number of items in the linked list.</p>
<p>This is because memory can be allocated dynamically as and when a node is added to the list.</p>
<p>Types of Linked Lists<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
There are several types of linked lists, two of which will be discussed in this chapter –<br />
Singly Linked List – each node contains the address of the next node in the list. The start node points to the first node in the list.</p>
<p>Doubly Linked List – each node contains the address of the next node as well as the previous node in the list. The start node points to the first node in the list whereas the end node points to the last node.</p>
<p>Singly Linked Lists<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
The operations that can be performed on singly linked lists are listed below –<br />
Creation of a list<br />
Insertion of nodes<br />
Traversal of the list<br />
Search of a specific node<br />
Modification of a node<br />
Deletion of a node<br />
Insertion in a list<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Assuming that a node has to be inserted at the beginning of an existing linked list, the following steps has to be performed :<br />
Initialize, allocate memory and accept data into a node, let this node be called new.<br />
Make new’s next point to what start is pointing to, i.e., the first node in the list. This can be done by new-&gt;next = start;<br />
Make start point to new (i.e., make it the first node). This can be done by start=new;</p>
<p>Creation of a Singly Linked List<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
This involves two steps :<br />
Creating a new node (allocate memory for the node and accept data into it).<br />
Storing the address of the node created in start. start=new;</p>
<p>Traversing a Linked List<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
This involves the following steps:<br />
Set list_ptr to start (assume that list_ptr is a pointer declared of type struct list).<br />
Print the information part of the node.<br />
Advance the pointer so that it points to the next node. This can be done by list_ptr=list_ptr-&gt;next;<br />
Repeat steps 2 and 3 until list_ptr is equal to NULL.</p>
<p>list_ptr=start;<br />
while(list_ptr)<br />
{<br />
printf(“ %c”, list_ptr-&gt;information);<br />
list_ptr=list_ptr-&gt;next;<br />
}</p>
<p>Searching in a Linked List<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Linked lists can be of two types –<br />
Sorted<br />
Unsorted<br />
Searching in a linked list involves traversing the list until the required node is reached.<br />
Modification in a linked list involves –<br />
Searching for the node to be modified.<br />
Changing the information part of the node.</p>
<p>Deletion in a Singly Linked List<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
For deleting a node at the beginning of a list, the steps involved are &#8211;<br />
Set ptr to start.<br />
Set start to point to what ptr’s next is pointing to start=ptr-&gt;next;<br />
Free the memory occupied by the node free(ptr);<br />
Doubly Linked Lists<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
A Doubly Linked List is just an extension of the concept of a singly linked list. Each node in a doubly linked list has an information part and two pointers – one pointing to the next node and one to the previous node.</p>
<p>Representing Doubly Linked Lists in C<br />
Doubly Linked Lists are represented in C in the same manner in which singly linked lists are.<br />
struct dlist {<br />
datatype data;<br />
………<br />
………<br />
struct dlist *next;<br />
struct dlist *prior;<br />
};</p>
<p>Traversal in a Doubly Linked List<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Traversal in a doubly linked list can be done in two directions –<br />
Start from the beginning of the list to the end of the list.<br />
Start from the last node and traverse in the opposite direction to the first node.</p>
<p>Circular Linked Lists<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
A circular linked list is obtained by modifying the link of the last node in a linked list.<br />
The main drawback of circular lists is that a node can be accessed from a given node by traversing through the list.</p>
<p>Implementing Stacks<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
A Stack is a data structure in which insertions and deletions are restricted to one end called Top.<br />
Stacks are also called Last-In-First-Out (LIFO) lists because they come out in the reverse order in which they go in</p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Flist-stack-queues%2F&amp;linkname=List-Stack-Queues" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Flist-stack-queues%2F&amp;linkname=List-Stack-Queues" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Flist-stack-queues%2F&#038;title=List-Stack-Queues" data-a2a-url="https://mitindia.in/list-stack-queues/" data-a2a-title="List-Stack-Queues"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/list-stack-queues/">List-Stack-Queues</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Data structure and algorithm</title>
		<link>https://mitindia.in/data-structure-algorithm/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Sun, 20 Nov 2016 07:36:04 +0000</pubDate>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[data structure]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=594</guid>

					<description><![CDATA[<p>Data Structures A data structure is a logical method of representing data in memory. Data structure is strictly described as an instance of an Abstract Data Type (ADT). An Abstract Data Type is defined as a mathematical model of a user-defined type along with the operations performed on that model. Data Structure Strengths Weaknesses Array [&#8230;]</p>
<p>The post <a href="https://mitindia.in/data-structure-algorithm/">Data structure and algorithm</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Data Structures<img decoding="async" class="alignright" src="http://image.slidesharecdn.com/lecture1-m-131122062232-phpapp02/95/lecture-1-data-structures-and-algorithms-1-638.jpg?cb=1385105034" alt="Image result for data structures and algorithms" width="177" height="133" /></h3>
<ul>
<li>A data structure is a logical method of representing data in memory.</li>
<li>Data structure is strictly described as an instance of an Abstract Data Type (ADT).</li>
<li>An Abstract Data Type is defined as a mathematical model of a user-defined type along with the operations performed on that model.</li>
</ul>
<table border="1" width="650">
<tbody>
<tr>
<td width="169"><strong>Data Structure</strong></td>
<td width="334"><strong>Strengths</strong></td>
<td width="254"><strong>Weaknesses</strong></td>
</tr>
<tr>
<td width="169">Array</td>
<td width="334">Fast access if index is known</td>
<td width="254">Slow search, fixed size</td>
</tr>
<tr>
<td width="169">Stack</td>
<td width="334">Features last in – first out access</td>
<td width="254">Slow access to other elements</td>
</tr>
<tr>
<td width="169">Queue</td>
<td width="334">Features first in – first out access</td>
<td width="254">Slow access to other elements</td>
</tr>
<tr>
<td width="169">Linked list</td>
<td width="334">Quick insertion and deletion</td>
<td width="254">Slow search</td>
</tr>
<tr>
<td width="169">Binary tree</td>
<td width="334">Quick insertion, deletion and search when tree is balanced</td>
<td width="254">Deletion procedure is complex</td>
</tr>
<tr>
<td width="169">Hash table</td>
<td width="334">Fast insertion and access if key is known</td>
<td width="254">Inefficient memory usage, slow access if key is not known</td>
</tr>
<tr>
<td width="169">Heap</td>
<td width="334">Fast insertion, deletion and access to largest element</td>
<td width="254">Slow access to other elements</td>
</tr>
<tr>
<td width="169">Graph</td>
<td width="334">Simulates real world problems</td>
<td width="254">Some algorithms are slow and complex</td>
</tr>
</tbody>
</table>
<h5>Algorithm</h5>
<p>An algorithm can be described as sequence of steps or instructions required to solve a given problem.</p>
<p>It is a finite set of instructions written to accomplish a particular task.</p>
<p>When designing an algorithm, one must ensure that the</p>
<p>algorithm adheres to the following criteria:</p>
<p>Input: Some input data (can be empty in some cases) externally supplied to the algorithm</p>
<p>Output: At least one output is produced</p>
<p>Finiteness: The algorithm must terminate after finite number of steps</p>
<p>Definiteness: The instructions must be clear and unambiguous</p>
<p>Effectiveness: Every instruction must be basic enough to be carried out on paper</p>
<p><strong>Following are certain points to be considered</strong></p>
<p>while writing an algorithm :</p>
<p>Representing an algorithm.</p>
<p>Designing an algorithm.</p>
<p>Analyzing an algorithm.</p>
<p><strong>Algorithm Analysis</strong></p>
<p>Algorithm Analysis involves comparing different algorithms written for a specific problem. All the algorithms are compared for their space and time complexities.</p>
<p>Space complexity: It refers to the amount of storage the algorithm consumes.</p>
<p>Time complexity: It is the time required by the algorithm for execution.</p>
<p><strong>Following are the different types of time complexities:</strong></p>
<p>Best-case time complexity: It is the measure of minimum time required for an algorithm to execute for a known input size.</p>
<p>Average case time complexity: Average time complexity is the measure of time an algorithm will require to execute, for a typical input data size. This method requires statistical calculations.</p>
<p>Worst-case time complexity: It is the measure of maximum time required for an algorithm to execute for a known input size.</p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fdata-structure-algorithm%2F&amp;linkname=Data%20structure%20and%20algorithm" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fdata-structure-algorithm%2F&amp;linkname=Data%20structure%20and%20algorithm" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fdata-structure-algorithm%2F&#038;title=Data%20structure%20and%20algorithm" data-a2a-url="https://mitindia.in/data-structure-algorithm/" data-a2a-title="Data structure and algorithm"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/data-structure-algorithm/">Data structure and algorithm</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
