Inserting a node C

A node can be inserted into the list either before the first node (so that the new node becomes the first node) or in between anywhere in the list. If we write a function to insert, we will need the information as to where the node is to be inserted, by accepting an e_no, before which the node is to be inserted.
code snippet for insertion of node

Inserting a node

A new pointer defined, newrecord. New employee number is accepted. Target is assigned the value of e_no before which new node is to be inserted.

Inserting a node

If target is 1 and new e_no = 7, then new node is to be inserted at the beginning of the list as shown diagrammatically.

new node is to be inserted at the beginning of the list

new node is to be inserted at the beginning of the list
If target is 8 and new e_no = 7, then newrecord node is be inserted before node whose e_ no = 8. The function locate, locates the node before the target node and returns a pointer to it.

node before the target node and returns a pointer

node before the target node and returns a pointer


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C Topics