answersLogoWhite

0

What is an algorithm of inserting elements of link list?

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer

To insert an element in a linked list, you need a pointer to the new element, and a pointer to the target element. Set new.next = target.next, and then set target.next = new. This will insert new after target. To insert before target, you need the pointer to the element brfore target, and you can find that by searching from top until you find an element where element.next == target. To insert at top, a special case, you set new.next = top, and then set top = new.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is an algorithm of inserting elements of link list?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

3 Write the algorithm of inserting an element at middle of a linked?

theory part to how u can insert element at middle of link list ?


Is an algorithm that puts elements of a list in a certain order?

This is called sorting.


Write the Algorithm of inserting an element at middle of linked list?

I am telling you the algorithm of inserting an element at any location of simply link list:-insert_loc(start,item,loc)step1. [Check for overflow]if ptr=NULLthen print overflowexitelse[ptr=(node*) malloc (size of nodes)] {memory allocation}step2. set ptr->info=itemstep3. set i=1set temp=startstep4. Repeat step 5&6 until inextstep6. set i=i+1step7. set ptr->next=temp->nextstep8. set temp->next=ptrGood luckRjames007


How to write an actual algorithm for inserting an element in a linked list?

Insert newNode into a linked list after targetNode Node currentNode = root while currentNode != targetNode currentNode = currentNode.next newNode.next = currentNode.next currentNode.next = newNode


What is a stock sorting algorithm?

Stock sorting algorithm is a algorithm which is used to sort any kind of stock i.e. any data type containing the primitive values like array ,link list ,stack etc.


What is stock sorting algorithm?

Stock sorting algorithm is a algorithm which is used to sort any kind of stock i.e. any data type containing the primitive values like array ,link list ,stack etc.


What is a chart that list elements?

The "Periodic Table of the Elements". See related link below.


List the first elements and their symbols form the periodic table of elements?

Refer to the related link.


List down the names of any three parameters on which you analyze an algorithm?

what is algorithm and its use there and analyze an algorithm


What is pseudo code algorithm for create a linked list with a header and insert a four numbers to the list?

pseudo code algorithm to create a linked list


Do trace elements have to be radioactive?

No, trace elements are not necessarily radioactive. A link to a list of elements that have no natural radioactive isotopes is at a related question, below.


Which elements boils above 2500 degrees?

See a complete list at the link below.