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

<channel>
	<title>Search | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/search/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 09 Jun 2012 16:45:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C Program for Singly Linked List Operations</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-singly-linked-list-operations/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-singly-linked-list-operations/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 16:45:08 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[Insert]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Linked List Operations]]></category>
		<category><![CDATA[single linked list]]></category>
		<category><![CDATA[Update]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3308</guid>

					<description><![CDATA[<p>C Program for Singly Linked List Operations – Insert (Front, Pos, back), Delete, Search and Update. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #include #include typedef struct node { int sid; char sname[25]; int ssem; struct node *link; }NODE; NODE *InsFront(NODE *, int, char *, int); NODE *InsBack(NODE *, int,</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-singly-linked-list-operations/">C Program for Singly Linked List Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Singly Linked List Operations – Insert (Front, Pos, back), Delete, Search and Update.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#include <stdlib.h>
#include <string.h>
typedef struct node
{
    int sid;
    char sname[25];
    int ssem;
    struct node *link;
}NODE;

NODE *InsFront(NODE *, int, char *, int);
NODE *InsBack(NODE *, int, char *, int);
NODE *InsPos(NODE *, int, char *, int,int);
NODE *DelNode(NODE *, int);
NODE *SrchUpdate(NODE *, int);
void Display(NODE *);

main()
{
    NODE *start=NULL;		 /* Main Program */
    int opn,id,sem,p,insopn;
    char name[25];
    do
    {
        clrscr();
        printf("\n ### Linked List Operations ### \n\n");
        printf("\n Press 1-Insertion, 2-Deletion, 3-Search, 4-Display,5-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&opn);
        switch(opn)
        {
        case 1: printf("Insertion at: Press 1->Front 2->Back 3->Pos ? ");
            scanf("%d",&insopn);
            printf("\n\nRead the Sid,Name, and Sem details ?");
            scanf("%d%s%d",&id,name,&sem);
            if( insopn == 1) start=InsFront(start,id,name,sem);
            else if(insopn == 2) start=InsBack(start,id,name,sem);
            else if(insopn == 3)
            {
                printf(" At What Position ? ");
                scanf("%d",&p);
                start=InsPos(start,id,name,sem,p);
            }
            break;

        case 2: printf(" Read the Student Id of the Node to be deleted ? ");
            scanf("%d",&id);
            start=DelNode(start,id);
            break;
        case 3: printf(" Read the Student Id of the Node to be Searched ? ");
            scanf("%d",&id);
            start=SrchUpdate(start,id);
            break;
        case 4: printf(" Linked List is \n");
            Display(start); break;
        case 5: printf("\n\n Terminating \n\n"); break;
        default: printf("\n\nInvalid Option !!! Try Again !! \n\n");
            break;
        }
        printf("\n\n\n\n  Press a Key to Continue . . . ");
        getch();
    }while(opn != 5);
}

NODE *InsFront(NODE *st, int id, char *name, int sem)
{
    NODE *temp;
    temp=(NODE *)malloc(sizeof(NODE));
    if( temp == NULL)
    { printf(" Out of Memory !! Overflow !!!");
    return(st);
    }
    else
    {
        temp->sid=id;
        strcpy(temp->sname,name);
        temp->ssem=sem;
        temp->link=st;
        printf(" Node has been inserted at Front Successfully !!");
        return(temp);
    }
}

NODE *InsBack(NODE *st, int id, char *name, int sem)
{
    NODE *temp,*t;
    temp=(NODE *)malloc(sizeof(NODE));
    if( temp == NULL)
    { printf(" Out of Memory !! Overflow !!!");
    return(st);
    }
    else
    {
        temp->sid=id;
        strcpy(temp->sname,name);
        temp->ssem=sem;
        temp->link=NULL;
        if(st == NULL) return(temp);
        else
        {
            t=st;
            while( t->link != NULL)
                t=t->link;
            t->link=temp;
            printf(" Node has been inserted at Back Successfully !!");
            return(st);
        }
    }
}

NODE *InsPos(NODE *st, int id, char *name, int sem, int pos)
{
    NODE *temp,*t,*prev;
    int cnt;
    temp=(NODE *)malloc(sizeof(NODE));
    if( temp == NULL)
    { printf(" Out of Memory !! Overflow !!!");
    return(st);
    }
    else
    {
        temp->sid=id;
        strcpy(temp->sname,name);
        temp->ssem=sem;
        temp->link=NULL;
        if(pos == 1)    /* Front Insertion */
        { temp->link=st;
        return(temp);
        }
        else
        {
            t=st; cnt=1;
            while( t != NULL && cnt != pos)
            {
                prev=t;
                t=t->link;
                cnt++;
            }
            if(t) /* valid Position  Insert new node*/
            {
                prev->link=temp;
                temp->link=t;
            }
            else
                printf(" Invalid Position !!!");
            printf(" Node has been inserted at given Position  Successfully !!");
            return(st);
        }
    }
}

NODE *DelNode(NODE *st, int id)
{
    NODE *t,*prev;
    if( st ==  NULL) { printf(" Underflow!!!"); return(st); }
    else
    { t=st;
    if(st->sid == id)    /* Front Deletion */
    { st=st->link;
    t->link=NULL;
    free(t);
    return(st);
    }
    else
    {
        while( t != NULL && t->sid != id)
        {
            prev=t;
            t=t->link;
        }
        if(t) /* node to be deleted  found*/
        {
            prev->link=t->link;
            t->link=NULL;
            free(t);
        }
        else
            printf(" Invalid Student Id !!!");
        return(st);
    }
    }
}

NODE *SrchUpdate(NODE *st, int id)
{
    NODE *t;
    if( st ==  NULL) { printf(" Empty List !!"); return(st); }
    else
    {  t=st;
    while( t != NULL && t->sid != id)
    {
        t=t->link;
    }
    if(t) /* node to be Updated found*/
    {
        printf(" Node with Student Id %d found inthe List !\n",id);
        printf(" Read the New Id,Name and Sem forthe Student\n");
        scanf("%d%s%d",t->sid,t->sname,t->ssem);
    }
    else
        printf(" Invalid Student Id !!!");
    return(st);
    }
}

void Display(NODE *st)
{ 
	NODE *t;
	if( st == NULL) printf("Empty List\n");
	else
	{
		t=st;
		printf("Start->");
		while(t)
		{
			printf("[%d,%s,%d]->",t->sid,t->sname,t->ssem);
			t=t->link;
		}
		printf("Null\n");
	}
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-singly-linked-list-operations/">C Program for Singly Linked List Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-singly-linked-list-operations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to perform Insert, Delete, Search an element into a binary search tree</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-perform-insert-delete-search-an-element-into-a-binary-search-tree/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-perform-insert-delete-search-an-element-into-a-binary-search-tree/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 10 Mar 2010 15:14:15 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[Insert]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[C++ Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=995</guid>

					<description><![CDATA[<p>/* Write a C++ program to perform the following operations:<br />
a) Insert an element into a binary search tree.<br />
b) Delete an element from a binary search tree.<br />
c) Search for a key element in a binary search tree. */</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-perform-insert-delete-search-an-element-into-a-binary-search-tree/">C++ program to perform Insert, Delete, Search an element into a binary search tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write a C++ Data structure program to perform the following operations:<br />
a) Insert an element into a binary search tree.<br />
b) Delete an element from a binary search tree.<br />
c) for a key element in a binary search tree. */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;

void insert(int,int );
void delte(int);
void display(int);
int search(int);
int search1(int,int);
int tree[40],t=1,s,x,i;

main()
{
	int ch,y;
	for(i=1;i<40;i++)
	tree[i]=-1;
	while(1)
	{
cout <<"1.INSERT\n2.DELETE\n3.DISPLAY\n4.SEARCH\n5.EXIT\nEnter your choice:";
		cin >> ch;
		switch(ch)
		{
		case 1:
			cout <<"enter the element to insert";
			cin >> ch;
			insert(1,ch);
			break;
		case 2:
			cout <<"enter the element to delete";
			cin >>x;
			y=search(1);
			if(y!=-1) delte(y);
			else cout<<"no such element in tree";
			break;
		case 3:
			display(1);
			cout<<"\n";
			for(int i=0;i<=32;i++)
			cout <<i;
			cout <<"\n";
			break;
case 4:
			cout <<"enter the element to search:";
			cin >> x;
			y=search(1);
			if(y == -1) cout <<"no such element in tree";
			else cout <<x << "is in" <<y <<"position";
			break;
		case 5:
			exit(0);
		}
	}
}

void insert(int s,int ch )
{
	int x;
	if(t==1)
	{
		tree[t++]=ch;
		return;
	}
	x=search1(s,ch);
	if(tree[x]>ch)
		tree[2*x]=ch;
	else
		tree[2*x+1]=ch;
	t++;
}
void delte(int x)
{
	if( tree[2*x]==-1 && tree[2*x+1]==-1)
		tree[x]=-1;
	else if(tree[2*x]==-1)
	      {	tree[x]=tree[2*x+1];
		tree[2*x+1]=-1;
	      }
	else if(tree[2*x+1]==-1)
	      {	tree[x]=tree[2*x];
		tree[2*x]=-1;
	      }
	else
	{
	  tree[x]=tree[2*x];
	  delte(2*x);
	}
	t--;
}

int search(int s)
{
if(t==1)
{
cout <<"no element in tree";
return -1;
}
if(tree[s]==-1)
return tree[s];
if(tree[s]>x)
search(2*s);
else if(tree[s]<x)
search(2*s+1);
else
return s;
}

void display(int s)
{
if(t==1)
{cout <<"no element in tree:";
return;}
for(int i=1;i<40;i++)
if(tree[i]==-1)
cout <<" ";
else cout <<tree[i];
return ;
}

int search1(int s,int ch)
{
if(t==1)
{
cout <<"no element in tree";
return -1;
}
if(tree[s]==-1)
return s/2;
if(tree[s] > ch)
search1(2*s,ch);
else search1(2*s+1,ch);
}
</pre>
<p><strong>OUTPUT</strong><br />
1.INSERT<br />
2.DELETE<br />
3.DISPLAY<br />
4.SEARCH<br />
5.EXIT<br />
Enter your choice:3</p>
<p>no element in tree:<br />
0123456789011121314151617181920212223242526272829303132</p>
<p>1.INSERT<br />
2.DELETE<br />
3.DISPLAY<br />
4.SEARCH<br />
5.EXIT<br />
Enter your choice:1</p>
<p>Enter the element to insert 10<br />
1.INSERT<br />
2.DELETE<br />
3.DISPLAY<br />
4.SEARCH<br />
5.EXIT<br />
Enter your choice:4</p>
<p>Enter the element to search: 10<br />
10 is in 1 position<br />
1.INSERT<br />
2.DELETE<br />
3.DISPLAY<br />
4.SEARCH<br />
5.EXIT</p>
<p>Enter your choice:5</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-perform-insert-delete-search-an-element-into-a-binary-search-tree/">C++ program to perform Insert, Delete, Search an element into a binary search tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-perform-insert-delete-search-an-element-into-a-binary-search-tree/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
