Write procedure to the insert a node into the linked list, Data Structure & Algorithms

Assignment Help:

Q. Write a procedure to the insert a node into the linked list at a particular position and draw the same by taking an example?                                                                                                       

Ans:

* Insert (after legal position p).*/

/* Header implementation assumed. */

void insert( element_type x, LIST L, position p )

{

position tmp_cell;

tmp_cell = (position) malloc( sizeof (struct node));

if( tmp_cell == NULL )

fatal_error("Out of space!!!");

else

{

tmp_cell->element = x; tmp_cell->next = p->next; p->next = tmp_cell;

}

}

1421_linked list.png


Related Discussions:- Write procedure to the insert a node into the linked list

Write functions for both addition and subtraction, You will write functions...

You will write functions for both addition and subtraction of two numbers encoded in your data structure. These functions should not be hard to write. Remember how you add and subt

Process of analysis, The objective analysis of an algorithm is to determine...

The objective analysis of an algorithm is to determine its efficiency. Efficiency is based on the resources which are used by the algorithm. For instance, CPU utilization (Ti

Circular linked list, In a circular linked list There is no beginning a...

In a circular linked list There is no beginning and no end.

Booth algorithm, what is boot algorithm and some example

what is boot algorithm and some example

Avl tree rotations, AVL trees and the nodes it contains must meet strict ba...

AVL trees and the nodes it contains must meet strict balance requirements to maintain O(log n) search time. These balance restrictions are kept maintained via various rotation func

Generate a single sorted list of all n elements, Q. Assume that we have sep...

Q. Assume that we have separated n elements in to m sorted lists. Explain how to generate a single sorted list of all n elements in time O (n log m )?

Multiple queue, #questionalgorithm for implementing multiple\e queues in a ...

#questionalgorithm for implementing multiple\e queues in a single dimensional array

What is gouraud shading, Gouraud Shading The faceted appearance of a La...

Gouraud Shading The faceted appearance of a Lambert shaded model is due to each polygon having only a single colour. To avoid this effect, it is necessary to vary the colour ac

Multiqueue, data structure for multiqueue

data structure for multiqueue

Discrete time simulation of a queue, In this project you will write a progr...

In this project you will write a program to produce a discrete time simulation of a queue as shown in Fig. 1. Time is slotted on the input and the output. Each input packet follows

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd