Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

INSERT FUNCTION

/*prototypes of insert & find functions */

list * insert_list(list *);

list * find(list *, int);

/*definition of  anyinsert function */

list * insert_list(list *start)

{

list *n, *f;

int key, element;

printf("enter value of new element");

scanf("%d", &element);

printf("enter value of key element");

scanf("%d",&key);

if(start->data ==key)

{

n=(list *)mallo(sizeof(list));

n->data=element; n->next = start; start=n;

}

else

{

f = find(start, key);

if(f == NULL)

printf("\n key is not found \n");

else

{

n=(list*)malloc(sizeof(list));

n->data=element; n->next=f->next; f->next=n;

}

}

return(start);

}

/*definition of a find function */

list * find(list *start, int key)

{

if(start->next->data == key)

return(start);

if(start->next->next == NULL)

return(NULL);

else

find(start->next, key);

}

void main()

{

list  *head;

void create(list *);

int count(list *);

void traverse(list *);

head=(list *)malloc(sizeof(list));

create(head);

printf(" \ntraversing the list \n");

traverse(head);

printf("\n number of elements in the list   %d \n", count(head));

head=insert_list(head);

printf(" \nafter the insertion of new elementstraverse list \n");

traverse(head);

}

Program: Insertion of an element in a linked list at a particular position

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9536865

Have any Question?


Related Questions in Computer Engineering

Do the next application and answer the questions1 print a

Do the next application and answer the questions: 1 /** Print a friendly greeting. */ 2 public static void main(String[] args) { 3 int index; 4 for(index = 0; index 6} 7} Questions: 1. What is the scope of index in the a ...

You really need help with this assignment please provide

You really need help with this assignment. Please provide step by step instructions and screenshot of the steps and execution, so I can follow how to complete this assignment. Prof. Orlando Karam maintains an Ubuntu Linu ...

Structureswrite the program in c onlytask create a seating

Structures Write the Program in C++ only. Task: Create a seating reservation program for Podunk Airlines. The air fleet consists of a single plane with a seating capacity of 12. The plane makes one flight daily. Your pro ...

Question future policy and legislative issuesthe

Question: Future Policy and Legislative Issues The cyberspace domain continues to grow significantly in terms of its size, influence, and complexity. This complexity requires some form of meaningful policy formulation. D ...

Answer the following question what is the relationship

Answer the following Question : What is the relationship between a role and a competency? How do roles facilitate the development and implementation of specific practices for any organization? The response must be typed, ...

In defining demand and supply why do economists focus on

In defining demand and supply, why do economists focus on price while holding constant other factors that might have an impact on the behavior of buyers and sellers?

Question suppose a computer using set associative cache has

Question : Suppose a computer using set associative cache has 2^16 words of main memory and a cache of 128 blocks, and each cache block contains 8 words. Show steps, please type. a. If this cache is 2-way set associative ...

Identify economic decision that is driven by a behavioral

Identify economic decision that is driven by a behavioral bias rather than by pure rational behavior. why are they differ today?

A summary of business activities of a course registration

A summary of business activities of a "Course Registration System" for enrolling courses for students and for enrolled class lists for faculty members at an online university is as follows: The Physics Department provide ...

Suppose you are given the following consumption and income

Suppose you are given the following consumption and income data: Consumption   100   190  280  370  460  550 Income                 0   100  200  300  400  500 Obtain an equation for the consumption function. Use your fu ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As