From 2f20c9e757140fbef3e9e28dcba9a1ff288a3062 Mon Sep 17 00:00:00 2001 From: sahib-007 <73030244+sahib-007@users.noreply.github.com> Date: Sat, 17 Oct 2020 20:51:51 +0530 Subject: [PATCH] Algorithm to traverse in a Linked List --- Algorithms/Traversing in Linked list | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Algorithms/Traversing in Linked list diff --git a/Algorithms/Traversing in Linked list b/Algorithms/Traversing in Linked list new file mode 100644 index 0000000..0e17640 --- /dev/null +++ b/Algorithms/Traversing in Linked list @@ -0,0 +1,17 @@ +STEPS: + + 1.If First=NULL then {print “List empty” STOP}; + + 2.count=0; + + 3.ptr=First; {point ptr to the 1st node} + + 4.While ptr<> NULL repeat Steps 5 to 6 + + 5.count=count+1; + + 6.ptr=NEXT(ptr) [shift ptr to the next node] + + 7.print (‘Number of nodes=’, count) + + 8.END