write an algorithm for transversing nodes in a single linked list? Explain with an eg.
Answers
Answered by
1
Answer:
hii I think that it helps you
Explanation:
Algorithm
STEP 1: SET PTR = HEAD.
STEP 2: IF PTR = NULL.
STEP 4: REPEAT STEP 5 AND 6 UNTIL PTR != NULL.
STEP 5: PRINT PTR→ DATA.
STEP 6: PTR = PTR → NEXT.
STEP 7: EXIT.
Answered by
1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❥Declare a pointer to node type variable to store link of first node of linked list. Say head = (struct node*)malloc(sizeof(struct node)); . If there is no memory to allocate for head node i.e. head == NULL . Then print some error message and terminate program, otherwise move to below step.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Similar questions