Write the C program to insert a node in circular singly list at the beginning.
#include
#include
void beg_insert(int);
struct node
{
int data;
struct node *next;
};
struct node *head;
void main ()
{
int choice,item;
do
{
printf(“nEnter the item which you want to insert?n”);
scanf(“%d”,&item);
beg_insert(item);
printf(“nPress 0 to insert more ?n”);
scanf(“%d”,&choice);
}while(choice == 0);
}
void beg_insert(int item)
{
struct node *ptr = (struct node *)malloc(sizeof(struct node));
struct node *temp;
if(ptr == NULL)
{
printf(“nOVERFLOW”);
}
else
{
ptr -> data = item;
if(head == NULL)
{
head = ptr;
ptr -> next = head;
}
else
{
temp = head;
while(temp->next != head)
temp = temp->next;
ptr->next = head;
temp -> next = ptr;
head = ptr;
}
printf(“nNode Insertedn”);
}
}
What are the applications of Graph data structure?
The graph has the following applications:
- Graphs are used in circuit networks where points of connection are drawn as vertices and component wires become the edges of the graph.
- Graphs are used in transport networks where stations are drawn as vertices and routes become the edges of the graph.
- Graphs are used in maps that draw cities/states/regions as vertices and adjacency relations as edges.
- Graphs are used in program flow analysis where procedures or modules are treated as vertices and calls to these procedures are drawn as edges of the graph.
Which notations are used in Evaluation of Arithmetic Expressions using prefix and postfix forms?
Polish and Reverse Polish notations.
List some applications of Tree-data structure?
Applications of Tree- data structure:
- The manipulation of Arithmetic expression,
- Symbol Table construction,
- Syntax analysis
- Hierarchal data model