<?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:blogger='http://schemas.google.com/blogger/2008' 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-2455670798310287027</id><updated>2024-11-08T07:39:46.850-08:00</updated><category term="Programming"/><category term="c++"/><category term="Algorithm"/><category term="Algorithms"/><category term="C"/><category term="data structure"/><category term="Code"/><category term="GSM"/><category term="Computers"/><category term="Fun"/><category term="Graph"/><category term="Knowledge"/><category term="Linked Lists"/><category term="traversal"/><category term="umts"/><category term="Binary tree"/><category term="Humor"/><category term="Images"/><category term="Sarcastic Retard"/><category term="Sim cards"/><category term="Sorting Techniques"/><category term="Square root"/><category term="Stack"/><category term="bit magic"/><category term="inorder"/><category term="mobile"/><category term="psychological facts"/><category term="psychology"/><category term="telecom"/><category term="3G"/><category term="Abbreviations"/><category term="Big-O Notation"/><category term="Binary Search"/><category term="Counting Sort"/><category term="Facts"/><category term="Heap"/><category term="How to Blog"/><category term="ICCID"/><category term="IMEI"/><category term="IMSI"/><category term="Inception"/><category term="Incorporation of dreams in reality"/><category term="Insertion sort"/><category term="Interesting"/><category term="LTE"/><category term="MSISDN"/><category term="Mobile Computing"/><category term="Node"/><category term="Parenthesis Validation"/><category term="Prime"/><category term="Prime Number"/><category term="Radix Sort"/><category term="Self Introduction"/><category term="Sort"/><category term="Structure"/><category term="Time Complexity"/><category term="Validation"/><category term="VoIP"/><category term="VoLTE"/><category term="What Should I Blog About"/><category term="amplitude"/><category term="bit fields"/><category term="bits and bytes"/><category term="bystander effect"/><category term="cocktail party effect"/><category term="diffusion of responsibilities"/><category term="digital modulation"/><category term="dreams"/><category term="frequency"/><category term="mobile communication"/><category term="mobile subscribers"/><category term="modulation techniques"/><category term="phase"/><category term="postorder"/><category term="preorder"/><category term="quora"/><category term="shift keying"/><category term="the paradox of choice"/><category term="the spotlight effect"/><category term="tuning voice"/><title type='text'>Learn. Share. Improve.</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>48</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-9146480831625822975</id><published>2015-10-19T11:51:00.001-07:00</published><updated>2015-10-19T11:51:26.942-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Data Structure: Implementing Circular Queue in C++</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVScQlsDX1mw7sXhyUdVoeUGyEIdiwIClCpxFK9IM42grpB3c0__s-sat0FozDQAPYc4R7rvYLRuwX5mjRe0A_vQtwwdsnyDZD2w7YtlGJw-rBgQb4iH1gic2GZ9bJ-UF98nZhv6D0saRc/s1600/circular_queue___conceptual-view.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;293&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVScQlsDX1mw7sXhyUdVoeUGyEIdiwIClCpxFK9IM42grpB3c0__s-sat0FozDQAPYc4R7rvYLRuwX5mjRe0A_vQtwwdsnyDZD2w7YtlGJw-rBgQb4iH1gic2GZ9bJ-UF98nZhv6D0saRc/s320/circular_queue___conceptual-view.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Circular queue is a linear data structure. It follows FIFO principle. In circular queue the last node is connected back to the first node to make a circle. Circular linked list fallow the First In First Out principle. Elements are added at the rear end and the elements are deleted at front end of the queue.&lt;br /&gt;
&lt;br /&gt;
This C++ Program demonstrates the implementation of Circular Queue.&lt;br /&gt;
Here is source code of the C++ Program to demonstrate the implementation of Circular Queue. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
/*
 * C++ Program to Implement Circular Queue
 */
#include &lt; iostream &gt;
#define MAX 5
using namespace std;
/*
 * Class Circular Queue
 */
class Circular_Queue
{
    private:
        int *cqueue_arr;
        int front, rear;
    public:
        Circular_Queue()
        {
            cqueue_arr = new int [MAX];
            rear = front = -1;
        }
        /*
         * Insert into Circular Queue
         */
        void insert(int item)
        {
            if ((front == 0 &amp;&amp; rear == MAX-1) || (front == rear+1))
            {
                cout &lt;&lt; &quot;Queue Overflow \n&quot;;
                return;
            }
            if (front == -1)
            {
                front = 0;
                rear = 0;
            }
            else
            {
                if (rear == MAX - 1)
                    rear = 0;
                else
                    rear = rear + 1;
            }
            cqueue_arr[rear] = item ;
        }
        /*
         * Delete from Circular Queue
         */
        void del()
        {
            if (front == -1)
            {
                cout &lt;&lt; &quot;Queue Underflow\n&quot;;
                return ;
            }
            cout &lt;&lt; &quot;Element deleted from queue is : &quot; &lt;&lt; cqueue_arr[front] &lt;&lt; endl;
            if (front == rear)
            {
                front = -1;
                rear = -1;
            }
            else
            {
                if (front == MAX - 1)
                    front = 0;
                else
                    front = front + 1;
            }
        }
        /*
         * Display Circular Queue
         */
        void display()
        {
            int front_pos = front, rear_pos = rear;
            if (front == -1)
            {
                cout &lt;&lt; &quot;Queue is empty\n&quot;;
                return;
            }
            cout &lt;&lt; &quot;Queue elements :\n&quot;;
            if (front_pos &lt;= rear_pos)
            {
                while (front_pos &lt;= rear_pos)
                {
                    cout&lt;&lt;cqueue_arr[front_pos]&lt;&lt;&quot;  &quot;;
                    front_pos++;
                }
            }
            else
            {
                while (front_pos &lt;= MAX - 1)
                {
                    cout &lt;&lt; cqueue_arr[front_pos] &lt;&lt; &quot;  &quot;;
                    front_pos++;
                }
                front_pos = 0;
                while (front_pos &lt;= rear_pos)
                {
                    cout &lt;&lt; cqueue_arr[front_pos] &lt;&lt; &quot;  &quot;;
                    front_pos++;
                }
            }
            cout&lt;&lt;endl;
        }
};
/*
 * Main
 */
int main()
{
    int choice, item;
    Circular_Queue cq;
    do
    {
        cout &lt;&lt; &quot;1.Insert\n&quot;;
        cout &lt;&lt; &quot;2.Delete\n&quot;;
        cout &lt;&lt; &quot;3.Display\n&quot;;
        cout &lt;&lt; &quot;4.Quit\n&quot;;
        cout &lt;&lt; &quot;Enter your choice : &quot;;
        cin &gt;&gt; choice;
        switch(choice)
        {
        case 1:
            cout &lt;&lt; &quot;Input the element for insertion in queue : &quot;;
            cin &gt;&gt; item;	
            cq.insert(item);
	    break;
	case 2:
            cq.del();
	    break;
        case 3:
            cq.display();
	    break;
	case 4:
	    break;
	default:
	    cout &lt;&lt; &quot;Wrong choice\n&quot;;
	}/*End of switch*/
    }
    while(choice != 4);
    return 0;
}
&lt;/pre&gt;
&lt;br/&gt;
Output
&lt;br/&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
$ g++ circular_queue.cpp
$ a.out
 
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the element for insertion in queue : 3
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the element for insertion in queue : 2
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the element for insertion in queue : 6
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the element for insertion in queue : 4
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the element for insertion in queue : 1
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 3
Queue elements :
3  2  6  4  1
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 2
Element deleted from queue is : 3
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 3
Queue elements :
2  6  4  1
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 4
 
------------------
(program exited with code: 1)
Press return to continue
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/9146480831625822975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/data-structure-implementing-circular.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/9146480831625822975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/9146480831625822975'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/data-structure-implementing-circular.html' title='Data Structure: Implementing Circular Queue in C++'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVScQlsDX1mw7sXhyUdVoeUGyEIdiwIClCpxFK9IM42grpB3c0__s-sat0FozDQAPYc4R7rvYLRuwX5mjRe0A_vQtwwdsnyDZD2w7YtlGJw-rBgQb4iH1gic2GZ9bJ-UF98nZhv6D0saRc/s72-c/circular_queue___conceptual-view.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-3629670709209201531</id><published>2015-10-19T10:21:00.000-07:00</published><updated>2015-10-19T10:21:02.021-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Data Structure: Implementing Priority Queue in C++</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFwcVSf9-qqjuPCyu8Ny8SzGMfQ1vLOwaCJhfKRXsNffaHtNWjpU3GHb0aSwJ2lgBIvV5b01PlVeLyHj8DNHDMl_x7CKmcZ48193ZSrWaRi62oitX67OexmGYtd4wFGYXZptnFRhfPDN7w/s1600/2d5df0701e454291d06044cfc1396333496d1c14.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFwcVSf9-qqjuPCyu8Ny8SzGMfQ1vLOwaCJhfKRXsNffaHtNWjpU3GHb0aSwJ2lgBIvV5b01PlVeLyHj8DNHDMl_x7CKmcZ48193ZSrWaRi62oitX67OexmGYtd4wFGYXZptnFRhfPDN7w/s400/2d5df0701e454291d06044cfc1396333496d1c14.jpeg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
A priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a &quot;priority&quot; associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue.&lt;br /&gt;
More info: &lt;a href=&quot;https://en.wikipedia.org/wiki/Priority_queue&quot; target=&quot;_blank&quot;&gt;Wikipedia Link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This C++ Program demonstrates the implementation of Priority Queue.&lt;br /&gt;
Here is source code of the C++ Program to demonstrate the implementation of Priority Queue. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
/*
 * C++ Program to Implement Priority Queue
 */
#include &lt; iostream &gt;
#include &lt; cstdio &gt;
#include &lt; cstring &gt;
#include &lt; cstdlib &gt;
using namespace std;
 
/*
 * Node Declaration
 */
struct node
{
 int priority;
 int info;
 struct node *link;
};
/*
 * Class Priority Queue
 */
class Priority_Queue
{
    private:
        node *front;
    public:
        Priority_Queue()
        {
            front = NULL;
        }
        /*
         * Insert into Priority Queue
         */
        void insert(int item, int priority)
        {
            node *tmp, *q;
            tmp = new node;
            tmp-&gt;info = item;
            tmp-&gt;priority = priority;
            if (front == NULL || priority &lt; front-&gt;priority)
            {
                tmp-&gt;link = front;
                front = tmp;
            }
            else
            {
                q = front;
                while (q-&gt;link != NULL &amp;&amp; q-&gt;link-&gt;priority &lt;= priority)
                    q=q-&gt;link;
                tmp-&gt;link = q-&gt;link;
                q-&gt;link = tmp;
            }
        }
        /*
         * Delete from Priority Queue
         */
        void del()
        {
            node *tmp;
            if(front == NULL)
                cout &lt;&lt; &quot;Queue Underflow\n&quot;;
            else
            {
                tmp = front;
                cout &lt;&lt; &quot;Deleted item is: &quot; &lt;&lt; tmp-&gt;info &lt;&lt; endl;
                front = front-&gt;link;
                free(tmp);
            }
        }
        /*
         * Print Priority Queue
         */
        void display()
        {
            node *ptr;
            ptr = front;
            if (front == NULL)
                cout &lt;&lt; &quot;Queue is empty\n&quot;;
            else
            { cout &lt;&lt; &quot;Queue is :\n&quot;;
                cout &lt;&lt; &quot;Priority       Item\n&quot;;
                while(ptr != NULL)
                {
                    cout &lt;&lt; ptr-&gt;priority &lt;&lt; &quot;                 &quot; &lt;&lt; ptr-&gt;info &lt;&lt; endl;
                    ptr = ptr-&gt;link;
                }
            }
        }
};
/*
 * Main
 */
int main()
{
    int choice, item, priority;
    Priority_Queue pq; 
    do
    {
        cout &lt;&lt; &quot;1.Insert\n&quot;;
        cout &lt;&lt; &quot;2.Delete\n&quot;;
        cout &lt;&lt; &quot;3.Display\n&quot;;
        cout &lt;&lt; &quot;4.Quit\n&quot;;
        cout &lt;&lt; &quot;Enter your choice : &quot;; 
        cin &gt;&gt; choice;
        switch(choice)
        {
        case 1:
            cout &lt;&lt; &quot;Input the item value to be added in the queue : &quot;;
            cin &gt;&gt; item;
            cout &lt;&lt; &quot;Enter its priority : &quot;;
            cin &gt;&gt; priority;
            pq.insert(item, priority);
            break;
        case 2:
            pq.del();
            break;
        case 3:
            pq.display();
            break;
        case 4:
            break;
        default :
            cout &lt;&lt; &quot;Wrong choice\n&quot;;
        }
    }
    while(choice != 4);
    return 0;
}
&lt;/pre&gt;
Output
&lt;pre class=&quot;prettyprint&quot;&gt;
$ g++ priority_queue.cpp
$ a.out
 
4.Quit
Enter your choice : 1
Input the item value to be added in the queue : 4
Enter its priority : 2
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the item value to be added in the queue : 3
Enter its priority : 3
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the item value to be added in the queue : 2
Enter its priority : 4
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the item value to be added in the queue : 1
Enter its priority : 5
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 3
Queue is :
Priority       Item
1                 5
2                 4
3                 3
4                 2
5                 1
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 2
Deleted item is: 5
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 3
Queue is :
Priority       Item
2                 4
3                 3
4                 2
5                 1
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 4
 
------------------
(program exited with code: 1)
Press return to continue
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/3629670709209201531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/data-structure-implementing-priority.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3629670709209201531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3629670709209201531'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/data-structure-implementing-priority.html' title='Data Structure: Implementing Priority Queue in C++'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFwcVSf9-qqjuPCyu8Ny8SzGMfQ1vLOwaCJhfKRXsNffaHtNWjpU3GHb0aSwJ2lgBIvV5b01PlVeLyHj8DNHDMl_x7CKmcZ48193ZSrWaRi62oitX67OexmGYtd4wFGYXZptnFRhfPDN7w/s72-c/2d5df0701e454291d06044cfc1396333496d1c14.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-709183160436635464</id><published>2015-10-18T09:43:00.005-07:00</published><updated>2015-10-18T09:43:59.977-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Binary tree"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Data Structure: Binary Search Tree</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLkA26A-dEyvdR4SCRmokLln0RCjDUposMKczpEOMVf4dmDiNheN8H6AMb-7DlHzJR4KsEpMc1jtt4nMw3xgwpK03Qx9kq-Q4XSWC1HFPjwMOOZW57cV6DFcKOZycskOiE3VODxEGMoiOg/s1600/2000px-Binary_search_tree.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLkA26A-dEyvdR4SCRmokLln0RCjDUposMKczpEOMVf4dmDiNheN8H6AMb-7DlHzJR4KsEpMc1jtt4nMw3xgwpK03Qx9kq-Q4XSWC1HFPjwMOOZW57cV6DFcKOZycskOiE3VODxEGMoiOg/s320/2000px-Binary_search_tree.svg.png&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Until now all data structures that we have covered (Stack,Queue,Linked List) are linear in nature ie. they have a definite order of placement. Now we shall study Binary Trees which requires a different thought process as it is a non linear data structure.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A Binary Tree consists of a main node known as the Root. The Root then has two sub-sections, ie. the left and the right half. The data subsequently stored after the root is created depends on it&#39;s value compared to the root. Suppose the root value is 10 and the Value to be added is 15, then the data is added to the right section of the root. The Basic idea is that every node can be thought of a binary tree itself. Each node has two pointers, one to the left and the other to the right. Depending on the value to be stored, it is placed after a node&#39;s right pointer if the value of the node is lesser than the one to be added or the node&#39;s left pointer if vice versa.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Let&#39;s take an Example. To add the Following List of Numbers, we end up with a Binary Tree like this:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;32 16 34 1 87 13 7 18 14 19 23 24 41 5 53&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here&#39;s How:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;**: KEEP ADDING DATA IN THE TREE ON PAPER AFTER EACH STEP BELOW TO UNDERSTAND HOW THE TREE IS FORMED.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(1).&lt;/b&gt; Since 32 is the First Number to be added, 32 becomes the root of the tree.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(2).&lt;/b&gt; Next Number is 16 which is lesser than 32 Hence 16 becomes left node of 32.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(3).&lt;/b&gt; 34. Since 34 &amp;gt; 32 , 34 becomes the right node of the ROOT.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(4).&lt;/b&gt; 1. Since 1 &amp;lt; 32 we jump to the left node of the ROOT. But since the left node&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;has already been taken we test 1 once again. Since 1 &amp;lt; 16, 1 becomes the left&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;node of 16.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(5).&lt;/b&gt; 87. Since 87 &amp;gt; 32 we jump to the right node of the root. Once again this&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;space is occupied by 34. Now since 87 &amp;gt; 34, 87 becomes the right node of 34.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(6).&lt;/b&gt; 13. Since 13 &amp;lt; 32 we jump to left node of the root. There, 13 &amp;lt; 16 so we&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;continue towards the left node of 16. There 13 &amp;gt; 1, so 13 becomes the right&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;node of 1.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(7).&lt;/b&gt; Similarly work out addition till the end ie. before Number 53.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(8).&lt;/b&gt; 53. Since 53 &amp;gt; 32 we jump to the right node of the root. There 53 &amp;gt; 34 so we&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;continue to the right node of 34. There 53 &amp;lt; 87 so we continue towards the&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;left node of 87. There 53 &amp;gt; 41 so we jump to the right node of 41. Since the&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Right node of 41 is empty 53 becomes the right node of 41.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This should give you an idea of how a Binary Tree works. You must know that:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(1).&lt;/b&gt; The linking of nodes to nodes in a Binary Tree is one to one in nature&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ie. a node cannot be pointed by more than 1 node.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;(2).&lt;/b&gt; A Node can point to two different sub-nodes at the most.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here in the binary tree above there are a few nodes whose left and right&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;pointers are empty ie. they have no sub-node attached to them. So Nodes 5,14,18,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;19,23,24,41 have their left nodes empty.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;There are three popular ways to display a Binary Tree. Displaying the trees contents is known as transversal. There are three ways of transversing a tree iw. in inorder, preorder, and postorder transversal methods. Description of each is shown below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;strong class=&quot;bbc&quot; style=&quot;background-color: white; color: #222222; font-size: 14px; line-height: 21px; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;PREORDER:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul class=&quot;bbcol decimal&quot; style=&quot;background-color: white; color: #222222; font-size: 14px; line-height: 21px; list-style: decimal; margin: 0px 0px 0px 30px; padding: 0px 0px 0px 3em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Visit the root.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transverse the left leaf in preorder.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transverse the right leaf in preorder.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;strong class=&quot;bbc&quot; style=&quot;background-color: white; color: #222222; font-size: 14px; line-height: 21px; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;INORDER:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul class=&quot;bbcol decimal&quot; style=&quot;background-color: white; color: #222222; font-size: 14px; line-height: 21px; list-style: decimal; margin: 0px 0px 0px 30px; padding: 0px 0px 0px 3em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transverse the left leaf in inorder.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Visit the root.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transverse the right leaf in inorder.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;strong class=&quot;bbc&quot; style=&quot;background-color: white; color: #222222; font-size: 14px; line-height: 21px; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;POSTORDER:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul class=&quot;bbcol decimal&quot; style=&quot;background-color: white; color: #222222; font-size: 14px; line-height: 21px; list-style: decimal; margin: 0px 0px 0px 30px; padding: 0px 0px 0px 3em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transverse the left leaf in postorder.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transverse the right leaf in postorder.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Visit the root.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;Writing code for these three methods are simple if we understand the recursive nature of a binary tree. Binary tree is recursive, as in each node can be thought of a binary tree itself. It&#39;s just the order of displaying data that makes a difference for transversal.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;span style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;
&lt;div&gt;
Deletion from a Binary Tree is a bit more difficult to understand. For now just remember that for deleting a node, it is replaced with it&#39;s next inorder successor. I&#39;ll explain everything after the Binary Tree code. Now that you&#39;ve got all your Binary Tree Fundas clear, let&#39;s move on with the Source code.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;#include &amp;lt; iostream &amp;gt;

using namespace std;

#define YES 1
#define NO 0

class tree
{
	private:
		struct leaf
		{
			int data;
			leaf *l;
			leaf *r;
		};
		struct leaf *p;

	public:
		tree();
		~tree();
		void destruct(leaf *q);
		tree(tree&amp;amp; a);
		void findparent(int n,int &amp;amp;found,leaf* &amp;amp;parent);
		void findfordel(int n,int &amp;amp;found,leaf *&amp;amp;parent,leaf* &amp;amp;x);
		void add(int n);
		void transverse();
		void in(leaf *q);
		void pre(leaf *q);
		void post(leaf *q);
		void del(int n);
};
		
tree::tree()
{
	p=NULL;
}

tree::~tree()
{
	destruct(p);
}

void tree::destruct(leaf *q)
{
	if(q!=NULL)
	{
		destruct(q-&amp;gt;l);
		del(q-&amp;gt;data);
		destruct(q-&amp;gt;r);
	}
}
void tree::findparent(int n,int &amp;amp;found,leaf *&amp;amp;parent)
{
	leaf *q;
	found=NO;
	parent=NULL;

	if(p==NULL)
		return;

	q=p;
	while(q!=NULL)
	{
		if(q-&amp;gt;data==n)
		{
			found=YES;
			return;
		}
		if(q-&amp;gt;data &amp;gt; n)
		{
			parent=q;
			q=q-&amp;gt;l;
		}
		else
		{
			parent=q;
			q=q-&amp;gt;r;
		}
	}
}

void tree::add(int n)
{
	int found;
	leaf *t,*parent;
	findparent(n,found,parent);
	if(found==YES)
		cout &amp;lt;&amp;lt; &quot;\nSuch a Node Exists&quot;;
	else
	{
		t=new leaf;
		t-&amp;gt;data=n;
		t-&amp;gt;l=NULL;
		t-&amp;gt;r=NULL;

		if(parent==NULL)
			p=t;
		else
			parent-&amp;gt;data &amp;gt; n ? parent-&amp;gt;l=t : parent-&amp;gt;r = t;
	}
}

void tree::transverse()
{
	int c;
	cout &amp;lt;&amp;lt; &quot;\n1.InOrder\n2.Preorder\n3.Postorder\nChoice: &quot;;
	cin &amp;gt;&amp;gt; c;
	switch(c)
	{
		case 1:
			in(p);
			break;

		case 2:
			pre(p);
			break;

		case 3:
			post(p);
			break;
	}
}

void tree::in(leaf *q)
{
	if(q!=NULL)
	{
		in(q-&amp;gt;l);
		cout &amp;lt;&amp;lt; &quot;\t&quot;&amp;lt;&lt;q-&gt;data&amp;lt;&lt;endl in=&quot;&quot; q-=&quot;&quot;&gt;r);
	}
	
}

void tree::pre(leaf *q)
{
	if(q!=NULL)
	{
		cout &amp;lt;&amp;lt; &quot;\t&quot;&amp;lt;&lt;q-&gt;data&amp;lt;&lt;endl pre=&quot;&quot; q-=&quot;&quot;&gt;l);
		pre(q-&amp;gt;r);
	}
	
}

void tree::post(leaf *q)
{
	if(q!=NULL)
	{
		post(q-&amp;gt;l);
		post(q-&amp;gt;r);
		cout &amp;lt;&amp;lt; &quot;\t&quot;&amp;lt;&lt;q-&gt;data&amp;lt;&lt;endl found=&quot;0;&quot; if=&quot;&quot; int=&quot;&quot; leaf=&quot;&quot; n=&quot;&quot; p=&quot;=NULL)&quot; parent=&quot;NULL;&quot; q-=&quot;&quot; q=&quot;&quot; return=&quot;&quot; tree::findfordel=&quot;&quot; void=&quot;&quot; while=&quot;&quot; x=&quot;&quot;&gt;data==n)
		{
			found=1;
			x=q;
			return;
		}
		if(q-&amp;gt;data&amp;gt;n)
		{
			parent=q;
			q=q-&amp;gt;l;
		}
		else
		{
			parent=q;
			q=q-&amp;gt;r;
		}
	}
}

void tree::del(int num)
{
	leaf *parent,*x,*xsucc;
	int found;

	// If EMPTY TREE
	if(p==NULL)
	{
		cout &amp;lt;&amp;lt; &quot;\nTree is Empty&quot;;
		return;
	}
	parent=x=NULL;
	findfordel(num,found,parent,x);
	if(found==0)
	{
		cout&amp;lt;&amp;lt;&quot;\nNode to be deleted NOT FOUND&quot;;
		return;
	}

	// If the node to be deleted has 2 leaves
	if(x-&amp;gt;l != NULL &amp;amp;&amp;amp; x-&amp;gt;r != NULL)
	{
		parent=x;
		xsucc=x-&amp;gt;r;

		while(xsucc-&amp;gt;l != NULL)
		{
			parent=xsucc;
			xsucc=xsucc-&amp;gt;l;
		}
		x-&amp;gt;data=xsucc-&amp;gt;data;
		x=xsucc;
	}

	// if the node to be deleted has no child
	if(x-&amp;gt;l == NULL &amp;amp;&amp;amp; x-&amp;gt;r == NULL)
	{
		if(parent-&amp;gt;r == x)
			parent-&amp;gt;r=NULL;
		else
			parent-&amp;gt;l=NULL;

		delete x;
		return;
	}

	// if node has only right leaf
	if(x-&amp;gt;l == NULL &amp;amp;&amp;amp; x-&amp;gt;r != NULL )
	{
		if(parent-&amp;gt;l == x)
			parent-&amp;gt;l=x-&amp;gt;r;
		else
			parent-&amp;gt;r=x-&amp;gt;r;

		delete x;
		return;
	}

	// if node to be deleted has only left child
	if(x-&amp;gt;l != NULL &amp;amp;&amp;amp; x-&amp;gt;r == NULL)
	{
		if(parent-&amp;gt;l == x)
			parent-&amp;gt;l=x-&amp;gt;l;
		else
			parent-&amp;gt;r=x-&amp;gt;l;

		delete x;
		return;
	}
}

int main()
{
	tree t;
	int data[]={32,16,34,1,87,13,7,18,14,19,23,24,41,5,53};
	for(int iter=0 ; iter &amp;lt; 15 ; i++)
		t.add(data[iter]);

	t.transverse();
	t.del(16);
	t.transverse();
	t.del(41);
	t.transverse();
	return 0;
}

&lt;/endl&gt;&lt;/q-&gt;&lt;/endl&gt;&lt;/q-&gt;&lt;/endl&gt;&lt;/q-&gt;&lt;/pre&gt;
Output
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;1.InOrder
2.Preorder
3.Postorder
Choice: 1
1
5
7
13
14
16
18
19
23
24
32
34
41
53
87

1.InOrder
2.Preorder
3.Postorder
Choice: 2
32
18
1
13
7
5
14
19
23
24
34
87
41
53

1.InOrder
2.Preorder
3.Postorder
Choice: 3
5
7
14
13
1
24
23
19
18
53
87
34
32
Press any key to continue
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;NOTE:&lt;/b&gt; Visual C++ may give Runtime Errors with this code. Compile with Turbo C++.&lt;br /&gt;
&lt;br /&gt;
Just by looking at the output you might realise that we can print out the whole tree in ascending order by using inorder transversal. Infact Binary Trees are used for Searching [ Binary Search Trees {BST} ] as well as in Sorting. The Addition of data part seems fine. Only the deletion bit needs to be explained.&lt;br /&gt;
&lt;br /&gt;
For deletion of data there are a few cases to be considered:&lt;br /&gt;
1. If the leaf to be deleted is not found.&lt;br /&gt;
2. If the leaf to be deleted has no sub-leafs.&lt;br /&gt;
3. If the leaf to be deleted has 1 sub-leaf.&lt;br /&gt;
4. If the leaf to be deleted has 2 sub-leafs.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CASE 1:&lt;/b&gt;&lt;br /&gt;
Dealing with this case is simple, we simply display an error message.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CASE 2:&lt;/b&gt;&lt;br /&gt;
Since the node has no sub-nodes, the memory occupied by this should be freed and either the left link or the right link of the parent of this node should be set to NULL. Which of these should be set to NULL depends upon whether the node being deleted is a left child or a right child of its parent.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CASE 3:&lt;/b&gt;&lt;br /&gt;
In the third case we just adjust the pointer of the parent of the leaf to be deleted such that after deletion it points to the child of the node being deleted.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CASE 4:&lt;/b&gt;&lt;br /&gt;
The last case in which the leaf to be deleted has to sub-leaves of its own is rather complicated.The whole logic is to locate the inorder successor, copy it&#39;s data and reduce the problem to simple deletion of a node with one or zero leaves. Consider in the above program...(Refer to the previous tree as well) when we are deleting 16 we search for the next inorder successor. So we simply set the data value to 5 and delete the node with value 5 as shown for cases 2 and 3.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/709183160436635464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/data-structure-binary-search-tree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/709183160436635464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/709183160436635464'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/data-structure-binary-search-tree.html' title='Data Structure: Binary Search Tree'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLkA26A-dEyvdR4SCRmokLln0RCjDUposMKczpEOMVf4dmDiNheN8H6AMb-7DlHzJR4KsEpMc1jtt4nMw3xgwpK03Qx9kq-Q4XSWC1HFPjwMOOZW57cV6DFcKOZycskOiE3VODxEGMoiOg/s72-c/2000px-Binary_search_tree.svg.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-4741503885590231017</id><published>2015-10-17T12:31:00.002-07:00</published><updated>2015-10-17T12:58:08.970-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked Lists"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Cpp Program to Implement Queue Using Linked Lists</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi5vhoXXY6Yuyh7orsLqrtkAzKoujAiRmEJdRhdEcKneVF6iHxDDtY6vBl5X-UlKVEHD7w3TsU4vmQKEFXOiCk9AucB760S4OmiekEXtCtip-G7p-UYz-29-0tvL72tuejKMKHnOKm3RWk/s1600/linkedlist.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi5vhoXXY6Yuyh7orsLqrtkAzKoujAiRmEJdRhdEcKneVF6iHxDDtY6vBl5X-UlKVEHD7w3TsU4vmQKEFXOiCk9AucB760S4OmiekEXtCtip-G7p-UYz-29-0tvL72tuejKMKHnOKm3RWk/s400/linkedlist.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This C++ program, using iteration, implements the list of elements removed from the queue in first in first out mode using a linked list. A linked list is an ordered set of data elements, each containing a link to its successor.&lt;br /&gt;
&lt;br /&gt;
Here is the source code of the C program to display the list of elements removed from the queue. The C++ program is successfully compiled and run on DevCpp, a C++ compiler. The program output is also shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&#39;prettyprint&#39;&gt;/*
 * C++ Program to Implement Queue using Linked List
 */
#include &amp;lt; iostream &amp;gt;
#include &amp;lt; stdio.h &amp;gt;
#include &amp;lt; conio.h &amp;gt;
using namespace std;
struct node
{
    int data;
    node *next;
}*front = NULL,*rear = NULL,*p = NULL,*np = NULL;
void push(int x)
{
    np = new node;
    np-&amp;gt;data = x;
    np-&amp;gt;next = NULL;
    if(front == NULL)
    {
        front = rear = np;
        rear-&amp;gt;next = NULL;
    }
    else
    {
        rear-&amp;gt;next = np;
        rear = np;
        rear-&amp;gt;next = NULL;
    }
}
int remove()
{
    int x;
    if(front == NULL)
    {
        cout &amp;lt;&amp;lt; &quot;empty queue\n&quot;;
    }
    else
    {
        p = front;
        x = p-&amp;gt;data;
        front = front-&amp;gt;next;
        delete(p);
        return(x);
    }
}
int main()
{
    int n,c = 0,x;
    cout &amp;lt;&amp;lt; &quot;Enter the number of values to be pushed into queue\n&quot;;
    cin &amp;gt;&amp;gt; n;
    while (c &amp;lt; n)
    {
 cout &amp;lt;&amp;lt; &quot;Enter the value to be entered into queue\n&quot;;
 cin &amp;gt;&amp;gt; x;
        push(x);
        c++;
     }
     cout &amp;lt;&amp;lt; &quot;\n\nRemoved Values\n\n&quot;;
     while(true)
     {
        if (front != NULL)
            cout &amp;lt;&amp;lt; remove() &amp;lt;&amp;lt; endl;
        else
            break;
     }
     getch();
}
&lt;/pre&gt;
&lt;br /&gt;
Output of above program
&lt;br /&gt;
&lt;pre class=&#39;prettyprint&#39;&gt;Output
Enter the number of values to be pushed into queue
6
Enter the value to be entered into queue
5
Enter the value to be entered into queue
4
Enter the value to be entered into queue
3
Enter the value to be entered into queue
2
Enter the value to be entered into queue
1
Enter the value to be entered into queue
0
 
Removed Values
 
5
4
3
2
1
0
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/4741503885590231017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-cpp-program-to-implement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/4741503885590231017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/4741503885590231017'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-cpp-program-to-implement.html' title='Programming: Cpp Program to Implement Queue Using Linked Lists'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi5vhoXXY6Yuyh7orsLqrtkAzKoujAiRmEJdRhdEcKneVF6iHxDDtY6vBl5X-UlKVEHD7w3TsU4vmQKEFXOiCk9AucB760S4OmiekEXtCtip-G7p-UYz-29-0tvL72tuejKMKHnOKm3RWk/s72-c/linkedlist.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-3304779302557305206</id><published>2015-10-17T12:16:00.003-07:00</published><updated>2015-10-17T12:20:30.089-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked Lists"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Stack"/><title type='text'>Programming: C++ Program to Implement Stack Using Linked List</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This C++ program, using iteration, implements the list of elements removed from the stack in last in first out mode using a linked list. A linked list is an ordered set of data elements, each containing a link to its successor.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzaEYD_vhFQZAlEkIhdmXCqJ_FbfDmNQawkr-MfnbUUQiQYgoItA2hLSCXY2mvK17JaEVxa1NLngbyph08cwMboSj8C8Ye_as8sxZRYdgTz3UIXG_fLYzb4fKlzCqFtSa5hCNj3Fx6ZwUs/s1600/62.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;261&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzaEYD_vhFQZAlEkIhdmXCqJ_FbfDmNQawkr-MfnbUUQiQYgoItA2hLSCXY2mvK17JaEVxa1NLngbyph08cwMboSj8C8Ye_as8sxZRYdgTz3UIXG_fLYzb4fKlzCqFtSa5hCNj3Fx6ZwUs/s320/62.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here is the source code of the C++ program to display the list of elements removed from the stack. The C++ program is successfully compiled and run on DevCpp, a C++ compiler. The program output is also shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
*
 * C++ Program to Implement Queue using Linked List
 */
#include &lt; iostream &gt;
#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
using namespace std;
struct node
{
    int data;
    node *next;
}*front = NULL, *rear = NULL, *p = NULL, *np = NULL;
void push(int x)
{
    np = new node;
    np-&gt;data = x;
    np-&gt;next = NULL;
    if(front == NULL)
    {
        front = rear = np;
        rear-&gt;next = NULL;
    }
    else
    {
        rear-&gt;next = np;
        rear = np;
        rear-&gt;next = NULL;
    }
}
int remove()
{
    int x;
    if (front == NULL)
    {
        cout &lt;&lt; &quot;empty queue\n&quot;;
    }
    else
    {
        p = front;
        x = p-&gt;data;
        front = front-&gt;next;
        delete(p);
        return(x);
    }
}
int main()
{
    int n, c = 0, x;
    cout &lt;&lt; &quot;Enter the number of values to be pushed into queue\n&quot;;
    cin &gt;&gt; n;
    while (c &lt; n)
    {
 cout &lt;&lt; &quot;Enter the value to be entered into queue\n&quot;;
 cin &gt;&gt; x;
        push(x);
        c++;
    }
    cout &lt;&lt; &quot;\n\nRemoved Values\n\n&quot;;
    while(true)
    {
        if (front != NULL)
            cout &lt;&lt; remove() &lt;&lt; endl;
 else
     break;
    }
    getch();
}
&lt;/pre&gt;
&lt;br/&gt;
Here is the output of the program:
&lt;pre class=&quot;brush: cpp&quot;&gt;
Output
Enter the number of values to be pushed into queue
6
Enter the value to be entered into queue
5
Enter the value to be entered into queue
4
Enter the value to be entered into queue
3
Enter the value to be entered into queue
2
Enter the value to be entered into queue
1
Enter the value to be entered into queue
0
 
Removed Values
 
5
4
3
2
1
0
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/3304779302557305206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-implement.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3304779302557305206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3304779302557305206'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-implement.html' title='Programming: C++ Program to Implement Stack Using Linked List'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzaEYD_vhFQZAlEkIhdmXCqJ_FbfDmNQawkr-MfnbUUQiQYgoItA2hLSCXY2mvK17JaEVxa1NLngbyph08cwMboSj8C8Ye_as8sxZRYdgTz3UIXG_fLYzb4fKlzCqFtSa5hCNj3Fx6ZwUs/s72-c/62.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-8007127021512818411</id><published>2015-10-15T10:50:00.002-07:00</published><updated>2015-10-15T11:20:58.978-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="Heap"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: C++ program to implement Heap</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
A heap is a partially sorted binary tree. Although a heap is not completely in order, it conforms to a sorting principle: every node has a value less (for the sake of simplicity, we will assume that all orderings are from least to greatest) than either of its children. Additionally, a heap is a &quot;complete tree&quot; -- a complete tree is one in which there are no gaps between leaves. For instance, a tree with a root node that has only one child must have its child as the left node. More precisely, a complete tree is one that has every level filled in before adding a node to the next level, and one that has the nodes in a given level filled in from left to right, with no breaks.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw47-jQxUIL3mxCcGQ6LiRJcVIoguhS6flSyu6oKDfeTojn_aaOuNXnx0KNghBDJ9kac7_Hh6SA_TKHkRZLGiiIBcRCM2l-OCLlKWTZIHaioosXkUjsF6wv6KSP-n6196gL9u_1G1Oo-Jk/s1600/completetree.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw47-jQxUIL3mxCcGQ6LiRJcVIoguhS6flSyu6oKDfeTojn_aaOuNXnx0KNghBDJ9kac7_Hh6SA_TKHkRZLGiiIBcRCM2l-OCLlKWTZIHaioosXkUjsF6wv6KSP-n6196gL9u_1G1Oo-Jk/s1600/completetree.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Why use a heap?&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
A heap can be thought of as a priority queue; the most important node will always be at the top, and when removed, its replacement will be the most important. This can be useful when coding algorithms that require certain things to processed in a complete order, but when you don&#39;t want to perform a full sort or need to know anything about the rest of the nodes. For instance, a well-known algorithm for finding the shortest distance between nodes in a graph, Dijkstra&#39;s Algorithm, can be optimized by using a priority queue.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;C++ Implementation of Heap&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt; 
/*
 * C++ Program to Implement Heap
 */
#include &lt; iostream &gt;
#include &lt; cstdlib &gt;
#include &lt; vector &gt;
#include &lt; iterator &gt;
using namespace std;
/*
 * Class Declaration
 */
class Heap
{
    private:
        vector &lt; int &gt; heap;
        int left(int parent);
        int right(int parent);
        int parent(int child);
        void heapifyup(int index);
        void heapifydown(int index);
    public:
        Heap()
        {}
        void Insert(int element);
        void DeleteMin();
        int ExtractMin();
        void DisplayHeap();
        int Size();
};

/*
 * Return Heap Size
 */
int Heap::Size()
{
    return heap.size();
}
 
/*
 * Insert Element into a Heap
 */
void Heap::Insert(int element)
{
    heap.push_back(element);
    heapifyup(heap.size() -1);
}
/*
 * Delete Minimum Element
 */
void Heap::DeleteMin()
{
    if (heap.size() == 0)
    {
        cout &lt;&lt; &quot;Heap is Empty&quot; &lt;&lt; endl;
        return;
    }
    heap[0] = heap.at(heap.size() - 1);
    heap.pop_back();
    heapifydown(0);
    cout &lt;&lt; &quot;Element Deleted&quot; &lt;&lt; endl;
}
 
/*
 * Extract Minimum Element
 */
int Heap::ExtractMin()
{
    if (heap.size() == 0)
    {
        return -1;
    }
    else
        return heap.front();
}
 
/*
 * Display Heap
 */
void Heap::DisplayHeap()
{
    vector &lt; int &gt;::iterator pos = heap.begin();
    cout &lt;&lt; &quot;Heap --&gt;  &quot;;
    while (pos != heap.end())
    {
        cout &lt;&lt; *pos &lt;&lt; &quot; &quot;;
        pos++;
    }
    cout &lt;&lt; endl;
}
 
/*
 * Return Left Child
 */
int Heap::left(int parent)
{
    int l = 2 * parent + 1;
    if(l &lt; heap.size())
        return l;
    else
        return -1;
}
 
/*
 * Return Right Child
 */
int Heap::right(int parent)
{
    int r = 2 * parent + 2;
    if(r &lt; heap.size())
        return r;
    else
        return -1;
}
 
/*
 * Return Parent
 */
int Heap::parent(int child)
{
    int p = (child - 1)/2;
    if(child == 0)
        return -1;
    else
        return p;
}
 
/*
 * Heapify- Maintain Heap Structure bottom up
 */
void Heap::heapifyup(int in)
{
    if (in &gt;= 0 &amp;&amp; parent(in) &gt;= 0 &amp;&amp; heap[parent(in)] &gt; heap[in])
    {
        int temp = heap[in];
        heap[in] = heap[parent(in)];
        heap[parent(in)] = temp;
        heapifyup(parent(in));
    }
}
 
/*
 * Heapify- Maintain Heap Structure top down
 */
void Heap::heapifydown(int in)
{
 
    int child = left(in);
    int child1 = right(in);
    if (child &gt;= 0 &amp;&amp; child1 &gt;= 0 &amp;&amp; heap[child] &gt; heap[child1])
    {
       child = child1;
    }
    if (child &gt; 0)
    {
        int temp = heap[in];
        heap[in] = heap[child];
        heap[child] = temp;
        heapifydown(child);
    }
}
 
/*
 * Main Contains Menu
 */
int main()
{
    Heap h;
    while (1)
    {
        cout &lt;&lt; &quot;------------------&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;Operations on Heap&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;------------------&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;1.Insert Element&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;2.Delete Minimum Element&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;3.Extract Minimum Element&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;4.Print Heap&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;5.Exit&quot; &lt;&lt; endl;
        int choice, element;
        cout&lt;&lt;&quot;Enter your choice: &quot;;
        cin&gt;&gt;choice;
        switch(choice)
        {
        case 1:
            cout &lt;&lt; &quot;Enter the element to be inserted: &quot;;
            cin &gt;&gt; element;
            h.Insert(element);
            break;
        case 2:
            h.DeleteMin();
            break;
        case 3:
            cout &lt;&lt; &quot;Minimum Element: &quot;;
            if (h.ExtractMin() == -1)
            {
                cout &lt;&lt; &quot;Heap is Empty&quot; &lt;&lt; endl;
            }
            else
                cout &lt;&lt; &quot;Minimum Element:  &quot; &lt;&lt; h.ExtractMin() &lt;&lt; endl;
            break;
        case 4:
            cout &lt;&lt; &quot;Displaying elements of Hwap:  &quot;;
            h.DisplayHeap();
            break;
        case 5:
            exit(1);
        default:
            cout &lt;&lt; &quot;Enter Correct Choice&quot; &lt;&lt; endl;
        }
    }
    return 0;
}
&lt;/pre&gt;

&lt;h3&gt;Output of the above program:&lt;/h3&gt;

&lt;pre class=&quot;brush:cpp&quot;&gt;
$ g++ heap.cpp
$ a.out
/*
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 7
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  7
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 4
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  4 7
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 9
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  4 7 9
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 3
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  3 4 9 7
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 3
Minimum Element: Minimum Element:  3
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 5
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  3 4 9 7 5
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 11
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  3 4 9 7 5 11
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 2
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  2 4 3 7 5 11 9
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 2
Element Deleted
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  3 4 11 7 5 9
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 3
Minimum Element: Minimum Element:  3
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 2
Element Deleted
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap:  Heap --&gt;  4 5 11 7 9
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 3
Minimum Element: Minimum Element:  4
------------------
Operations on Heap
------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 5
 
------------------
(program exited with code: 0)
Press return to continue
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/8007127021512818411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-implement-heap.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8007127021512818411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8007127021512818411'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-implement-heap.html' title='Programming: C++ program to implement Heap'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw47-jQxUIL3mxCcGQ6LiRJcVIoguhS6flSyu6oKDfeTojn_aaOuNXnx0KNghBDJ9kac7_Hh6SA_TKHkRZLGiiIBcRCM2l-OCLlKWTZIHaioosXkUjsF6wv6KSP-n6196gL9u_1G1Oo-Jk/s72-c/completetree.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-5059233899983401605</id><published>2015-10-14T08:25:00.001-07:00</published><updated>2015-10-14T08:25:13.440-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: C++ Program to Implement Hash Table</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What is hash table ?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Do not confuse this with Hash List or Hash Tree.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;From Wikipedia about hash table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In computing, a hash table (hash map) is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Ideally, the hash function will assign each key to a unique bucket, but it is possible that two keys will generate an identical hash causing both keys to point to the same bucket. Instead, most hash table designs assume that hash collisions—different keys that are assigned by the hash function to the same bucket—will occur and must be accommodated in some way.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPQoHanK8JSFVEFTcNGjHltUHagyq2jWOdWWgmZgE69GgCNQCW5YIbvy_3DASQruMs5nxRBqTl5YmsENbgB0qeRouRfZnFgInccuXkkK1iFjbH1VSnf5-FqVrD6pVY8H9Wi9x0_SflFc2K/s1600/2000px-Hash_table_5_0_1_1_1_1_1_LL.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPQoHanK8JSFVEFTcNGjHltUHagyq2jWOdWWgmZgE69GgCNQCW5YIbvy_3DASQruMs5nxRBqTl5YmsENbgB0qeRouRfZnFgInccuXkkK1iFjbH1VSnf5-FqVrD6pVY8H9Wi9x0_SflFc2K/s400/2000px-Hash_table_5_0_1_1_1_1_1_LL.svg.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This C++ Program demonstrates operations on Hash Tables&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here is source code of the C++ Program to demonstrate Hash Tables. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
/*
 *C++ Program to Implement Hash Tables
 */
#include&lt;iostream&gt;
#include&lt;cstdlib&gt;
#include&lt;string&gt;
#include&lt;cstdio&gt;
using namespace std;
const int TABLE_SIZE = 128;
 
/*
 * HashEntry Class Declaration
 */
class HashEntry
{
    public:
        int key;
        int value;
        HashEntry(int key, int value)
        {
            this-&gt;key = key;
            this-&gt;value = value;
        }
};
 
/*
 * HashMap Class Declaration
 */
class HashMap
{
    private:
        HashEntry **table;
    public:   
        HashMap()
	{
            table = new HashEntry * [TABLE_SIZE];
            for (int i = 0; i&lt; TABLE_SIZE; i++)
            {
                table[i] = NULL;
            }
        }
        /*
         * Hash Function
         */
        int HashFunc(int key)
        {
            return key % TABLE_SIZE;
        }
        /*
         * Insert Element at a key
         */
	void Insert(int key, int value)
	{
            int hash = HashFunc(key);
            while (table[hash] != NULL &amp;&amp; table[hash]-&gt;key != key)
            {
                hash = HashFunc(hash + 1);
            }
            if (table[hash] != NULL)
                delete table[hash];
            table[hash] = new HashEntry(key, value);
	}
        /*
         * Search Element at a key
         */
        int Search(int key)
	{
	    int  hash = HashFunc(key);
	    while (table[hash] != NULL &amp;&amp; table[hash]-&gt;key != key)
	    {
	        hash = HashFunc(hash + 1);
	    }
	    if (table[hash] == NULL)
	        return -1;
	    else
	        return table[hash]-&gt;value;
        }
 
        /*
         * Remove Element at a key
         */
        void Remove(int key)
	{
	    int hash = HashFunc(key);
	    while (table[hash] != NULL)
	    {
	        if (table[hash]-&gt;key == key)
	            break;
	        hash = HashFunc(hash + 1);
	    }
            if (table[hash] == NULL)
	    {
                cout&lt;&lt;&quot;No Element found at key &quot;&lt;&lt;key&lt;&lt;endl;
                return;
            }
            else
            {
                delete table[hash];
            }
            cout&lt;&lt;&quot;Element Deleted&quot;&lt;&lt;endl;
        }
        ~HashMap()
	{
            for (int i = 0; i &lt; TABLE_SIZE; i++)
            {
                if (table[i] != NULL)
                    delete table[i];
                delete[] table;
            }
        }
};
/*
 * Main Contains Menu
 */
int main()
{
    HashMap hash;
    int key, value;
    int choice;
    while (1)
    {
        cout&lt;&lt;&quot;\n----------------------&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Operations on Hash Table&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;\n----------------------&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;1.Insert element into the table&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;2.Search element from the key&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;3.Delete element at a key&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;4.Exit&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Enter your choice: &quot;;
        cin&gt;&gt;choice;
        switch(choice)
        {
        case 1:
            cout&lt;&lt;&quot;Enter element to be inserted: &quot;;
            cin&gt;&gt;value;
            cout&lt;&lt;&quot;Enter key at which element to be inserted: &quot;;
            cin&gt;&gt;key;
            hash.Insert(key, value);
            break;
        case 2:
            cout&lt;&lt;&quot;Enter key of the element to be searched: &quot;;
            cin&gt;&gt;key;
            if (hash.Search(key) == -1)
            {
	        cout&lt;&lt;&quot;No element found at key &quot;&lt;&lt;key&lt;&lt;endl;
	        continue;
	    }
	    else
	    {
	        cout&lt;&lt;&quot;Element at key &quot;&lt;&lt;key&lt;&lt;&quot; : &quot;;
	        cout&lt;&lt;hash.Search(key)&lt;&lt;endl;
	    }
            break;
        case 3:
            cout&lt;&lt;&quot;Enter key of the element to be deleted: &quot;;
            cin&gt;&gt;key;
            hash.Remove(key);
            break;
        case 4:
            exit(1);
        default:
           cout&lt;&lt;&quot;\nEnter correct option\n&quot;;
       }
    }
    return 0;
}
&lt;/pre&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
$ g++ hash_table.cpp
$ a.out
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 12
Enter key at which element to be inserted: 1
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 24
Enter key at which element to be inserted: 2
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 36
Enter key at which element to be inserted: 3
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 48
Enter key at which element to be inserted: 4
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 60
Enter key at which element to be inserted: 5
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 3
Element at key 3 : 36
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 5
Element at key 5 : 60
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 3
Enter key of the element to be deleted: 4
Element Deleted
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 4
No element found at key 4
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 2
Element at key 2 : 24
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 4
 
 
------------------
(program exited with code: 1)
Press return to continue
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/5059233899983401605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-implement-hash.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5059233899983401605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5059233899983401605'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-implement-hash.html' title='Programming: C++ Program to Implement Hash Table'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPQoHanK8JSFVEFTcNGjHltUHagyq2jWOdWWgmZgE69GgCNQCW5YIbvy_3DASQruMs5nxRBqTl5YmsENbgB0qeRouRfZnFgInccuXkkK1iFjbH1VSnf5-FqVrD6pVY8H9Wi9x0_SflFc2K/s72-c/2000px-Hash_table_5_0_1_1_1_1_1_LL.svg.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-8398534751370996129</id><published>2015-10-14T08:13:00.001-07:00</published><updated>2015-10-14T08:13:46.658-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="Graph"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: C Program to Represent Graph Using Adjacency Matrix</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This C program generates graph using Adjacency Matrix Method.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A graph G,consists of two sets V and E. V is a finite non-empty set of vertices.E is a set of pairs of vertices,these pairs are called as edges V(G) and E(G) will represent the sets of vertices and edges of graph G.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Undirected graph &lt;/b&gt;– It is a graph with V vertices and E edges where E edges are undirected. In undirected graph, each edge which is present between the vertices Vi and Vj,is represented by using a pair of round vertices (Vi,Vj).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Directed graph&lt;/b&gt; – It is a graph with V vertices and E edges where E edges are directed.In directed graph,if Vi and Vj nodes having an edge.than it is represented by a pair of triangular brackets Vi,Vj.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here is the source code of the C program to create a graph using adjacency matrix. The C program is successfully compiled and run on a Linux system. The program output is also shown below.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;//... A Program to represent a Graph by using an Adjacency Matrix method
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
int dir_graph();
int undir_graph();
int read_graph(int adj_mat[50][50], int n );

void main()
{
   int option;
   do
   {     
        printf(&quot;\n A Program to represent a Graph by using an &quot;);
  printf(&quot;Adjacency Matrix method \n &quot;);
  printf(&quot;\n 1. Directed Graph &quot;);
  printf(&quot;\n 2. Un-Directed Graph &quot;);
  printf(&quot;\n 3. Exit &quot;);
  printf(&quot;\n\n Select a proper option : &quot;);
  scanf(&quot;%d&quot;, &amp;amp;option);
  switch(option)
  {
    case 1 : dir_graph();
       break;
    case 2 : undir_graph();
       break;
    case 3 : exit(0);
  } // switch
    }while(1);
}
 
int dir_graph()
{
    int adj_mat[50][50];
    int n;
    int in_deg, out_deg, i, j;
    printf(&quot;\n How Many Vertices ? : &quot;);
    scanf(&quot;%d&quot;, &amp;amp;n);
    read_graph(adj_mat, n);
    printf(&quot;\n Vertex \t In_Degree \t Out_Degree \t Total_Degree &quot;);
    for (i = 1; i &amp;lt;= n ; i++ )
    {
        in_deg = out_deg = 0;
 for ( j = 1 ; j &amp;lt;= n ; j++ )
 {
            if ( adj_mat[j][i] == 1 )
                in_deg++;
 } 
        for ( j = 1 ; j &amp;lt;= n ; j++ )
            if (adj_mat[i][j] == 1 )
                out_deg++;
            printf(&quot;\n\n %5d\t\t\t%d\t\t%d\t\t%d\n\n&quot;,i,in_deg,out_deg,in_deg+out_deg);
    }
    return;
}
 
int undir_graph()
{
    int adj_mat[50][50];
    int deg, i, j, n;
    printf(&quot;\n How Many Vertices ? : &quot;);
    scanf(&quot;%d&quot;, &amp;amp;n);
    read_graph(adj_mat, n);
    printf(&quot;\n Vertex \t Degree &quot;);
    for ( i = 1 ; i &amp;lt;= n ; i++ )
    {
        deg = 0;
        for ( j = 1 ; j &amp;lt;= n ; j++ )
            if ( adj_mat[i][j] == 1)
                deg++;
        printf(&quot;\n\n %5d \t\t %d\n\n&quot;, i, deg);
    } 
    return;
} 
 
int read_graph ( int adj_mat[50][50], int n )
{
    int i, j;
    char reply;
    for ( i = 1 ; i &amp;lt;= n ; i++ )
    {
        for ( j = 1 ; j &amp;lt;= n ; j++ )
        {
            if ( i == j )
            {
                adj_mat[i][j] = 0;
  continue;
            } 
            printf(&quot;\n Vertices %d &amp;amp; %d are Adjacent ? (Y/N) :&quot;,i,j);
            scanf(&quot;%c&quot;, &amp;amp;reply);
            if ( reply == &#39;y&#39; || reply == &#39;Y&#39; )
                adj_mat[i][j] = 1;
            else
                adj_mat[i][j] = 0;
 }
    } 
    return;
}
&lt;/stdlib&gt;&lt;/stdio&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
$ gcc graph.c -o graph
$ ./graph
 A Program to represent a Graph by using an Adjacency Matrix method 
 
 1. Directed Graph 
 2. Un-Directed Graph 
 3. Exit 
 
 Select a proper option : 
 How Many Vertices ? : 
 Vertices 1 &amp; 2 are Adjacent ? (Y/N) : N
 Vertices 1 &amp; 3 are Adjacent ? (Y/N) : Y
 Vertices 1 &amp; 4 are Adjacent ? (Y/N) : Y
 Vertices 2 &amp; 1 are Adjacent ? (Y/N) : Y
 Vertices 2 &amp; 3 are Adjacent ? (Y/N) : Y
 Vertices 2 &amp; 4 are Adjacent ? (Y/N) : N
 Vertices 3 &amp; 1 are Adjacent ? (Y/N) : Y
 Vertices 3 &amp; 2 are Adjacent ? (Y/N) : Y
 Vertices 3 &amp; 4 are Adjacent ? (Y/N) : Y
 Vertices 4 &amp; 1 are Adjacent ? (Y/N) : Y
 Vertices 4 &amp; 2 are Adjacent ? (Y/N) : N
 Vertices 4 &amp; 3 are Adjacent ? (Y/N) : Y
 Vertex   In_Degree   Out_Degree   Total_Degree 
 
     1   2  0  2
 
 
 
     2   1  2  3
 
 
 
     3   0  1  1
 
 
 
     4   1  1  2
 
 
 A Program to represent a Graph by using an Adjacency Matrix method 
 
 1. Directed Graph 
 2. Un-Directed Graph 
 3. Exit
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/8398534751370996129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-represent.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8398534751370996129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8398534751370996129'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-represent.html' title='Programming: C Program to Represent Graph Using Adjacency Matrix'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-7035801417037852058</id><published>2015-10-14T07:57:00.001-07:00</published><updated>2015-10-14T07:57:21.436-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LTE"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><category scheme="http://www.blogger.com/atom/ns#" term="VoLTE"/><title type='text'>What is the difference between VoIP and VoLTE?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
VoIP refers to Voice Over IP, which is a methodology of delivering the voice communication data over the internet.&amp;nbsp;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;V&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;oice over IP (VoIP) refers to sending voice data over the internet. Initially this was only possible using computers (connected o&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;r WiFi). An example would be Skype.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;With mobile phones becoming&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&amp;nbsp;popular (pre-smartphone mostly but also some smartphones) there was an attempt to port VoIP over mobile phones and this was generally referred to as mobile VoIP (mVoIP). You could use cellular data connectivity or WiFi for VoIP in this case.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Nowadays, VoIP is referred for Over The Top (OTT) applications that may use PC&#39;s, tablets, smartphones, etc. Example would be Skype, Viber, WhatsApp, etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Packets are packets and the only thing that knows they are voice is the application that receives than &amp;amp; processes them eg your Skype app. As such that is Layer 7 and they go through L1-L6 exactly as every other packet. They could be going over LTE, over WiFi or over ADSL - it doesn&#39;t matter = packets are packets.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;The cellular world used to have 2 separate core networks called CS (circuit switched) that was used for voice and PS (packet switched) for data. To simplify the network, they started moving Voice over to PS part. For 3G/HSPA this became known as VoHSPA (Voice over HSPA) and for 4G/LTE it is known as VoLTE (Voice over LTE). Since HSPA/LTE is data only network, the networks realised that they can use WiFi for the access network in the same way. Hence VoWiFi is using WiFi for access but the PS network for guaranteeing the quality of service (QoS).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4HObok60HHt0W8p3Y2VDcvW6OLL-kxfDA4er-ZIDGdNPHrH3fpl-2GX1Zn3PVDyaYVNbxMRkn7qP6jsGolPdxQzupRKljUD8fD02MUp6kgG9anxJS7wuDzBMkyc1kHDziRcnDZKlvGsA3/s1600/194_pbx_phone_system_how_to_make_free_international_voip_calls_p513_f1_en.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;125&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4HObok60HHt0W8p3Y2VDcvW6OLL-kxfDA4er-ZIDGdNPHrH3fpl-2GX1Zn3PVDyaYVNbxMRkn7qP6jsGolPdxQzupRKljUD8fD02MUp6kgG9anxJS7wuDzBMkyc1kHDziRcnDZKlvGsA3/s320/194_pbx_phone_system_how_to_make_free_international_voip_calls_p513_f1_en.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;The Voice over LTE, VoLTE scheme was devised as a result of operators seeking a standardised system for transferring traffic for voice over LTE.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Originally LTE was seen as a completely IP cellular system just for carrying data, and operators would be able to carry voice either by reverting to 2G / 3G systems or by using VoIP in one form or another.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;VoLTE is a specific type of VoIP designed into the LTE standard, so it has lots of very specific optimisations and accelerations. &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;In effect, the packets are treated as &quot;special&quot; by the whole LTE network.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;That means it will work better (lower latency, less power, etc) - and as you say, be able to handover to other LTE cells or to 3G/2G legacy networks.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Signals Research Group (very good, very&amp;nbsp;respected&amp;nbsp;consultancy) &amp;amp; Spirent did some testing and confirmed&amp;nbsp;this.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;color: #666666; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Commercially deployed Voice-over-LTE (VoLTE) technology provides better service than 3G Circuit Switched (CS) voice and Internet calling services and Skype software.&lt;/span&gt;&lt;br style=&quot;color: #666666; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #666666; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;The analysis found that VoLTE users enjoyed considerably better call quality, faster connectivity and substantially less drain on the batteries of their mobile devices.&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;color: #666666; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;The report evaluates several attributes including call setup time, call reliability, call quality, network resource requirements, and the impact on battery life. The report’s highlights include:&lt;/span&gt;&lt;/blockquote&gt;
&lt;ul style=&quot;color: #666666; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px; margin: 0px 0px 0px 28px; padding: 8px 0px; text-align: left;&quot;&gt;&lt;ul&gt;&lt;ul&gt;
&lt;li style=&quot;margin: 0px 0px 8px; padding: 0px;&quot;&gt;VoLTE call quality greatly exceeded that of 3G CS voice and was measurable higher than the HD voice service offered by Skype&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 8px; padding: 0px;&quot;&gt;With network loading, and in particular with background applications running on the mobile phone and transferring data with the network, the VoLTE results were considerably better than Skype&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 8px; padding: 0px;&quot;&gt;VoLTE call setup time was nearly twice as fast as 3G Circuit Switched Fallback (CSFB) call setup&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 8px; padding: 0px;&quot;&gt;VoLTE used substantially fewer network resources than Skype voice, which in turn resulted in longer estimated device battery life for the subscriber and a more efficient network for the operator&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;When leaving LTE coverage, VoLTE calls were successfully handed over to 3G CS voice. The network’s enhanced Single Radio Voice Call Continuity ensures calls continue without interruption&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;color: #666666; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;“The clear choice for mobile network operators should be a no brainer,” said Emil Olbrich, vice president of Network Technologies for SRG. “VoLTE delivers a consistently higher call quality than OTT voice applications. Operators should also strongly consider the long-term network savings associated with VoLTE, given that it takes advantage of advanced features that allow it to use far less network resources when it comes to supporting a voice call when compared with current OTT voice applications.”&lt;/span&gt;&amp;nbsp;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;So how do you compare VoLTE, VoWiFi and VoIP. I found this interesting table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcFYdBNiivCbizSmortKnEOUetv7AQXBcCNdVC_LYUlcrO2UIHg2XWdrrnsP7UYqtPvjdbypp2jW4DrM3iCV752l6ReBgTMLD2UqzXy5nZo9F_4CDtmCWiMIzqYMqCvzGTm9TTmvI9xo2g/s1600/main-qimg-d7c0bfab1c66fa4cb0f5072e27aa9cea.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcFYdBNiivCbizSmortKnEOUetv7AQXBcCNdVC_LYUlcrO2UIHg2XWdrrnsP7UYqtPvjdbypp2jW4DrM3iCV752l6ReBgTMLD2UqzXy5nZo9F_4CDtmCWiMIzqYMqCvzGTm9TTmvI9xo2g/s400/main-qimg-d7c0bfab1c66fa4cb0f5072e27aa9cea.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;As can be seen in the table, VoLTE should provide you the best quality, followed by VoWiFi (SIP VoIP) and VoIP wou&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;ld be the worst. Again, the worst may still be good enough for most people most of the time.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/7035801417037852058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/what-is-difference-between-voip-and.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/7035801417037852058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/7035801417037852058'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/what-is-difference-between-voip-and.html' title='What is the difference between VoIP and VoLTE?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4HObok60HHt0W8p3Y2VDcvW6OLL-kxfDA4er-ZIDGdNPHrH3fpl-2GX1Zn3PVDyaYVNbxMRkn7qP6jsGolPdxQzupRKljUD8fD02MUp6kgG9anxJS7wuDzBMkyc1kHDziRcnDZKlvGsA3/s72-c/194_pbx_phone_system_how_to_make_free_international_voip_calls_p513_f1_en.png" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-2751545940987846555</id><published>2015-10-13T08:15:00.004-07:00</published><updated>2015-10-13T08:15:55.251-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Computers"/><category scheme="http://www.blogger.com/atom/ns#" term="Knowledge"/><title type='text'>Knowledge: Some good computer tricks 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;1.&amp;nbsp;Some trick for Gmail users&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;To open only unread emails , just type is:unread in search box.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You can also open is:starred , is:read , is:muted , is:chat.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc0PIxunfp1m6LH9SwRPHBTaMZcQU7TjFsb1A5eNEC7rksaf6IaGccPYiEeN4FeUge9mIC8IkGpKbZHKyvFuzWGdn-3kW1npseiZoLEiW8ntG6tqUCNeP2Bm18icmY4qMSZyDmpgbXOxlO/s1600/gamil.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;255&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc0PIxunfp1m6LH9SwRPHBTaMZcQU7TjFsb1A5eNEC7rksaf6IaGccPYiEeN4FeUge9mIC8IkGpKbZHKyvFuzWGdn-3kW1npseiZoLEiW8ntG6tqUCNeP2Bm18icmY4qMSZyDmpgbXOxlO/s400/gamil.png&quot; width=&quot;400&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;if you want to open unread emails from inbox only then type&lt;/span&gt;&lt;br style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;b style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;is:unread label:inbox&lt;/b&gt;&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&amp;nbsp; in search box.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVITVBLtjbBPoVrkRLL7r-UXVOYCNzwtOwCvakXXF7JkdDvFSBC_ylOLWDOM7ko5NkyMZOv_zygH2327oaWEQcLhY8mWZKAYlA8qPSHgr5pbEguq6KGmG6etgAeXaZsQmGzojgCbUslqoE/s1600/gmail2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;237&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVITVBLtjbBPoVrkRLL7r-UXVOYCNzwtOwCvakXXF7JkdDvFSBC_ylOLWDOM7ko5NkyMZOv_zygH2327oaWEQcLhY8mWZKAYlA8qPSHgr5pbEguq6KGmG6etgAeXaZsQmGzojgCbUslqoE/s400/gmail2.png&quot; width=&quot;400&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;For other&amp;nbsp;labels&amp;nbsp;just use&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;label:spam , label:chats&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;e.t.c&amp;nbsp; and You can combine the keywords according to use.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;2.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;How to enable GodMode on Windows.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;This is a very simple trick.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;a. In any drive of your computer create a New Folder and rename it as GodMode.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;b. Now append the string (without quotes) “.{ED7BA470-8E54-465E-825C-99712043E01C}” after the name of the folder so that the resultant string looks like “GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;c. Once you renamed the folder, the icon of the folder will change automatically and the name will be changed to GodMode.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGWt8t9WaBJbL_E_IXoLOKcXWPeNmDb5cFfFxKXUyEwYARWszUuVC7os2Vd0fNGLPK06i6KMosO4yskduPRglA9-tNkvPkF2gEGxjZpXpv6IwJDCMWYi1JDOajxzSkjUEe-KnLaza4wcNh/s1600/godmode.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGWt8t9WaBJbL_E_IXoLOKcXWPeNmDb5cFfFxKXUyEwYARWszUuVC7os2Vd0fNGLPK06i6KMosO4yskduPRglA9-tNkvPkF2gEGxjZpXpv6IwJDCMWYi1JDOajxzSkjUEe-KnLaza4wcNh/s1600/godmode.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;PS: Note that any changes that you make on the God Mode will be made directly to the system so don’t make any major changes unless you are very sure about it.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;You may rename it i.e. instead of GodMode any other name can be used.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;GodMode contains list of all computer settings.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Below are the two screenshot of the settings. Apart from that there are many more settings you will find in GodMode (all categorized and accessible from one folder- GodMode)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc-Af1AIrafIjQCcqCUYOB2xFpULgzHl6nRD9TdDJD5tXVGjHD_pV3YTAHERmP9_xCK7WB7EP4v4ioMQEvIFWz3aAxlQb5oEnXVDBdQgKD8vCADdDT7S2lSZKIngVwgsSRvhQBtvo6Gawl/s1600/gm3.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc-Af1AIrafIjQCcqCUYOB2xFpULgzHl6nRD9TdDJD5tXVGjHD_pV3YTAHERmP9_xCK7WB7EP4v4ioMQEvIFWz3aAxlQb5oEnXVDBdQgKD8vCADdDT7S2lSZKIngVwgsSRvhQBtvo6Gawl/s320/gm3.png&quot; width=&quot;301&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicteZSPtvWMgb9tWks7WEzJ0Uq-VWhJQn879JQBViMOURAWaabjnIIq94pJwovUtV7KQoFRk7zOhT5B3DCMxbykANrlcWp5rtv2eyXaRpAqcwI5M8dIhNUVNoukTkPwBR7z21zPGGBIiHb/s1600/gm2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;234&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicteZSPtvWMgb9tWks7WEzJ0Uq-VWhJQn879JQBViMOURAWaabjnIIq94pJwovUtV7KQoFRk7zOhT5B3DCMxbykANrlcWp5rtv2eyXaRpAqcwI5M8dIhNUVNoukTkPwBR7z21zPGGBIiHb/s320/gm2.png&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;More to come.. Stay tuned.. :)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/2751545940987846555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/knowledge-some-good-computer-tricks-2.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/2751545940987846555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/2751545940987846555'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/knowledge-some-good-computer-tricks-2.html' title='Knowledge: Some good computer tricks 2'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc0PIxunfp1m6LH9SwRPHBTaMZcQU7TjFsb1A5eNEC7rksaf6IaGccPYiEeN4FeUge9mIC8IkGpKbZHKyvFuzWGdn-3kW1npseiZoLEiW8ntG6tqUCNeP2Bm18icmY4qMSZyDmpgbXOxlO/s72-c/gamil.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-7620733040101042560</id><published>2015-10-13T08:05:00.001-07:00</published><updated>2015-10-13T08:05:13.379-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="Computers"/><category scheme="http://www.blogger.com/atom/ns#" term="Knowledge"/><title type='text'>Knowledge: Some good computer tricks</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;1. Finding Windows Product Key&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Assuming you can boot your computer without any problems, you can easily create a simple VBscript that will read the value out of the registry and then translate it into the format that you need for reinstalling.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Copy and paste the following into a Notepad window:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
MsgBox ConvertToKey(WshShell.RegRead(&quot;HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId&quot;))
 
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = &quot;BCDFGHJKMPQRTVWXY2346789&quot;
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x &amp;gt;= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) &amp;amp; KeyOutput
If (((29 - i) Mod 6) = 0) And (i &amp;lt;&amp;gt; -1) Then
i = i -1
KeyOutput = &quot;-&quot; &amp;amp; KeyOutput
End If
Loop While i &amp;gt;= 0
ConvertToKey = KeyOutput
End Function
&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You’ll need to use File -&amp;gt; Save As, change the “Save as type” to “All Files” and then name it productkey.vbs or something similar ending with the vbs extension. We’d recommend saving to the desktop for easy access.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtHhL7vQvGESHH2c4497qNPW-2TN1bWYXeslZoDkfRkEZEwRWWsoWdk8Wv3BWomGrEW5n5-FhRkbabTdJTlV6WACT3U2FXkXIsComBQDCafeDT4v0du4lh7RuEDMw1QjF9XwmJ1ld_KQtj/s1600/main-qimg-ce70b570fe9ea3a6653ead325fff5c65.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtHhL7vQvGESHH2c4497qNPW-2TN1bWYXeslZoDkfRkEZEwRWWsoWdk8Wv3BWomGrEW5n5-FhRkbabTdJTlV6WACT3U2FXkXIsComBQDCafeDT4v0du4lh7RuEDMw1QjF9XwmJ1ld_KQtj/s400/main-qimg-ce70b570fe9ea3a6653ead325fff5c65.png&quot; width=&quot;400&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-size: 15px; line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you’ve saved it, you can just double-click and the popup window will show you your product key.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioT17dVBBODxKpuU0J8djfLbd89GTUW5uYieGU0dyi8PJEHayPtkaIO5e0ZbIk7ZpkcNtPEvmkyPlQLzims7zUqRmNvKI13xLi6ddFnwiDXog6pB_gKd8Bf4_qBmt4nTRKEQMoWIqla_Q7/s1600/main-qimg-027f279aee427ffcab6f54a6d2b81fe1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;142&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioT17dVBBODxKpuU0J8djfLbd89GTUW5uYieGU0dyi8PJEHayPtkaIO5e0ZbIk7ZpkcNtPEvmkyPlQLzims7zUqRmNvKI13xLi6ddFnwiDXog6pB_gKd8Bf4_qBmt4nTRKEQMoWIqla_Q7/s400/main-qimg-027f279aee427ffcab6f54a6d2b81fe1.png&quot; width=&quot;400&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Note :- If you use CTRL + C when the popup window is active, it will copy the contents of the window to the clipboard, and then you can paste it into Notepad or somewhere else.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;2.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Locate Your Android Phone Easily&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;It is very common situation when you can&#39;t find your phone. Then you start looking for it , searching in places like under the pillow , in some jeans pocket, bag etc, or may be that you left it in some place which definitely &amp;nbsp;you don&#39;t recall. Then you find some one who could make a call , but you realize that its on silent mod.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;There are some apps available but what if you are just like me and a lot of us who don&#39;t have it installed. Here comes a Giant to save you all and search your android Phone in minutes. You don&#39;t need to find some other phone to ring your to find or to find the location of the phone if it is lost/stolen. The Giant named Google has it all figured out.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkwJI8crsrv_7uWVfrLiFuf2tmKh0MQc-5W-Fuyre8qyzPB76ZRxToFWAeA10TNbeVRG4Xh-yFZfbynTolg75CZNuImbF30J5hBBhbFzIlRJB7r_24m6jii97TEgxNPAziodKgl8cpHiC8/s1600/main-qimg-027f279aee427ffcab6f54a6d2b81fesda1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkwJI8crsrv_7uWVfrLiFuf2tmKh0MQc-5W-Fuyre8qyzPB76ZRxToFWAeA10TNbeVRG4Xh-yFZfbynTolg75CZNuImbF30J5hBBhbFzIlRJB7r_24m6jii97TEgxNPAziodKgl8cpHiC8/s400/main-qimg-027f279aee427ffcab6f54a6d2b81fesda1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;on Google just search &amp;nbsp;&quot;find my phone&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Baam!, There you go.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Google will now locate your phone.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif; font-size: 15px; line-height: 21px;&quot;&gt;You can now Ring you phone for 5 min in full volume even if it was in silent mod. It actually schedules a ring if the phone cannot be reached instantly.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif; font-size: 15px; line-height: 21px;&quot;&gt;You can in worst case erase your phone, helpful when phone gets stolen and sensitive data is there.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif; font-size: 15px; line-height: 21px;&quot;&gt;You can now be little more careless.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;b&gt;3.&amp;nbsp;Create your own wifi hotspot on Windows 7 or 8 without using any external applications&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;You don&#39;t need &quot;Connectify&quot; or any other software for it. Also, you can save yourself from that 90 minutes counter in connectify.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana, sans-serif;&quot;&gt;&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
All you need to do is run the following two commands in cmd -&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
Open cmd with Run as Administrator.&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
1) netsh wlan set hostednetwork mode=allow ssid=wifiname key=wifipassword&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
2) netsh wlan start hostednetwork&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
Best solution - Make a batch file of it and just run the file every time when you start the pc.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
To make a batch file -&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
First write the commands on a notepad&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 15px; line-height: 21px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3zzdohEJ9fc4kE85Ux_UuLu26cVCYzpPCFLBQ6UZ41htTYtGxy_6vhDJeJb9QVb5o2RNejrMzT_BXoM6DaegU8nw5gc2A5YMbAtR59CsgM3w6BVOODwAXgtSD5nHK58l5cYpU586XbhRF/s1600/notebatch.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;136&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3zzdohEJ9fc4kE85Ux_UuLu26cVCYzpPCFLBQ6UZ41htTYtGxy_6vhDJeJb9QVb5o2RNejrMzT_BXoM6DaegU8nw5gc2A5YMbAtR59CsgM3w6BVOODwAXgtSD5nHK58l5cYpU586XbhRF/s400/notebatch.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Then save it with the extension bat. &amp;nbsp;e.g. wifi.bat&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Your batch file is made and now execute the file with Admin Privileges.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Important - For this to work, your sharing should be on in network properties for &amp;nbsp;the network/ethernet connection that you want to share through your &amp;nbsp;wifi:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Go to Open Network and Sharing Centre -&amp;gt;Change Adapter Settings(On left panel)\&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Your wifi hotspot would be Microsoft Hosted Network Virtual Adaptor in the Network Connections.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Go to the properties of the LAN/ethernet/WiFi connection and make the changes accordingly.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMNS8i5V2Wl40I_KXNe3gfTmD0b1PTA2Fp36POa4E-7v_pCbAzOGRJT7Pp_6yFkabeW8E2YchU77fDLxWNYsrqSry7EFQKQj4V5DmlBKqqCeroY8bGW4Afkq1TJn4qHgc-1vyhIDm4ZG7O/s1600/wifihot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;295&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMNS8i5V2Wl40I_KXNe3gfTmD0b1PTA2Fp36POa4E-7v_pCbAzOGRJT7Pp_6yFkabeW8E2YchU77fDLxWNYsrqSry7EFQKQj4V5DmlBKqqCeroY8bGW4Afkq1TJn4qHgc-1vyhIDm4ZG7O/s400/wifihot.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Your wifi hotspot would be ready. :)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;To stop the wifi hotspot -&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Write the following in command prompt (or create a batch file similar to above) : netsh wlan stop hostednetwork.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;More coming soon.. :)&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/7620733040101042560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/knowledge-some-good-computer-tricks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/7620733040101042560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/7620733040101042560'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/knowledge-some-good-computer-tricks.html' title='Knowledge: Some good computer tricks'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtHhL7vQvGESHH2c4497qNPW-2TN1bWYXeslZoDkfRkEZEwRWWsoWdk8Wv3BWomGrEW5n5-FhRkbabTdJTlV6WACT3U2FXkXIsComBQDCafeDT4v0du4lh7RuEDMw1QjF9XwmJ1ld_KQtj/s72-c/main-qimg-ce70b570fe9ea3a6653ead325fff5c65.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-3152799149457505934</id><published>2015-10-13T07:42:00.002-07:00</published><updated>2015-10-13T07:42:42.089-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GSM"/><category scheme="http://www.blogger.com/atom/ns#" term="Sim cards"/><category scheme="http://www.blogger.com/atom/ns#" term="umts"/><title type='text'>GSM: Difference between UMTS SIM (USIM) and GSM SIM</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcg5vMfZO4NID-IUFtcmFd05RMUvkkDLANZQn4hPivpTZYcLkJdKr2GCVsNqCwNFD92FLSyfbRZulyODWzbsOiRFhwCWQKLneMuDRqxvaDtPWG0xK2Hs5EnsOy01BR6Jt8lOf8-KYVFYN0/s1600/main-qimg-f0f5b07833be3bcc8e28c70caeaed369.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;117&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcg5vMfZO4NID-IUFtcmFd05RMUvkkDLANZQn4hPivpTZYcLkJdKr2GCVsNqCwNFD92FLSyfbRZulyODWzbsOiRFhwCWQKLneMuDRqxvaDtPWG0xK2Hs5EnsOy01BR6Jt8lOf8-KYVFYN0/s320/main-qimg-f0f5b07833be3bcc8e28c70caeaed369.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;SIM and USIM&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
SIM cards (Subscriber Identity Module) are used to communicate on GSM networks and USIMs were introduced together with UMTS or 3G network.&lt;br /&gt;
&lt;br /&gt;
Although it&#39;s possible to access 3G with a simple SIM card, the USIM have many advantages as compared to the SIM:&lt;br /&gt;
&lt;br /&gt;
• A USIM is a tiny computer which is able to handle several mini internal applications, for instance a contact-less e-purse for the subway, a local service portal giving you access to your phone bill, etc, while SIM&#39;s analog is simple SIM menu which can&#39;t compute something by own other than communicating with carrier&#39;s server;&lt;br /&gt;
Bigger and Improved phone-book: USIM allows you to store thousands of contacts (limit on SIM is 255). Each contact can now contain email id and more than one phone number;&lt;br /&gt;
&lt;br /&gt;
• A 3G (UMTS) handset equipped with a USIM card can be used to make video calls on 3g network;&lt;br /&gt;
&lt;br /&gt;
• New and improved security algorithms are used to prevent unauthorized access to phone line, encrypt your calls and internet traffic and store contacts securely;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/3152799149457505934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/gsm-difference-between-umts-sim-usim.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3152799149457505934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3152799149457505934'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/gsm-difference-between-umts-sim-usim.html' title='GSM: Difference between UMTS SIM (USIM) and GSM SIM'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcg5vMfZO4NID-IUFtcmFd05RMUvkkDLANZQn4hPivpTZYcLkJdKr2GCVsNqCwNFD92FLSyfbRZulyODWzbsOiRFhwCWQKLneMuDRqxvaDtPWG0xK2Hs5EnsOy01BR6Jt8lOf8-KYVFYN0/s72-c/main-qimg-f0f5b07833be3bcc8e28c70caeaed369.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-5937811570269205796</id><published>2015-10-13T07:37:00.005-07:00</published><updated>2015-10-13T07:37:41.437-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GSM"/><title type='text'>GSM: Why is the channel spacing in GSM 900 just 200KHz?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I&#39;ve came across this question so many times in the period of telecommunication learning. Every time I asked the question, there was no one to properly answer the question, may be it was because I couldn&#39;t phrase the question in easily understandable way. Eventually I came across a few answers, here is the most convincing one from quora..&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUITI5An4HniEmDj2-5PntwVyO_ie5fPWWCu0J8JXuqGxk2MkmSt5DG_EYgv2iGPU9cNa267LUzwcWoQGt4exYt9BuvTw2V6kq9FiUwCcYoyAmr54UU83UpPkUe_CNZEGqsuLpbSKSJyHd/s1600/GSMLogo.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;192&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUITI5An4HniEmDj2-5PntwVyO_ie5fPWWCu0J8JXuqGxk2MkmSt5DG_EYgv2iGPU9cNa267LUzwcWoQGt4exYt9BuvTw2V6kq9FiUwCcYoyAmr54UU83UpPkUe_CNZEGqsuLpbSKSJyHd/s320/GSMLogo.svg.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;u&gt;Why the channel spacing in GSM 900 is just 200KHz ?&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;It was a trade-off: wider channels = more bandwidth and more users.&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 21px;&quot;&gt;Narrower channels are easier to implement (the&amp;nbsp;equalizer) *&lt;/span&gt;&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Other, very similar TDMA/FDD chose different channel sizes:&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;US D-AMPS / IS136 used 30KHZ (but only had three users instead of 8 or 16)&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;Japan&#39;s PDC used 25KHz, again for 3 users&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;GSM beat both of those. I don&#39;t know that proves 200KHz was &quot;better&quot;&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;There is no unique &quot;right answer&quot;&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;If you do an archive trawl through 3GPP standards from early 90s you&#39;ll probably find the analysis (I wish you luck...!)&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;* Remember these decisions were taken 20 years ago: the technology at the time is relevant, not what you can do now.&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;NOTE&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;i style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;It uses 25MHz each in 890-915 MHz and 935-960 MHz ranges with 200khz channel spacing&amp;nbsp;&lt;/i&gt;&lt;br style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 15px; line-height: 21px;&quot;&gt;That is not completely correct: GSM uses many more ranges than that e around 850 and 1800.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/5937811570269205796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/gsm-why-is-channel-spacing-in-gsm-900.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5937811570269205796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5937811570269205796'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/gsm-why-is-channel-spacing-in-gsm-900.html' title='GSM: Why is the channel spacing in GSM 900 just 200KHz?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUITI5An4HniEmDj2-5PntwVyO_ie5fPWWCu0J8JXuqGxk2MkmSt5DG_EYgv2iGPU9cNa267LUzwcWoQGt4exYt9BuvTw2V6kq9FiUwCcYoyAmr54UU83UpPkUe_CNZEGqsuLpbSKSJyHd/s72-c/GSMLogo.svg.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-8138071593748634146</id><published>2015-10-12T09:16:00.001-07:00</published><updated>2015-10-12T09:16:11.838-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Reverse a stack using Recursion</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
You are not allowed to use loop constructs like while, for..etc, and you can only use the following ADT functions on Stack S:&lt;br /&gt;
&lt;br /&gt;
1. isEmpty(S)&lt;br /&gt;
2. push(S)&lt;br /&gt;
3. pop()&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Solution&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The idea of the solution is to hold all values in Function Call Stack until the stack becomes empty. When the stack becomes empty, insert all held items one by one at the bottom of the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;1 -&amp;gt; top of the STACK
2
3
4 -&amp;gt; bottom of the STACK

First 4 is inserted at the bottom.
4

Then 3 is inserted at the bottom.
4 
3

Then 2 is inserted at the bottom.
4 
3
2

Then 1 is inserted at the bottom
4 
3
2
1 -&amp;gt; bottom of the STACK 
&lt;/pre&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;So we need a function that inserts at the bottom of a&amp;nbsp;&lt;span style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 600; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stack&lt;/span&gt;&amp;nbsp;using the above given basic stack function.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;//Below is a&amp;nbsp;&lt;span style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 600; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;recursive function&lt;/span&gt;&amp;nbsp;that&amp;nbsp;&lt;span style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 600; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;inserts an element&lt;/span&gt;&amp;nbsp;at the bottom of a stack.&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;void insertAtBottom(struct sNode** top_ref, int item)
{
   int temp; 
   if(isEmpty(*top_ref))
   { 
       push(top_ref, item);
   }
   else
   {     
     /* Hold all items in Function Call Stack until we reach end of
       the stack. When the stack becomes empty, the isEmpty(*top_ref)
       becomes true, the above if part is executed and the item is
       inserted at the bottom */
     temp = pop(top_ref);
     insertAtBottom(top_ref, item);

     /* Once the item is inserted at the bottom, push all the
          items held in Function Call Stack */
     push(top_ref, temp);
   }            
}
&lt;/pre&gt;
&lt;br /&gt;
//Below is the function that reverses the given stack using insertAtBottom()
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;void reverse(struct sNode** top_ref)
{
  int temp;  
  if(!isEmpty(*top_ref))
  {

    /* Hold all items in Function Call Stack until we reach end of
     the stack */
    temp = pop(top_ref);                       
    reverse(top_ref);

    /* Insert all the items (held in Function Call Stack) one by one
       from the bottom to top. Every item is inserted at the bottom */
    insertAtBottom(top_ref, temp);
  }     
}
&lt;/pre&gt;
&lt;br /&gt;
//Below is a complete running program for testing above functions.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
#include
#include
#define bool int
/* structure of a stack node */
struct sNode
{
   char data;
   struct sNode *next;
};
/* Function Prototypes */
void push(struct sNode** top_ref, int new_data);
int pop(struct sNode** top_ref);
bool isEmpty(struct sNode* top);
void print(struct sNode* top);
/* Driveer program to test above functions */
int main()
{
  struct sNode *s = NULL;
  push(&amp;s, 4);
  push(&amp;s, 3);
  push(&amp;s, 2);
  push(&amp;s, 1); 
  printf(&quot;\n Original Stack &quot;);
  print(s);
  reverse(&amp;s);
  printf(&quot;\n Reversed Stack &quot;); 
  print(s);
  getchar();
}   
/* Function to check if the stack is empty */
bool isEmpty(struct sNode* top)
{
  return (top == NULL)? 1 : 0;
}
/* Function to push an item to stack*/
void push(struct sNode** top_ref, int new_data)
{
  /* allocate node */
  struct sNode* new_node =
            (struct sNode*) malloc(sizeof(struct sNode));
  if(new_node == NULL)
  {
     printf(&quot;Stack overflow \n&quot;);
     getchar();
     exit(0);
  }         
  /* put in the data  */
  new_node-&gt;data  = new_data;
  /* link the old list off the new node */
  new_node-&gt;next = (*top_ref);
  /* move the head to point to the new node */
  (*top_ref)    = new_node;
}
/* Function to pop an item from stack*/
int pop(struct sNode** top_ref)
{
  char res;
  struct sNode *top;
  /*If stack is empty then error */
  if(*top_ref == NULL)
  {
     printf(&quot;Stack overflow \n&quot;);
     getchar();
     exit(0);
  }
  else
  {
     top = *top_ref;
     res = top-&gt;data;
     *top_ref = top-&gt;next;
     free(top);
     return res;
  }
}
/* Functrion to pront a linked list */
void print(struct sNode* top)
{
  printf(&quot;\n&quot;);
  while(top != NULL)
  {
    printf(&quot; %d &quot;, top-&gt;data);
    top =  top-&gt;next;
  }
}
&lt;/pre&gt;

Later...
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/8138071593748634146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-reverse-stack-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8138071593748634146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8138071593748634146'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-reverse-stack-using.html' title='Programming: Reverse a stack using Recursion'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-3891986940157129375</id><published>2015-10-12T08:44:00.000-07:00</published><updated>2015-10-12T08:54:41.509-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: C program to print all permutations of a given string</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself.&lt;br /&gt;
&lt;br /&gt;
A string of length n has n! permutation.
Source: Mathword(http://mathworld.wolfram.com/Permutation.html)&lt;br /&gt;
&lt;br /&gt;
Below are the permutations of string&lt;br /&gt;
ABC.
ABC, ACB, BAC, BCA, CAB, CBA&lt;br /&gt;
&lt;br /&gt;
Here is a solution using backtracking.

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtmbbhz-z6XAQbgJiQuRhcZ7IuT8i_4CZK39IX8wVOp7Grx0pNzk0-Cnosolc9I6Cr5kP4a8EUbH7ZratN2dfWWqPA5JptoKy049z8_Y8AI0h0oUyVzuPXLj116sq5eiTKhB5TY5hbSITt/s1600/NewPermutation.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtmbbhz-z6XAQbgJiQuRhcZ7IuT8i_4CZK39IX8wVOp7Grx0pNzk0-Cnosolc9I6Cr5kP4a8EUbH7ZratN2dfWWqPA5JptoKy049z8_Y8AI0h0oUyVzuPXLj116sq5eiTKhB5TY5hbSITt/s640/NewPermutation.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;These permute2 values themselves can be broken down to smaller subproblems.&lt;br /&gt;&lt;a href=&quot;http://www.eandbsoftware.org/wp-content/uploads/2013/07/CodeCogsEqn-1.gif&quot; style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #3b8dbd; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; transition-duration: 0.2s; transition-timing-function: ease; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;CodeCogsEqn (1)&quot; class=&quot;alignnone size-full wp-image-1320&quot; src=&quot;http://www.eandbsoftware.org/wp-content/uploads/2013/07/CodeCogsEqn-1.gif&quot; height=&quot;18&quot; style=&quot;border-radius: 2px; border: 0px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 0px; max-width: 100%; padding: 0px; transition: opacity 0.2s ease; vertical-align: baseline;&quot; width=&quot;526&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here, it is obvious that permute1(any char) = char itself. This is the base case of this recursion. Unrolling the recursion for the 3 required values yields:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;permute2(“BC”) = { “BC”, “CB” }&lt;br /&gt;permute2(“AC”) = { “AC”, “CA”}&lt;br /&gt;permute2(“AB”) = {“AB”, “BA”}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So the resultant sets of strings are:&lt;br /&gt;permute3(“ABC”) = {“ABC”, “ACB”} U {“BAC”, “BCA”} U {“CAB”, “CBA”}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;which is the set of all permutations of the string “ABC”. It is obvious to see that we are in fact just choosing the starting prefix of the permutation and then requesting the permute function to run on a smaller sub-problem of permuting a smaller string.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;To generalize, we can state that we can get all the permutations of a string using the general recurrence:&lt;br /&gt;&lt;a href=&quot;http://www.eandbsoftware.org/wp-content/uploads/2013/07/CodeCogsEqn-2.gif&quot; style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #3b8dbd; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; transition-duration: 0.2s; transition-timing-function: ease; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;CodeCogsEqn (2)&quot; class=&quot;alignnone size-full wp-image-1321&quot; src=&quot;http://www.eandbsoftware.org/wp-content/uploads/2013/07/CodeCogsEqn-2.gif&quot; height=&quot;47&quot; style=&quot;border-radius: 2px; border: 0px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 0px; max-width: 100%; padding: 0px; transition: opacity 0.2s ease; vertical-align: baseline;&quot; width=&quot;353&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
C
# include 
 
/* Function to swap values at two pointers */
void swap (char *x, char *y)
{
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
  
/* Function to print permutations of string
   This function takes three parameters:
   1. String
   2. Starting index of the string
   3. Ending index of the string. */
void permute(char *a, int i, int n)
{
   int j;
   if (i == n)
     printf(&quot;%s\n&quot;, a);
   else
   {
        for (j = i; j &lt;= n; j++)
       {
          swap((a+i), (a+j));
          permute(a, i+1, n);
          swap((a+i), (a+j)); //backtrack
       }
   }
}
 
/* Driver program to test above functions */
int main()
{
   char a[] = &quot;ABC&quot;; 
   permute(a, 0, 2);
   getchar();
   return 0;
}

Output:

ABC
ACB
BAC
BCA
CBA
CAB
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;
Algorithm Paradigm: Backtracking
Time Complexity: O(n*n!)&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;
Please write comments if you find the above codes/algorithms incorrect, or find other ways to solve the same problem.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #444444; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; font-weight: 400; letter-spacing: -0.5px; line-height: 1.3em; margin: 0px 0px 14px; padding: 0px; text-align: left; vertical-align: baseline; white-space: normal; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;The diagram shows recursive execution of&amp;nbsp;&lt;span style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 600; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;permute()&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;For i = 0 and j = 0
A is fixed at first place using below line
swap((a+i), (a+j)) /*A is swapped with A*/
Then all the permutations of BC (sub-string after A) are printed
permute(a, i+1, n);  /*Call permute for BC  with i = 1  */
Finally swap the characters back
swap((a+i), (a+j)) /*A is swapped with A*/
For i = 0 and j = 1
B is fixed at first place using below line
swap((a+i), (a+j)) /*A is swapped with B*/
Then all the permutations of BC (sub-string after A) are printed
permute(a, i+1, n);  /*Call permute for AC  with i = 1 */
Finally, swap the characters back
swap((a+i), (a+j)) /*B is swapped with A*/
For i = 0 and j = 2
C is fixed at first place using below line
swap((a+i), (a+j)) /*A is swapped with C*/
Then all the permutations of BC (sub-string after A) are printed
permute(a, i+1, n);  /*Call permute for BA with i = 1 */
Finally, swap the characters back
swap((a+i), (a+j)) /*C is swapped with A*/
For i = 1, second character is swapped one by one with the other characters (after second character). Same way is continued for i = 2, 3..
&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;
To understand how this works, just look at the string “ABC”.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;
Let us assume that we have a magic function permute2 that generates all possible permutations of a given string of length 2.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;
Then, the permutations problem for the string “ABC” can then be broken down as:
&lt;span style=&quot;color: #3b8dbd; font-family: inherit;&quot;&gt;&lt;span style=&quot;border-color: initial; border-radius: 2px; border-style: initial; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; transition-delay: initial; transition-property: opacity;&quot;&gt;&lt;img alt=&quot;CodeCogsEqn&quot; class=&quot;alignnone size-full wp-image-1318&quot; height=&quot;39&quot; src=&quot;http://www.eandbsoftware.org/wp-content/uploads/2013/07/CodeCogsEqn.gif&quot; style=&quot;border-radius: 2px; border: 0px; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 0px; max-width: 100%; padding: 0px; transition: opacity 0.2s ease; vertical-align: baseline;&quot; width=&quot;401&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Titillium, Arial, sans-serif; font-stretch: inherit; line-height: 28.8px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;
&lt;/div&gt;

Hope it will be useful to you..
Source: http://www.eandbsoftware.org/
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/3891986940157129375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-print-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3891986940157129375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3891986940157129375'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2015/10/programming-c-program-to-print-all.html' title='Programming: C program to print all permutations of a given string'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtmbbhz-z6XAQbgJiQuRhcZ7IuT8i_4CZK39IX8wVOp7Grx0pNzk0-Cnosolc9I6Cr5kP4a8EUbH7ZratN2dfWWqPA5JptoKy049z8_Y8AI0h0oUyVzuPXLj116sq5eiTKhB5TY5hbSITt/s72-c/NewPermutation.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-1104209922221591898</id><published>2013-11-13T02:06:00.001-08:00</published><updated>2013-11-13T02:06:58.576-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Code"/><category scheme="http://www.blogger.com/atom/ns#" term="Computers"/><category scheme="http://www.blogger.com/atom/ns#" term="Images"/><category scheme="http://www.blogger.com/atom/ns#" term="Knowledge"/><title type='text'>[Knowledge]: How are images displayed on screen by code ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;First, a little about how we perceive images
and then the details about how it is displayed on the computer screen.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;Every object&#39;s color we see is a composite of
Red, Green and Blue components. The mixture of these primary colors in
different proportions produces the entire spectrum of colors we can see. There
are two ways we can understand this - One is the additive color system and the
second is the subtractive color system. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;In an additive color scheme, we understand
colors as a mixture of primary colors - Red, Green and Blue (RGB). For example,
Yellow is an equal mixture of Red and Green colors. White is an equal mixture
or red, green, blue components.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;In the subtractive scheme, we understand colors
based on what quantities of primary colors are absorbed by an object and what
is reflected off of it. For example, an object in white light that absorbs no
wavelengths of the visible light spectrum appears white because it reflects
everything. Similarly, an object appears black because it absorbs everything
and reflects nothing.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;How colors are
represented in a computer and rendered on the screen:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;In a computer, the primary colors Red, Green
and Blue are represented by bits. These bits are rendered by tiny display units
called pixels. The display unit is a huge grid of individual pixels and each
pixel can display a mixture of primary colors. Now if you have one bit for each
color RGB, how many different colors could be represented with it? The answer
is 2^3=8 colors. Each bit can take a value 0 or 1. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;R G B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; R G B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; R
G B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R G B&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;0&amp;nbsp; 0
0&amp;nbsp; &amp;nbsp; =
Black&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp;0&amp;nbsp;0&amp;nbsp; = Red&amp;nbsp; &amp;nbsp;&amp;nbsp;0&amp;nbsp; 1 0
= Green&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0 0&amp;nbsp; 1 = Blue&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;R G B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;R G B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;R
G B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; R G B&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;1&amp;nbsp; 1&amp;nbsp; 1 &amp;nbsp; =
White&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; 1 0 = Yellow&amp;nbsp;&amp;nbsp; 0&amp;nbsp; 1 1
= Cyan &amp;nbsp; 1&amp;nbsp;
0&amp;nbsp; 1&amp;nbsp; = Magenta&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;Computers usually deal with 8 bits of
information for every color for each pixel. So each component R,G or B can take
256 different values. That&#39;s 256 different shades of Red, Green and Blue or
256^3 = 16 million different color combinations that can represent virtually
any color possible.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIokAafXd2Ccrc-WRvcsj4uNXlPlc3QZ5d0_qZu2eDQTxuA0cX9QHNmvTD-ERwjjzVMkyEHo4uMPpK18BvSVr1UoTbzTsa_5njtnlbBAgy_N7eCV-WD9G4Ht78o3uE1kS7coV6j-M2mD-n/s1600/main-qimg-ff4a5c37dc8f13c2f81e29e407200725.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;228&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIokAafXd2Ccrc-WRvcsj4uNXlPlc3QZ5d0_qZu2eDQTxuA0cX9QHNmvTD-ERwjjzVMkyEHo4uMPpK18BvSVr1UoTbzTsa_5njtnlbBAgy_N7eCV-WD9G4Ht78o3uE1kS7coV6j-M2mD-n/s320/main-qimg-ff4a5c37dc8f13c2f81e29e407200725.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;An image file like bitmap (.bmp) consists of
color data for each pixel and color in a grid called the raster. You can
visualize the raster as follows:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXd287nO1pCGeFcVXFh2FQEdQIIPqCbFliyRxtKnaecsAIe0B8H0JvOdt2n0l20eAlPDOiRsGu2g5xdhDcjmnah25iQfzu9QEF90WyHH-1YqrTKZ6kF8jDdQ6rhXR38VMcfFx1mS3GhlHA/s1600/new2.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXd287nO1pCGeFcVXFh2FQEdQIIPqCbFliyRxtKnaecsAIe0B8H0JvOdt2n0l20eAlPDOiRsGu2g5xdhDcjmnah25iQfzu9QEF90WyHH-1YqrTKZ6kF8jDdQ6rhXR38VMcfFx1mS3GhlHA/s1600/new2.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span style=&quot;color: #333333; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;Each square represents a pixel and for each pixel, the image file holds the exact mixture of Red, Green and Blue colors. On a monitor, there are thousands of pixels close to each other. They are so tiny that the human eye cannot spot them. This is the secret of producing a life like image on screen. Because the pixels are so densely packed (On a 15 inch screen with resolution of 1366x768, there are 104 pixels per inch (PPI), the human eye cannot distinguish between individual pixels. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span id=&quot;docs-internal-guid-18084a60-50e4-b132-a7d8-dbde6f8ba28b&quot;&gt;&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This raster data is then mapped to the screen where it is displayed. Each pixel takes the color corresponding to it&#39;s position in the raster data. See the image below. On the left side is the image that you normally see. But when you zoom in, you can see individual pixels taking different colors.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;color: #333333; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNwQt_F_678Lp12xDujXdGRjUIDZTuc6b1ggExVbr7VH0H_gnJ2YFzxUGmdVdIQ-100TD7eMjHbc8tHI9JRSrG2Y4Ja_JMuUeA5FNIeIZhHTgAHADxk-CF56IcHPxRjWCcLOoUbROCG9kQ/s1600/new3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;143&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNwQt_F_678Lp12xDujXdGRjUIDZTuc6b1ggExVbr7VH0H_gnJ2YFzxUGmdVdIQ-100TD7eMjHbc8tHI9JRSrG2Y4Ja_JMuUeA5FNIeIZhHTgAHADxk-CF56IcHPxRjWCcLOoUbROCG9kQ/s400/new3.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;color: #333333; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;How are pixels actually rendered on screen?&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;normal&quot;&gt;
&lt;span id=&quot;docs-internal-guid-18084a60-50e6-1350-abb7-7e71852fb409&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: Arial; font-size: 13px; font-weight: bold; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This depends on the type of monitor. In the old days, we had the Cathode Ray Tube (CRT monitor).&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp85qNHUi5CuepWiLIICba3EdlnO27qRPHUek2TDwLCAF-Kll6kVfMd8vyQ6hgZMbeIcjldI1CDKAaZYEK9oAlFLaIoe40dbVhiLeZAmI2i_mUPQl-MKZOYtw3EgD_RbwYqLU32UunrF82/s1600/new4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp85qNHUi5CuepWiLIICba3EdlnO27qRPHUek2TDwLCAF-Kll6kVfMd8vyQ6hgZMbeIcjldI1CDKAaZYEK9oAlFLaIoe40dbVhiLeZAmI2i_mUPQl-MKZOYtw3EgD_RbwYqLU32UunrF82/s320/new4.jpg&quot; width=&quot;268&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In a CRT monitor, there exists a device called the electron gun which shoots electrons onto a phosphor screen. Phosphor is a fluorescent material and glows when electrons bombard them. The color produced by the phosphor element depends of the energy of the electrons which is controlled by the electron gun. &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;b id=&quot;docs-internal-guid-18084a60-50ea-2389-28a2-4ed5c9f294f4&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The electron gun shoots electrons and the trajectory of electrons is controlled by magnetic deflections. Based on the raster data, the electron gun starts at the top left and shoots electrons line by line at the desired energy based on the color that is to be produced at that point. Once it reaches the bottom of the screen, it goes back up and repeats. This process is called scanning and the rate at which it happens is called the refresh rate. &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;We have come a far way from CRTs and now have TFT LCD (Thin film transistor Liquid Crystal Display) screens. These screens work very differently. They rely on a special property of Liquid Crystals in the presence/absence of an electric field. Liquid crystals in a twisted nematic state reorient polarized light.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;In a LCD display, the liquid crystal is sandwiched between two polarizers that are 90 degrees out of phase (1 and 5 in the figure below are polarizers).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEima6muWhwARxWJLIx6bQLYMQeU-gbdMhYhpNFWD3gLIySdmxs3dum5rGfF-lMP5JRpiIwoTlQ0X-LzMTCBskPHcgMR3-tgf964FybRKjV7XmmNE4pHsjAShpe317obBCDhMnd-AgQ2M4kx/s1600/new5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEima6muWhwARxWJLIx6bQLYMQeU-gbdMhYhpNFWD3gLIySdmxs3dum5rGfF-lMP5JRpiIwoTlQ0X-LzMTCBskPHcgMR3-tgf964FybRKjV7XmmNE4pHsjAShpe317obBCDhMnd-AgQ2M4kx/s400/new5.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;When light passes through the first polarizer, it gets horizontally oriented. When there is no electric field, the Liquid crystal reorients this light and brings it in phase with the second polarizer. When an electric field is applied, the molecules in the liquid crystal align with the field and untwist. In this state, it doesn&#39;t reorient the light. Since the light is 90 degrees out of phase with the second polarizer, it cannot pass through it. White light source is used to illuminate the panel and filters are used to produce color.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In a &amp;nbsp;TFT LCD, the electric field is controlled by thin silicon transistors arranged in a grid. Each pixel in the grid has a liquid crystal element sandwiched between two capacitive plates supplied by the transistors. By turning the transistors on and off, we can control the intensity and color produced by the pixels.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgARHXUDXu9r6rR3qVZOyCmrHDUaNyCM_P7ilCXXBvsuWd2eD3ZTfclk1DBh7acltBCIVOSE4m6GjGmwUci4FXvySEheI45lTUHFsbZPFmLF2pMywwlRobBmo4Xzu2jeqcoM9p0wcOb3OSg/s1600/new6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgARHXUDXu9r6rR3qVZOyCmrHDUaNyCM_P7ilCXXBvsuWd2eD3ZTfclk1DBh7acltBCIVOSE4m6GjGmwUci4FXvySEheI45lTUHFsbZPFmLF2pMywwlRobBmo4Xzu2jeqcoM9p0wcOb3OSg/s320/new6.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span id=&quot;docs-internal-guid-18084a60-50ec-17c6-38ea-d54759d6f4a8&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The hardware takes care of rendering the image and the device drivers know how to communicate the raster to the hardware (it&#39;s hardware specific). The only thing left is to create the image file. There are different formats, but they all contain the RGB information about pixels.&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;fffeewww.... Thats huge... Hope now you know how these things actually work. This article has been contributed by someone on quora so I thought its useful..&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #333333; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Later, people.... :)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/1104209922221591898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/11/knowledge-how-are-images-displayed-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/1104209922221591898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/1104209922221591898'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/11/knowledge-how-are-images-displayed-on.html' title='[Knowledge]: How are images displayed on screen by code ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIokAafXd2Ccrc-WRvcsj4uNXlPlc3QZ5d0_qZu2eDQTxuA0cX9QHNmvTD-ERwjjzVMkyEHo4uMPpK18BvSVr1UoTbzTsa_5njtnlbBAgy_N7eCV-WD9G4Ht78o3uE1kS7coV6j-M2mD-n/s72-c/main-qimg-ff4a5c37dc8f13c2f81e29e407200725.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-1610097232801667535</id><published>2013-11-12T20:50:00.000-08:00</published><updated>2013-11-12T20:51:22.234-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="inorder"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="traversal"/><title type='text'>Algorithm: Inorder Tree Traversal without Recursion</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Its been a long time since I&#39;d posted something about programming and algorithms. I&#39;ve been reading a lot more about algorithms, so found one perfectly explained article, thought I should share it with you people.&lt;br /&gt;
&lt;br /&gt;
Using Stack is the obvious way to traverse tree without recursion. Below is an algorithm for traversing binary tree using stack.&lt;br /&gt;
&lt;b&gt;See this for step wise step execution of the algorithm.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1) Create an empty stack S.&lt;br /&gt;
2) Initialize current node as root&lt;br /&gt;
3) Push the current node to S and set current = current-&amp;gt;left until current is NULL&lt;br /&gt;
4) If current is NULL and stack is not empty then&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a) Pop the top item from stack.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b) Print the popped item, set current = current-&amp;gt;right&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c) Go to step 3.&lt;br /&gt;
5) If current is NULL and stack is empty then we are done.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Let us consider the below tree for example:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; / &amp;nbsp; \&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; / &amp;nbsp;\&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; 5&lt;br /&gt;
&lt;br /&gt;
Step 1 Creates an empty stack: S = NULL&lt;br /&gt;
&lt;br /&gt;
Step 2 sets current as address of root: current -&amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
Step 3 Pushes the current node and set current = current-&amp;gt;left until current is NULL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;current -&amp;gt; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;push 1: Stack S -&amp;gt; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;current -&amp;gt; 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;push 2: Stack S -&amp;gt; 2, 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;current -&amp;gt; 4&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;push 4: Stack S -&amp;gt; 4, 2, 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;current = NULL&lt;br /&gt;
&lt;br /&gt;
Step 4 pops from S&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a) Pop 4: Stack S -&amp;gt; 2, 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b) print &quot;4&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c) current = NULL /*right of 4 */ and go to step 3&lt;br /&gt;
Since current is NULL step 3 doesn&#39;t do anything.&lt;br /&gt;
&lt;br /&gt;
Step 4 pops again.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a) Pop 2: Stack S -&amp;gt; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b) print &quot;2&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c) current -&amp;gt; 5/*right of 2 */ and go to step 3&lt;br /&gt;
&lt;br /&gt;
Step 3 pushes 5 to stack and makes current NULL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Stack S -&amp;gt; 5, 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;current = NULL&lt;br /&gt;
&lt;br /&gt;
Step 4 pops from S&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a) Pop 5: Stack S -&amp;gt; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b) print &quot;5&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c) current = NULL /*right of 5 */ and go to step 3&lt;br /&gt;
Since current is NULL step 3 doesn&#39;t do anything&lt;br /&gt;
&lt;br /&gt;
Step 4 pops again.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a) Pop 1: Stack S -&amp;gt; NULL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b) print &quot;1&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c) current -&amp;gt; 3 /*right of 5 */ &lt;br /&gt;
&lt;br /&gt;
Step 3 pushes 3 to stack and makes current NULL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Stack S -&amp;gt; 3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;current = NULL&lt;br /&gt;
&lt;br /&gt;
Step 4 pops from S&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a) Pop 3: Stack S -&amp;gt; NULL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b) print &quot;3&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c) current = NULL /*right of 3 */ &lt;br /&gt;
&lt;br /&gt;
Traversal is done now as stack S is empty and current is NULL.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Implementation:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
#define bool int

/* A binary tree tNode has data, pointer to left child
&amp;nbsp; &amp;nbsp;and a pointer to right child */
struct tNode
{
&amp;nbsp; &amp;nbsp;int data;
&amp;nbsp; &amp;nbsp;struct tNode* left;
&amp;nbsp; &amp;nbsp;struct tNode* right;
};

/* Structure of a stack node. Linked List implementation is used for
&amp;nbsp; &amp;nbsp;stack. A stack node contains a pointer to tree node and a pointer to
&amp;nbsp; &amp;nbsp;next stack node */

struct sNode
{
&amp;nbsp; struct tNode *t;
&amp;nbsp; struct sNode *next;
};

/* Stack related functions */
void push(struct sNode** top_ref, struct tNode *t);
struct tNode *pop(struct sNode** top_ref);
bool isEmpty(struct sNode *top);

/* Iterative function for inorder tree traversal */
void inOrder(struct tNode *root)
{
&amp;nbsp; /* set current to root of binary tree */
 struct tNode *current = root;
&amp;nbsp; struct sNode *s = NULL; &amp;nbsp;/* Initialize stack s */
&amp;nbsp; bool done = 0;
&amp;nbsp; while (!done)
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; /* Reach the left most tNode of the current tNode */
&amp;nbsp; &amp;nbsp; if(current != &amp;nbsp;NULL)
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; /* place pointer to a tree node on the stack before traversing
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; the node&#39;s left subtree */
&amp;nbsp; &amp;nbsp; &amp;nbsp; push(&amp;amp;s, current); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; current = current-&amp;gt;left; 
&amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; /* backtrack from the empty subtree and visit the tNode
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at the top of the stack; however, if the stack is empty,
&amp;nbsp; &amp;nbsp; &amp;nbsp; you are done */
&amp;nbsp; &amp;nbsp; else &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (!isEmpty(s))
&amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current = pop(&amp;amp;s);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;, current-&amp;gt;data);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* we have visited the node and its left subtree.
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Now, it&#39;s right subtree&#39;s turn */
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current = current-&amp;gt;right;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; else
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; done = 1;
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; } /* end of while */
} &amp;nbsp; &amp;nbsp;

/* UTILITY FUNCTIONS */

/* Function to push an item to sNode*/
void push(struct sNode** top_ref, struct tNode *t)
{
&amp;nbsp; /* allocate tNode */
&amp;nbsp; struct sNode* new_tNode =
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (struct sNode*) malloc(sizeof(struct sNode));
&amp;nbsp; if(new_tNode == NULL)
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;Stack Overflow \n&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;getchar();
&amp;nbsp; &amp;nbsp; &amp;nbsp;exit(0);
&amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; /* put in the data &amp;nbsp;*/
&amp;nbsp; new_tNode-&amp;gt;t &amp;nbsp;= t;&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;&amp;nbsp; /* link the old list off the new tNode */
&amp;nbsp; new_tNode-&amp;gt;next = (*top_ref); &amp;nbsp;

&amp;nbsp; /* move the head to point to the new tNode */
&amp;nbsp; (*top_ref) &amp;nbsp; &amp;nbsp;= new_tNode;
}

/* The function returns true if stack is empty, otherwise false */
bool isEmpty(struct sNode *top)
{
&amp;nbsp; &amp;nbsp;return (top == NULL)? 1 : 0;
} &amp;nbsp;
/* Function to pop an item from stack*/

struct tNode *pop(struct sNode** top_ref)
{
&amp;nbsp; struct tNode *res;
&amp;nbsp; struct sNode *top;

&amp;nbsp; /*If sNode is empty then error */
&amp;nbsp; if(isEmpty(*top_ref))
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;Stack Underflow \n&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;getchar();
&amp;nbsp; &amp;nbsp; &amp;nbsp;exit(0);
&amp;nbsp; }
&amp;nbsp; else
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp;top = *top_ref;
&amp;nbsp; &amp;nbsp; &amp;nbsp;res = top-&amp;gt;t;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*top_ref = top-&amp;gt;next;
&amp;nbsp; &amp;nbsp; &amp;nbsp;free(top);
&amp;nbsp; &amp;nbsp; &amp;nbsp;return res;
&amp;nbsp; }
}

/* Helper function that allocates a new tNode with the
&amp;nbsp; &amp;nbsp;given data and NULL left and right pointers. */
struct tNode* newtNode(int data)
{
&amp;nbsp; struct tNode* tNode = (struct tNode*)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;malloc(sizeof(struct tNode));
&amp;nbsp; tNode-&amp;gt;data = data;
&amp;nbsp; tNode-&amp;gt;left = NULL;
&amp;nbsp; tNode-&amp;gt;right = NULL;

&amp;nbsp; return(tNode);
}

/* Driver program to test above functions*/
int main()
{

&amp;nbsp; /* Constructed binary tree is

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; / &amp;nbsp; \

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;3

&amp;nbsp; &amp;nbsp; &amp;nbsp; / &amp;nbsp;\

&amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; 5

&amp;nbsp; */
&amp;nbsp; struct tNode *root = newtNode(1);
&amp;nbsp; root-&amp;gt;left &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= newtNode(2);
&amp;nbsp; root-&amp;gt;right &amp;nbsp; &amp;nbsp; &amp;nbsp; = newtNode(3);
&amp;nbsp; root-&amp;gt;left-&amp;gt;left &amp;nbsp;= newtNode(4);
&amp;nbsp; root-&amp;gt;left-&amp;gt;right = newtNode(5);

&amp;nbsp; inOrder(root);

&amp;nbsp; getchar();
&amp;nbsp; return 0;
}&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;Time Complexity: O(n)&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;This article has been shared from Geeks for Geeks. Please let me know if you have any concern about anything in this article.&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;&lt;/pre&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;Later folks.... :)&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/1610097232801667535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/11/algorithm-inorder-tree-traversal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/1610097232801667535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/1610097232801667535'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/11/algorithm-inorder-tree-traversal.html' title='Algorithm: Inorder Tree Traversal without Recursion'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-5222015319289761351</id><published>2013-10-30T01:54:00.001-07:00</published><updated>2013-10-30T01:54:47.465-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked Lists"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Reverse alternate K nodes in a Singly Linked List</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given a linked list, write a function to reverse every alternate k nodes (where k is an input to the function) in an efficient way. Give the complexity of your algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;
Inputs: &amp;nbsp; 1-&amp;gt;2-&amp;gt;3-&amp;gt;4-&amp;gt;5-&amp;gt;6-&amp;gt;7-&amp;gt;8-&amp;gt;9-&amp;gt;NULL and k = 3&lt;br /&gt;
Output: &amp;nbsp; 3-&amp;gt;2-&amp;gt;1-&amp;gt;4-&amp;gt;5-&amp;gt;6-&amp;gt;9-&amp;gt;8-&amp;gt;7-&amp;gt;NULL.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Method 1 (Process 2k nodes and recursively call for rest of the list)&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This method is basically an extension of the method discussed in this post.&lt;br /&gt;
kAltReverse(struct node *head, int k)&lt;br /&gt;
&amp;nbsp; 1) &amp;nbsp;Reverse first k nodes.&lt;br /&gt;
&amp;nbsp; 2) &amp;nbsp;In the modified list head points to the kth node. &amp;nbsp;So change next&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;of head to (k+1)th node&lt;br /&gt;
&amp;nbsp; 3) &amp;nbsp;Move the current pointer to skip next k nodes.&lt;br /&gt;
&amp;nbsp; 4) &amp;nbsp;Call the kAltReverse() recursively for rest of the n - 2k nodes.&lt;br /&gt;
&amp;nbsp; 5) &amp;nbsp;Return new head of the list.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;#include&amp;lt;stdio.h&amp;gt;

#include&amp;lt;stdlib.h&amp;gt;



/* Link list node */

struct node

{

&amp;nbsp; &amp;nbsp; int data;

&amp;nbsp; &amp;nbsp; struct node* next;

};



/* Reverses alternate k nodes and

&amp;nbsp; &amp;nbsp;returns the pointer to the new head node */

struct node *kAltReverse(struct node *head, int k)

{

&amp;nbsp; &amp;nbsp; struct node* current = head;

&amp;nbsp; &amp;nbsp; struct node* next;

&amp;nbsp; &amp;nbsp; struct node* prev = NULL;

&amp;nbsp; &amp;nbsp; int count = 0; &amp;nbsp;



&amp;nbsp; &amp;nbsp; /*1) reverse first k nodes of the linked list */

&amp;nbsp; &amp;nbsp; while (current != NULL &amp;amp;&amp;amp; count &amp;lt; k)

&amp;nbsp; &amp;nbsp; {

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;next &amp;nbsp;= current-&amp;gt;next;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;current-&amp;gt;next = prev;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;prev = current;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;current = next;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count++;

&amp;nbsp; &amp;nbsp; }

&amp;nbsp; 

&amp;nbsp; &amp;nbsp; /* 2) Now head points to the kth node. &amp;nbsp;So change next

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;of head to (k+1)th node*/

&amp;nbsp; &amp;nbsp; if(head != NULL)

&amp;nbsp; &amp;nbsp; &amp;nbsp; head-&amp;gt;next = current; &amp;nbsp;



&amp;nbsp; &amp;nbsp; /* 3) We do not want to reverse next k nodes. So move the current

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pointer to skip next k nodes */

&amp;nbsp; &amp;nbsp; count = 0;

&amp;nbsp; &amp;nbsp; while(count &amp;lt; k-1 &amp;amp;&amp;amp; current != NULL )

&amp;nbsp; &amp;nbsp; {

&amp;nbsp; &amp;nbsp; &amp;nbsp; current = current-&amp;gt;next;

&amp;nbsp; &amp;nbsp; &amp;nbsp; count++;

&amp;nbsp; &amp;nbsp; }



&amp;nbsp; &amp;nbsp; /* 4) Recursively call for the list starting from current-&amp;gt;next.

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;And make rest of the list as next of first node */

&amp;nbsp; &amp;nbsp; if(current != &amp;nbsp;NULL)

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;current-&amp;gt;next = kAltReverse(current-&amp;gt;next, k);



&amp;nbsp; &amp;nbsp; /* 5) prev is new head of the input list */

&amp;nbsp; &amp;nbsp; return prev;

}



/* UTILITY FUNCTIONS */

/* Function to push a node */

void push(struct node** head_ref, int new_data)

{

&amp;nbsp; &amp;nbsp; /* allocate node */

&amp;nbsp; &amp;nbsp; struct node* new_node =

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (struct node*) malloc(sizeof(struct node));



&amp;nbsp; &amp;nbsp; /* put in the data &amp;nbsp;*/

&amp;nbsp; &amp;nbsp; new_node-&amp;gt;data &amp;nbsp;= new_data;



&amp;nbsp; &amp;nbsp; /* link the old list off the new node */

&amp;nbsp; &amp;nbsp; new_node-&amp;gt;next = (*head_ref); &amp;nbsp; 



&amp;nbsp; &amp;nbsp; /* move the head to point to the new node */

&amp;nbsp; &amp;nbsp; (*head_ref) &amp;nbsp; &amp;nbsp;= new_node;

}



/* Function to print linked list */

void printList(struct node *node)

{

&amp;nbsp; &amp;nbsp; int count = 0;

&amp;nbsp; &amp;nbsp; while(node != NULL)

&amp;nbsp; &amp;nbsp; {

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &amp;nbsp;&quot;, node-&amp;gt;data);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; node = node-&amp;gt;next;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;

&amp;nbsp; &amp;nbsp; }

} &amp;nbsp; 



/* Drier program to test above function*/

int main(void)

{

&amp;nbsp; &amp;nbsp; /* Start with the empty list */

&amp;nbsp; &amp;nbsp; struct node* head = NULL;



&amp;nbsp; &amp;nbsp; // create a list 1-&amp;gt;2-&amp;gt;3-&amp;gt;4-&amp;gt;5...... -&amp;gt;20

&amp;nbsp; &amp;nbsp; for(int i = 20; i &amp;gt; 0; i--)

&amp;nbsp; &amp;nbsp; &amp;nbsp; push(&amp;amp;head, i);



&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n Given linked list \n&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp;printList(head);

&amp;nbsp; &amp;nbsp; &amp;nbsp;head = kAltReverse(head, 3);



&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n Modified Linked list \n&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp;printList(head);



&amp;nbsp; &amp;nbsp; &amp;nbsp;getchar();

&amp;nbsp; &amp;nbsp; &amp;nbsp;return(0);

}&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
Given linked list&lt;br /&gt;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20&lt;br /&gt;
Modified Linked list&lt;br /&gt;
3 2 1 4 5 6 9 8 7 10 11 12 15 14 13 16 17 18 20 19&lt;br /&gt;
&lt;br /&gt;
Time Complexity: O(n)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Method 2 (Process k nodes and recursively call for rest of the list)&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The method 1 reverses the first k node and then moves the pointer to k nodes ahead. So method 1 uses two while loops and processes 2k nodes in one recursive call.&lt;br /&gt;
&lt;br /&gt;
This method processes only k nodes in a recursive call. It uses a third bool parameter b which decides whether to reverse the k elements or simply move the pointer.&lt;br /&gt;
&lt;br /&gt;
_kAltReverse(struct node *head, int k, bool b)&lt;br /&gt;
&amp;nbsp; 1) &amp;nbsp;If b is true, then reverse first k nodes.&lt;br /&gt;
&amp;nbsp; 2) &amp;nbsp;If b is false, then move the pointer k nodes ahead.&lt;br /&gt;
&amp;nbsp; 3) &amp;nbsp;Call the kAltReverse() recursively for rest of the n - k nodes and link&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rest of the modified list with end of first k nodes.&lt;br /&gt;
&amp;nbsp; 4) &amp;nbsp;Return new head of the list.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;#include&amp;lt;stdio.h&amp;gt;

#include&amp;lt;stdlib.h&amp;gt;



/* Link list node */

struct node

{

&amp;nbsp; &amp;nbsp; int data;

&amp;nbsp; &amp;nbsp; struct node* next;

};



/* Helper function for kAltReverse() */

struct node * _kAltReverse(struct node *node, int k, bool b);



/* Alternatively reverses the given linked list in groups of

&amp;nbsp; &amp;nbsp;given size k. */

struct node *kAltReverse(struct node *head, int k)

{

&amp;nbsp; return _kAltReverse(head, k, true);

}

&amp;nbsp;

/* &amp;nbsp;Helper function for kAltReverse(). &amp;nbsp;It reverses k nodes of the list only if

&amp;nbsp; &amp;nbsp; the third parameter b is passed as true, otherwise moves the pointer k

&amp;nbsp; &amp;nbsp; nodes ahead and recursively calls iteself &amp;nbsp;*/

struct node * _kAltReverse(struct node *node, int k, bool b)

{

&amp;nbsp; &amp;nbsp;if(node == NULL)

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return NULL;



&amp;nbsp; &amp;nbsp;int count = 1;

&amp;nbsp; &amp;nbsp;struct node *prev = NULL;

&amp;nbsp; &amp;nbsp;struct node &amp;nbsp;*current = node;

&amp;nbsp; &amp;nbsp;struct node *next;

&amp;nbsp;

&amp;nbsp; &amp;nbsp;/* The loop serves two purposes

&amp;nbsp; &amp;nbsp; &amp;nbsp; 1) If b is true, then it reverses the k nodes

&amp;nbsp; &amp;nbsp; &amp;nbsp; 2) If b is false, then it moves the current pointer */

&amp;nbsp; &amp;nbsp;while(current != NULL &amp;amp;&amp;amp; count &amp;lt;= k)

&amp;nbsp; &amp;nbsp;{

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;next = current-&amp;gt;next;



&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Reverse the nodes only if b is true*/

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(b == true)

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current-&amp;gt;next = prev;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;prev = current;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;current = next;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count++;

&amp;nbsp; &amp;nbsp;}

&amp;nbsp; &amp;nbsp;

&amp;nbsp; &amp;nbsp;/* 3) If b is true, then node is the kth node.

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;So attach rest of the list after node.

&amp;nbsp; &amp;nbsp; &amp;nbsp;4) After attaching, return the new head */

&amp;nbsp; &amp;nbsp;if(b == true)

&amp;nbsp; &amp;nbsp;{

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; node-&amp;gt;next = _kAltReverse(current,k,!b);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return prev; &amp;nbsp; &amp;nbsp; &amp;nbsp; 

&amp;nbsp; &amp;nbsp;}

&amp;nbsp; &amp;nbsp;

&amp;nbsp; &amp;nbsp;/* If b is not true, then attach rest of the list after prev.

&amp;nbsp; &amp;nbsp; &amp;nbsp;So attach rest of the list after prev */ &amp;nbsp;

&amp;nbsp; &amp;nbsp;else

&amp;nbsp; &amp;nbsp;{

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prev-&amp;gt;next = _kAltReverse(current, k, !b);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return node; &amp;nbsp; &amp;nbsp; &amp;nbsp;

&amp;nbsp; &amp;nbsp;}

}

&amp;nbsp;



/* UTILITY FUNCTIONS */

/* Function to push a node */

void push(struct node** head_ref, int new_data)

{

&amp;nbsp; &amp;nbsp; /* allocate node */

&amp;nbsp; &amp;nbsp; struct node* new_node =

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (struct node*) malloc(sizeof(struct node));

&amp;nbsp;

&amp;nbsp; &amp;nbsp; /* put in the data &amp;nbsp;*/

&amp;nbsp; &amp;nbsp; new_node-&amp;gt;data &amp;nbsp;= new_data;

&amp;nbsp;

&amp;nbsp; &amp;nbsp; /* link the old list off the new node */

&amp;nbsp; &amp;nbsp; new_node-&amp;gt;next = (*head_ref);

&amp;nbsp;

&amp;nbsp; &amp;nbsp; /* move the head to point to the new node */

&amp;nbsp; &amp;nbsp; (*head_ref) &amp;nbsp; &amp;nbsp;= new_node;

}

&amp;nbsp;

/* Function to print linked list */

void printList(struct node *node)

{

&amp;nbsp; &amp;nbsp; int count = 0;

&amp;nbsp; &amp;nbsp; while(node != NULL)

&amp;nbsp; &amp;nbsp; {

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &amp;nbsp;&quot;, node-&amp;gt;data);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; node = node-&amp;gt;next;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;

&amp;nbsp; &amp;nbsp; }

}

&amp;nbsp;

/* Drier program to test above function*/

int main(void)

{

&amp;nbsp; &amp;nbsp; /* Start with the empty list */

&amp;nbsp; &amp;nbsp; struct node* head = NULL;

&amp;nbsp; &amp;nbsp; int i;

&amp;nbsp;

&amp;nbsp; &amp;nbsp; // create a list 1-&amp;gt;2-&amp;gt;3-&amp;gt;4-&amp;gt;5...... -&amp;gt;20

&amp;nbsp; &amp;nbsp; for(i = 20; i &amp;gt; 0; i--)

&amp;nbsp; &amp;nbsp; &amp;nbsp; push(&amp;amp;head, i);

&amp;nbsp;

&amp;nbsp; &amp;nbsp; printf(&quot;\n Given linked list \n&quot;);

&amp;nbsp; &amp;nbsp; printList(head);

&amp;nbsp; &amp;nbsp; head = kAltReverse(head, 3);

&amp;nbsp;

&amp;nbsp; &amp;nbsp; printf(&quot;\n Modified Linked list \n&quot;);

&amp;nbsp; &amp;nbsp; printList(head);

&amp;nbsp;

&amp;nbsp; &amp;nbsp; getchar();

&amp;nbsp; &amp;nbsp; return(0);

}&lt;/pre&gt;
&lt;b&gt;Output:&lt;/b&gt;
Given linked list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Modified Linked list
3 2 1 4 5 6 9 8 7 10 11 12 15 14 13 16 17 18 20 19

Time Complexity: O(n)
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/5222015319289761351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-reverse-alternate-k-nodes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5222015319289761351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5222015319289761351'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-reverse-alternate-k-nodes.html' title='Programming: Reverse alternate K nodes in a Singly Linked List'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-8155244092213816779</id><published>2013-10-24T23:50:00.001-07:00</published><updated>2013-10-24T23:57:28.202-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Print 100 to 1 without using any loops in the program</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Hello folks, hope you people are doing well..&lt;br /&gt;
&lt;br /&gt;
I have tried some of the techniques to print 100 to 1 without using any loops in the program. So here are some of the best suitable techniques. Actually I only have one right now, but will surely share others as soon as I get some better differences between them to share.&lt;br /&gt;
&lt;br /&gt;
Main concept here is to use &lt;b&gt;Recursion.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Method #1:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c&quot;&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;

void printvals(int);



void printvals(int n)

{

  if(n!=0)

  {

  cout&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; &quot;;

  printvals(--n);

  }

}

int main()

{

  int i=100;

  printvals(i);

  return 0;

}&lt;/pre&gt;
&lt;br /&gt;
Later Folks...... :)&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/8155244092213816779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-print-100-to-1-without.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8155244092213816779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/8155244092213816779'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-print-100-to-1-without.html' title='Programming: Print 100 to 1 without using any loops in the program'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-3743165913881806515</id><published>2013-10-17T21:44:00.003-07:00</published><updated>2013-10-17T21:44:56.405-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Variable Storage Classes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Automatic: &lt;i&gt;auto&lt;/i&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;storage is automatically allocated on function/block entry and automatically freed when the function/block is exited&amp;nbsp;&lt;/li&gt;
&lt;li&gt;may not be used with global variables (which have storage space that exists for the life of the program)&amp;nbsp;&lt;/li&gt;
&lt;li&gt;auto is the default for function/block variables&amp;nbsp;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;auto int a is the same as int a&amp;nbsp;&lt;/li&gt;
&lt;li&gt;because it is the default, it is almost never used&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;h2&gt;
Optimization Hint:&amp;nbsp;&lt;code&gt;register&lt;/code&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;register&lt;/code&gt;&amp;nbsp;provides a hint to the compiler that you think a variable will be frequently used&lt;/li&gt;
&lt;li&gt;compiler is free to ignore&amp;nbsp;&lt;code&gt;register&lt;/code&gt;&amp;nbsp;hint&lt;/li&gt;
&lt;li&gt;if ignored, the variable is equivalent to an&amp;nbsp;&lt;code&gt;auto&lt;/code&gt;&amp;nbsp;variable with the exception that you may not take the address of a&amp;nbsp;&lt;code&gt;register&lt;/code&gt;&amp;nbsp;(since, if put in a register, the variable will not have an address)&lt;/li&gt;
&lt;li&gt;rarely used, since any modern compiler will do a better job of optimization than most programmers&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
Static Storage:&amp;nbsp;&lt;code&gt;static&lt;/code&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;if used inside a block or function, the compiler will create space for the variable which lasts for the life of the program&lt;/li&gt;
&lt;li&gt;&lt;pre class=&quot;brush: cpp&quot;&gt;  int
  counter(void)
  {
 static int cnt = 0;

 return cnt++;
  }
&lt;/pre&gt;
causes the&amp;nbsp;&lt;code&gt;counter()&lt;/code&gt;&amp;nbsp;function to return a constantly increasing number&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
External References:&amp;nbsp;&lt;code&gt;extern&lt;/code&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;If a variable is declared (with global scope) in one file but referenced in another, the&amp;nbsp;&lt;code&gt;extern&lt;/code&gt;&amp;nbsp;keyword is used to inform the compiler of the variable&#39;s existence:&lt;ul&gt;
&lt;li&gt;In&amp;nbsp;&lt;var&gt;declare.c&lt;/var&gt;:&lt;pre&gt;int farvar;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;In&amp;nbsp;&lt;var&gt;use.c&lt;/var&gt;:&lt;pre class=&quot;brush: cpp&quot;&gt;{
 extern int farvar;
 int a;
 a = farvar * 2;
}
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Note that the&amp;nbsp;&lt;code&gt;extern&lt;/code&gt;&amp;nbsp;keyword is for&amp;nbsp;&lt;em&gt;declarations&lt;/em&gt;, not&amp;nbsp;&lt;em&gt;definitions&lt;/em&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;An&amp;nbsp;&lt;code&gt;extern&lt;/code&gt;&amp;nbsp;declaration does not create any storage; that must be done with a global definition&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
Private Variables:&amp;nbsp;&lt;code&gt;static&lt;/code&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;another use for the&amp;nbsp;&lt;code&gt;static&lt;/code&gt;&amp;nbsp;keyword is to ensure that code outside this file cannot modify variables that are globally declared inside this file&lt;ul&gt;
&lt;li&gt;If&amp;nbsp;&lt;var&gt;declare.c&lt;/var&gt;&amp;nbsp;had declared&amp;nbsp;&lt;var&gt;farvar&lt;/var&gt;&amp;nbsp;as:&lt;pre&gt;static int farvar;
&lt;/pre&gt;
then the&amp;nbsp;&lt;code&gt;extern int farvar&lt;/code&gt;&amp;nbsp;statement in&amp;nbsp;&lt;var&gt;use.c&lt;/var&gt;&amp;nbsp;would cause an error&lt;/li&gt;
&lt;li&gt;This use of&amp;nbsp;&lt;code&gt;static&lt;/code&gt;&amp;nbsp;is commonly used in situations where a group of functions need to share information but do not want to risk other functions changing their internal variables&lt;pre class=&quot;brush: cpp&quot;&gt;static int do_ping = 1; /* start with `PING&#39; */

void
ping(void)
{
 if (do_ping == 1) {
  printf(&quot;PING &quot;);
  do_ping = 0;
 }
}

void
pong(void)
{
 if (do_ping == 0) {
  printf(&quot;PONG\n&quot;);
  do_ping = 1;
 }
}&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
Variable Initialization&lt;/h2&gt;
&lt;ul style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;li&gt;&lt;code&gt;auto&lt;/code&gt;,&amp;nbsp;&lt;code&gt;register&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code&gt;static&lt;/code&gt;&amp;nbsp;variables may be initialized at creation:&lt;pre class=&quot;brush: cpp&quot;&gt;  int
  main(void)
  {
 int a = 0;
 register int start = 1234;
 static float pi = 3.141593;
  }
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Any global and&amp;nbsp;&lt;code&gt;static&lt;/code&gt;&amp;nbsp;variables which have not been explicitly initialized by the programmer are set to zero&lt;/li&gt;
&lt;li&gt;If an&amp;nbsp;&lt;code&gt;auto&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code&gt;register&lt;/code&gt;&amp;nbsp;variable has not been explicitly initialized, it contains whatever was previously stored in the space that is allocated to it&lt;ul&gt;
&lt;li&gt;this means that&amp;nbsp;&lt;code&gt;auto&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code&gt;register&lt;/code&gt;&amp;nbsp;variables should&amp;nbsp;&lt;strong&gt;always&lt;/strong&gt;&amp;nbsp;be initialized before being used&lt;/li&gt;
&lt;li&gt;compiler may provide a switch to warn about uninitialized variables&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/3743165913881806515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-variable-storage-classes.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3743165913881806515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3743165913881806515'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-variable-storage-classes.html' title='Programming: Variable Storage Classes'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-5628450476235751473</id><published>2013-10-10T01:12:00.001-07:00</published><updated>2013-10-10T01:12:24.637-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bit magic"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Converting Decimal into Binary &amp; Binary Into Decimal</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Its been very important that you know all the techniques of converting a decimal into binary or vice-versa. Here I am going to show two techniques of converting a decimal into binary, one of them is using bit-manipulation and the other one is conventional.&lt;br /&gt;
&lt;br /&gt;
One conventional method of converting decimal into binary is shown below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZrP0Y5vG3BfgzKR4unWqRQWNEqZfpe8bG9JMmK114KplFPEhD0vuvPpB6xQ7vuxilqVl2NE4v4lyg08bAW4vEenKNcPq-Uf28DxpXbOHsFxNV-DQ4KUa3RtWb6c2gQ6EFMHHsEPOLzZW_/s1600/1_1.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;287&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZrP0Y5vG3BfgzKR4unWqRQWNEqZfpe8bG9JMmK114KplFPEhD0vuvPpB6xQ7vuxilqVl2NE4v4lyg08bAW4vEenKNcPq-Uf28DxpXbOHsFxNV-DQ4KUa3RtWb6c2gQ6EFMHHsEPOLzZW_/s320/1_1.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Here is the implementation:&lt;span id=&quot;goog_841521209&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;#include &amp;lt;iostream&amp;gt;

#include &amp;lt;math.h&amp;gt;

using namespace std;



void dec2bin(unsigned n, int a[])

/* This method is bit-manipulation */ 

{

   unsigned i, j=0;

   for(i = 1 &amp;lt;&amp;lt; 15; i&amp;gt;0; i = i/2)

   {
a
  if(n &amp;amp; i)

  {

   a[j++] = 1;

  }

  else

  {

   a[j++] = 0;

  }

   }

}



void dec2bin2(int n)

/* Conventional Method */ 

{

   if(n&amp;gt;1)

  dec2bin2(n/2);

  

   printf(&quot;%d&quot;, n%2);

}



int main()

{

   int a[16] = {0}, i, sum=0;

   dec2bin(4, a);

   for(i=0; i&amp;lt;=15; i++)

  cout&amp;lt;&amp;lt;a[i];

   cout&amp;lt;&amp;lt;endl;

   //dec2bin2(65535);

   

   /* Below method will convert the binary into Decimal */
   for(i=0; i&amp;lt;16; i++)

   {

  sum+=((pow(2, (15-i)))*a[i]);

   }

   cout&amp;lt;&amp;lt;&quot;Decimal: &quot;&amp;lt;&amp;lt;sum;

   return 0;

}&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I have shown two methods of converting the decimal number into binary and one method in the main() to show the conversion of binary in decimal number...&lt;br /&gt;
&lt;br /&gt;
Let me know if you have any queries or above program requires any correction...&lt;br /&gt;
.... Next time... :)&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/5628450476235751473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-converting-decimal-into.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5628450476235751473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/5628450476235751473'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-converting-decimal-into.html' title='Programming: Converting Decimal into Binary &amp; Binary Into Decimal'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZrP0Y5vG3BfgzKR4unWqRQWNEqZfpe8bG9JMmK114KplFPEhD0vuvPpB6xQ7vuxilqVl2NE4v4lyg08bAW4vEenKNcPq-Uf28DxpXbOHsFxNV-DQ4KUa3RtWb6c2gQ6EFMHHsEPOLzZW_/s72-c/1_1.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-593827954596587582</id><published>2013-10-08T23:28:00.002-07:00</published><updated>2013-10-08T23:28:47.457-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Finding first non-repeating character in given string [Improved Method]</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I have discussed O(n) method for finding first non-repeating character in a given string.&lt;br /&gt;
You can find it here &lt;a href=&quot;http://learnshareimprove.blogspot.in/2013/10/programming-finding-first-non-repeating.html&quot; target=&quot;_blank&quot;&gt;Method-1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The above approach takes O(n) time, but in practice it can be improved. The first part of the algorithm runs through the string to construct the count array (in O(n) time). This is reasonable. But the second part about running through the string again just to find the first non-repeater is not good in practice. In real situations, your string is expected to be much larger than your alphabet. Take DNA sequences for example: they could be millions of letters long with an alphabet of just 4 letters. What happens if the non-repeater is at the end of the string? Then we would have to scan for a long time (again).&lt;br /&gt;
&lt;br /&gt;
We can augment the count array by storing not just counts but also the index of the first time you encountered the character e.g. (3, 26) for ‘a’ meaning that ‘a’ got counted 3 times and the first time it was seen is at position 26. So when it comes to finding the first non-repeater, we just have to scan the count array, instead of the string. Thanks to Ben for suggesting this approach.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;limits.h&amp;gt;&lt;br /&gt;
#define NO_OF_CHARS 256&lt;br /&gt;
&lt;br /&gt;
// Structure to store count of a character and index of the first&lt;br /&gt;
// occurrence in the input string&lt;br /&gt;
struct countIndex {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int count;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int index;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/* Returns an array of above structure type. The size of&lt;br /&gt;
&amp;nbsp; &amp;nbsp;array is NO_OF_CHARS */&lt;br /&gt;
struct countIndex *getCharCountArray(char *str)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;struct countIndex *count =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (struct countIndex *)calloc(sizeof(countIndex), NO_OF_CHARS);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for (i = 0; *(str+i); &amp;nbsp;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; (count[*(str+i)].count)++;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; // If it&#39;s first occurrence, then store the index&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (count[*(str+i)].count == 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count[*(str+i)].index = i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return count;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* The function returns index of first non-repeating&lt;br /&gt;
&amp;nbsp; &amp;nbsp;character in a string. If all characters are repeating&lt;br /&gt;
&amp;nbsp; &amp;nbsp;then reurns INT_MAX */&lt;br /&gt;
int firstNonRepeating(char *str)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; struct countIndex *count = getCharCountArray(str);&lt;br /&gt;
&amp;nbsp; int result = INT_MAX, i;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; for (i = 0; i &amp;lt; NO_OF_CHARS; &amp;nbsp;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // If this character occurs only once and appears&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // before the current result, then update the result&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (count[*(str+i)].count == 1 &amp;amp;&amp;amp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; result &amp;gt; count[*(str+i)].index)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; result = i;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; free(count); // To avoid memory leak&lt;br /&gt;
&amp;nbsp; return result;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Driver program to test above function */&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; char str[] = &quot;HelloWorldHowAreYou&quot;;&lt;br /&gt;
&amp;nbsp; int index = &amp;nbsp;firstNonRepeating(str);&lt;br /&gt;
&amp;nbsp; if(index == INT_MAX)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;Either all characters are repeating or string is empty&quot;);&lt;br /&gt;
&amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot;First non-repeating character is %c&quot;, str[index]);&lt;br /&gt;
&amp;nbsp; getchar();&lt;br /&gt;
&amp;nbsp; return 0;&lt;br /&gt;
}&lt;/pre&gt;&lt;/div&gt;

Hope it helps...
....Next time... :)
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/593827954596587582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-finding-first-non-repeating_8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/593827954596587582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/593827954596587582'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-finding-first-non-repeating_8.html' title='Programming: Finding first non-repeating character in given string [Improved Method]'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-3814309042183953243</id><published>2013-10-08T21:47:00.000-07:00</published><updated>2013-10-08T21:47:10.912-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Programming: Finding first non-repeating character in given string</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given a string, find the first non-repeating character in it. For example, if the input string is “HelloWorld”, then output should be ‘H’ and if input string is “HelloHowAreYou”, then output should be ‘w’.&lt;br /&gt;
&lt;br /&gt;
We can use string characters as index and build a count array. Following is the algorithm.&lt;br /&gt;
&lt;br /&gt;
1) Scan the string from left to right and construct the count array.&lt;br /&gt;
2) Again, scan the string from left to right and check for count of each&lt;br /&gt;
&amp;nbsp;character, if you find an element who&#39;s count is 1, return it.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Input string: str = helloworld&lt;br /&gt;
1: Construct character count array from the input string.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; count[&#39;h&#39;] = 1&lt;br /&gt;
&amp;nbsp; count[&#39;e&#39;] = 1&lt;br /&gt;
&amp;nbsp; count[&#39;l&#39;] = 3&lt;br /&gt;
&amp;nbsp; count[&#39;o&#39;] = 2&lt;br /&gt;
&amp;nbsp; count[&#39;w&#39;] = 1&lt;br /&gt;
&amp;nbsp; ……&lt;br /&gt;
2: Get the first character who&#39;s count is 1 (&#39;h&#39;).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Implementation:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;#include &amp;lt;iostream&amp;gt;

#include &amp;lt;malloc.h&amp;gt;

#define NO_OF_CHAR 256

using namespace std;



int *getcharcountarray(char *str)

{

    int *count = (int *)calloc(sizeof(int), NO_OF_CHAR);

    int i;

    for(i=0; *(str+i); i++)

     count[*(str+i)]++;

    return count;

}



int gettheindex(char *str)

{

    int *count = getcharcountarray(str);

    int index = -1, i;

    

    for(i=0; *(str+i); i++)

    {

     if(count[*(str+i)] == 1)

     {

         index = i;

         break;

     }

    }

    free(count);

    return index;

}



int main()

{

    char str[] = &quot;samsungelectronics&quot;;

    int index = gettheindex(str);

    if(index == -1)

     cout&amp;lt;&amp;lt;&quot;Either all characters are repeating or string is empty&quot;&amp;lt;&amp;lt;endl;

    else

     cout&amp;lt;&amp;lt;&quot;First repeating character is &quot;&amp;lt;&amp;lt;str[index]&amp;lt;&amp;lt;endl;

    return 0;



}&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/3814309042183953243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-finding-first-non-repeating.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3814309042183953243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/3814309042183953243'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/programming-finding-first-non-repeating.html' title='Programming: Finding first non-repeating character in given string'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-349908570226133794</id><published>2013-10-07T21:31:00.001-07:00</published><updated>2013-10-07T21:32:55.681-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Graph"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Data Structures: Graph - Adjacency Matrix</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;As I have explained basic concepts of the Graph in my previous post, I hope it is clear to you people. Now, I am going to show, how you can represent this graph in programming.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Now, if I call these vertices as to be the pieces of similar information and the edges as to be the various linkages between them, then, you can certainly think of representing any Graph with the help of Linked Lists, can&#39;t you?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Well, we&#39;ll see that implementation in our next section. But for now, you&#39;ve a bit simpler representation of Graphs, the Adjacency Matrix. This matrix shows you all the direct linkages between the vertices; meaning the direct edges between the vertices. Let me explain this with the help of an example -&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjotZL41bNPMZbBtmtAj5aymNN51d1ab4uSDH2AKakyBlkZqIhOn-bFmlfrg3-WZG7mtp2lBYVcctXLJQaGUECFh-L04uwVyxQteDa-_9wrktHevrg58hvRWH_VE2D9hME2gvcgdvF40jIw/s1600/adjmat.GIF&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjotZL41bNPMZbBtmtAj5aymNN51d1ab4uSDH2AKakyBlkZqIhOn-bFmlfrg3-WZG7mtp2lBYVcctXLJQaGUECFh-L04uwVyxQteDa-_9wrktHevrg58hvRWH_VE2D9hME2gvcgdvF40jIw/s1600/adjmat.GIF&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Consider, this directed graph. It has five vertices and five edges - AD, BD, CB, DE and EC. The Adjacency matrix for this will be -&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 330px;&quot;&gt;
        &lt;tbody&gt;
&lt;tr&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;A&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;B&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;C&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;D&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;E&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;246&quot;&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;tr&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;A&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;246&quot;&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;tr&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;B&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; width=&quot;246&quot;&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;tr&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;C&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; rowspan=&quot;3&quot; width=&quot;246&quot;&gt;&lt;blockquote&gt;
&lt;div align=&quot;left&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;1 if the edge is there&lt;br /&gt;
              0 if no edge is there&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/td&gt;
        &lt;/tr&gt;
&lt;tr&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;D&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;tr&gt;
          &lt;td align=&quot;center&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: xx-small;&quot;&gt;&lt;b&gt;E&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;11&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
          &lt;td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; width=&quot;12&quot;&gt;&lt;span style=&quot;color: maroon; font-family: Arial; font-size: xx-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Now you know why it is called as an adjacency matrix. It only shows the direct paths between the vertices but you can see there exist paths which have intermediate vertices also; like from A to B you have D-&amp;gt;E-&amp;gt;C.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Remember, it does not matter if the graph is weighted, the adjacency matrix is gonna remain the same.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;u&gt;&lt;span style=&quot;color: maroon;&quot;&gt;Note:-&lt;/span&gt;&lt;/u&gt;&lt;b&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;When I say route, I mean the direct path between the vertices and that no other vertex is there in that path except the two adjacent vertices forming the edge.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;b&gt;I guess you know how to store a 2D-matrix in an array! That is left for your practice.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#define MAX 5&lt;br /&gt;
using namespace std;&lt;br /&gt;

int main()&lt;br /&gt;
{&lt;br /&gt;
int E, V[MAX]; //E=number of Edges, V=Vertices&lt;br /&gt;
int i, j;&lt;br /&gt;
int temp1=0, temp2=0;&lt;br /&gt;
int adj_mat[MAX][MAX] = {0}; //Adjacency Matrix&lt;br /&gt;
cout&amp;lt;&amp;lt;&quot;Enter Vertices&quot;&amp;lt;&amp;lt;endl; //Enter all the vertices. for example 1,2,3,4 etc..&lt;br /&gt;
for(i=0; i&amp;lt;MAX; i++)&lt;br /&gt;
{&lt;br /&gt;
cin&amp;gt;&amp;gt;V[i];&lt;br /&gt;
}&lt;br /&gt;
cout&amp;lt;&amp;lt;&quot;Enter number of Edges&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
cin&amp;gt;&amp;gt;E; //Total number of edges between vertices.&lt;br /&gt;
&lt;br /&gt;
for(j=0; j&amp;lt;E; j++)&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;&quot;Edge #&quot;&amp;lt;&amp;lt;j+1&amp;lt;&amp;lt;&quot; &quot;; //j+1 because we will be starting from Edge #1 and not 0.&lt;br /&gt;
cin&amp;gt;&amp;gt;temp1; //Path from&lt;br /&gt;
cin&amp;gt;&amp;gt;temp2; //Path To&lt;br /&gt;
//Path from and to, are in case of directed graph.&lt;br /&gt;
adj_mat[temp1-1][temp2-1] = 1; //Placing 1 in appropriate place in adjacency matrix&lt;br /&gt;
}
for(i=0; i&amp;lt;MAX; i++)&lt;br /&gt;
{&lt;br /&gt;
for(j=0; j&amp;lt;MAX; j++)&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;adj_mat[i][j]&amp;lt;&amp;lt;&quot; &quot;; //Display the adjacency matrix.&lt;br /&gt;
}&lt;br /&gt;
cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
}&lt;br /&gt;
return 0; //Get back in where you came from... :)&lt;br /&gt;
}
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/349908570226133794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/data-structures-graph-adjacency-matrix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/349908570226133794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/349908570226133794'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/data-structures-graph-adjacency-matrix.html' title='Data Structures: Graph - Adjacency Matrix'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjotZL41bNPMZbBtmtAj5aymNN51d1ab4uSDH2AKakyBlkZqIhOn-bFmlfrg3-WZG7mtp2lBYVcctXLJQaGUECFh-L04uwVyxQteDa-_9wrktHevrg58hvRWH_VE2D9hME2gvcgdvF40jIw/s72-c/adjmat.GIF" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2455670798310287027.post-6336921510675585096</id><published>2013-10-07T20:59:00.000-07:00</published><updated>2013-10-07T20:59:15.404-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Graph"/><title type='text'>Data Structures: Graph Concepts</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;I&#39;ve been reading about the data structures a lot lately and came across this article on the website&amp;nbsp;&lt;a href=&quot;http://datastructures.itgo.com/&quot;&gt;http://datastructures.itgo.com&lt;/a&gt;, So I though this is worth sharing on my blog. The person has neatly explained about the data structures and I am going to share some of the information available. So lets start with Graph.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Sorry! I can&#39;t give that mathematical definition, involving all those Vs and &amp;nbsp;Es, for the Graphs. Rather, take it this way - a graph is a collection of some finite VERTICES and some finite EDGES which happen to connect these vertices. If I consider a given list of cities as my list of VERTICES then you can, probably, call the air routes between them as to be the EDGES for them.&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Based on this analogy, we can say that a Directed Graph is a one in which you have one way air routes and that you can not come back through that same route; means, you can fly from Delhi to Mumbai but can not come back through that same route. Similarly, if you have two way air routes between the cities then I call it, an Undirected Graph. Finally, if its not a sponsored journey then certainly you will have to bear the ticket fare, which means every route (EDGE) has some cost of journey attached and that makes it a Weighted Graph. No fare, no weight!&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeS_krJiM1YcDqLoDz0uXcZJl_Rmm3VCjQBwPUM7Dywfd2jEBbO5nL3wx78eg9SYDZVlrm2yJBy5Dc0TR3IMB_ZoW5csrhdZm40La3e60jbzlWo-E2x2tAgOCjw2bm6Oaq8Y30C0nbD3C4/s1600/digraph.GIF&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeS_krJiM1YcDqLoDz0uXcZJl_Rmm3VCjQBwPUM7Dywfd2jEBbO5nL3wx78eg9SYDZVlrm2yJBy5Dc0TR3IMB_ZoW5csrhdZm40La3e60jbzlWo-E2x2tAgOCjw2bm6Oaq8Y30C0nbD3C4/s1600/digraph.GIF&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Directed Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtseR-Xb_VTJj3UbN10iUylUj8S1neFFshiZy308eNZH1aBcSjiDCZJH-rBA62zw3GoN9BBjj-GmGeb-fXJmF9Mjg4apK4mceu8J3ykDhDvatipL4W7G1BuyP-GsrBGJnB2jnFw9fBL8gV/s1600/undigraph.GIF&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtseR-Xb_VTJj3UbN10iUylUj8S1neFFshiZy308eNZH1aBcSjiDCZJH-rBA62zw3GoN9BBjj-GmGeb-fXJmF9Mjg4apK4mceu8J3ykDhDvatipL4W7G1BuyP-GsrBGJnB2jnFw9fBL8gV/s1600/undigraph.GIF&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Undirected Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCSds866QMmPkp1WfwYk9CTeohBjAyeDSzq0s4YI8OBnTLSZ5e0_jOwAcJK1d1eP1GvTyAOac97JekVm93RklWdqjGCrGlfulsP0v0TNqqwvYqMG47sBRdTJrqGTrff4tC55a0JpHH3fCQ/s1600/weightgra.GIF&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCSds866QMmPkp1WfwYk9CTeohBjAyeDSzq0s4YI8OBnTLSZ5e0_jOwAcJK1d1eP1GvTyAOac97JekVm93RklWdqjGCrGlfulsP0v0TNqqwvYqMG47sBRdTJrqGTrff4tC55a0JpHH3fCQ/s1600/weightgra.GIF&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Weighted Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;Directed Graph:-&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Vertices(cities): A, B, C and D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Edges(routes): AB, AC, CD&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: green;&quot;&gt;Undirected Graph:-&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Vertices: A, B, C, D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Edges:&amp;nbsp; AB, AC, BA, CD, DC&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: green;&quot;&gt;Weighted Graph:-&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Vertices: A, B, C, D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Weighted Edges: AC-10, AB-17, CD-13&lt;br /&gt;&lt;br /&gt;You might be thinking by now, what these Graphs have to do with computers! Well, to name a few I&#39;ll give you some applications of it - in the study of information routing on computer networks (helps in finding the shortest routes); electronic circuit designing (helps to find out the electrical loops and overlaps); ticketing software uses it to find out the shortest route... Got the idea!&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;u&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;u&gt;&lt;span style=&quot;color: maroon;&quot;&gt;Note:-&lt;/span&gt;&lt;/u&gt;&lt;b&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;When I said route&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;b&gt;here&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: green;&quot;&gt;, I meant the direct path between the adjacent vertices and that no other vertex is there in that path except the two adjacent vertices forming the pat&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;b&gt;h&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: green;&quot;&gt;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://learnshareimprove.blogspot.com/feeds/6336921510675585096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/data-structures-graph-concepts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/6336921510675585096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2455670798310287027/posts/default/6336921510675585096'/><link rel='alternate' type='text/html' href='http://learnshareimprove.blogspot.com/2013/10/data-structures-graph-concepts.html' title='Data Structures: Graph Concepts'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07062727053659751506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeS_krJiM1YcDqLoDz0uXcZJl_Rmm3VCjQBwPUM7Dywfd2jEBbO5nL3wx78eg9SYDZVlrm2yJBy5Dc0TR3IMB_ZoW5csrhdZm40La3e60jbzlWo-E2x2tAgOCjw2bm6Oaq8Y30C0nbD3C4/s72-c/digraph.GIF" height="72" width="72"/><thr:total>0</thr:total></entry></feed>