Update node in single linked list at any position

Algorithm for Update node
  • Step1: First check the head status, if head status is NULL then it is EMPTY LIST, so no need to perform any task.
  • Step2: If head status is other then NULL then,
      • Get node count value.
      • Get node position value to perform delete operation.
      • validate node position value, if valid position, then go for further process.
  • Step3: If node position value is 1.Then take new data and update head->data value.
  • Step4: If node position value is other then 1, Then process following steps
      • Take a temporary head i.e. th and assign current head value to th.
      • Create a loop and travel up to link position.
      • Take new information and update th->data value.

0 comments:

Post a Comment