answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

Write a c program to insert an element in the beginning at the end at the specified position in a linear linked list?

#include<stdio.h> #include<stdlib.h> typedef struct Node { int data; struct Node *next; }node; void insert(node *pointer, int data) { /* Iterate through the list till we encounter the last node.*/ while(pointer->next!=NULL) { pointer = pointer -> next; } /* Allocate memory for the new node and put data in it.*/ pointer->next = (node *)malloc(sizeof(node)); pointer = pointer->next; pointer->data = data; pointer->next = NULL; } int find(node *pointer, int key) { pointer = pointer -> next; //First node is dummy node. /* Iterate through the entire linked list and search for the key. */ while(pointer!=NULL) { if(pointer->data == key) //key is found. { return 1; } pointer = pointer -> next;//Search in the next node. } /*Key is not found */ return 0; } void delete(node *pointer, int data) { /* Go to the node for which the node next to it has to be deleted */ while(pointer->next!=NULL && (pointer->next)->data != data) { pointer = pointer -> next; } if(pointer->next==NULL) { printf("Element %d is not present in the list\n",data); return; } /* Now pointer points to a node and the node next to it has to be removed */ node *temp; temp = pointer -> next; /*temp points to the node which has to be removed*/ pointer->next = temp->next; /*We removed the node which is next to the pointer (which is also temp) */ free(temp); /* Beacuse we deleted the node, we no longer require the memory used for it . free() will deallocate the memory. */ return; } void print(node *pointer) { if(pointer==NULL) { return; } printf("%d ",pointer->data); print(pointer->next); } int main() { /* start always points to the first node of the linked list. temp is used to point to the last node of the linked list.*/ node *start,*temp; start = (node *)malloc(sizeof(node)); temp = start; temp -> next = NULL; /* Here in this code, we take the first node as a dummy node. The first node does not contain data, but it used because to avoid handling special cases in insert and delete functions. */ printf("1. Insert\n"); printf("2. Delete\n"); printf("3. Print\n"); printf("4. Find\n"); while(1) { int query; scanf("%d",&query); if(query==1) { int data; scanf("%d",&data); insert(start,data); } else if(query==2) { int data; scanf("%d",&data); delete(start,data); } else if(query==3) { printf("The list is "); print(start->next); printf("\n"); } else if(query==4) { int data; scanf("%d",&data); int status = find(start,data); if(status) { printf("Element Found\n"); } else { printf("Element Not Found\n"); } } } }


What is the first person to shoot a 3 pointer?

d.j. erving


Is the stack is also known as LIFO?

True, unless you start messing about with the stack pointer.


What is triple pointer?

Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;

Related Questions

When was Piaa Bajpai born?

Piaa Bajpai was born in 1986.


When was PIAA Football Records created?

PIAA Football Records was created in 1913.


What is it called when you make a shot behind the arc in NBA?

a threee pointer


How do you make a 3 pointer in nba2k11?

If you increase your 3 pointer skill your chance of making a 3 pointer is increased. (Myplayer mode). Other from that it's all about your jumpshot timing.


Why does array index start with zero in C language?

Because of pointers and that all arrays are really pointers. A pointer something like *pointer can also be written as pointer[0] and *(pointer + 1) can also be written as pointer[1]


What types of lights does PIAA manufacture?

The PIAA manufactures several standard types of lights. The ones listed on their website are L.E.D. (Light Emitting Diodes), Halogen, and H.I.D. (High Intensity Discharge) lamps.


How many points do you score for a basket?

It all depends on where you shoot from. If you shoot anywhere inside the 3 pointer line during play, it will be counted as a 2 pointer. However, if you shoot outside of the 3 pointer line, then its counted as a 3 pointer. If you are fouled and get the shot in from the free throw line, you get 1 point.


Can Piaa 510 fog lights be installed into the existing positions where the factory fog lights are installed on a 2005 Ford Escape?

The PIAA 510 fog lights are not the proper size to fit in the front bumper fascia where the factory fog lights are mounted. Additionally, there is no mounting point on the Escape to hold the PIAA 510 fog light. The PIAA 510 has a universal design that allows for mounting on a vehicle with enough clearance for the size of the light. It is ideal for newer vehicles that were manufactured with bumper light sockets. For the complete line of PIAA fog lights and driving lights visit AutoLights4Less.com. They offer PIAA and many other fine brands of headlight bulb, headlight assemblies, tail light assemblies, fog lights, driving lights and turn signal lights.


What is the three different point values for making a basket in basketball?

1 pointer-free throw 2 pointer-shot made within the 3 point line 3 pointer-shot made behind the 3 point line


Three types of scoring in basket ball game?

Free throw, 2 pointer, 3 pointer.


How does a basketball player get a 3 pointer?

he shoots a basket from three yards away making it a three pointer


How many possible outcomes are there when you toss a coin and spin the pointer on a spinner with 3 colors?

6 2 on the coin, 3 on the pointer: 2x3=6