 Hello friends, I am Sanjay Bhukta. I welcome you on Sanjay Bhukta Tech School. In this video, I am going to explain how to write an algorithm to traverse a language. So before writing an algorithm, let me draw a language so that we can add that for our reference purpose. So suppose this is start pointer, then this is our first node, this is our second node, and this is our third node, right? So node 1, node 2, node 3. So I hope you have watched my previous video where I explained you know what is actually consistent things. First one is information or you can say value that we want to process and second is pointer to next node. So this node's base address will be stored here, this node's base address will be stored here and node number 1's base address will be stored here. So let's say I am executing the base address of this node is 1001, right? It is 2001, it is 3001. So this address will be stored here, 2001 will be stored here, 3001 will be stored here and it will be null. So this way we can present a language in memory and each node will be stored at different location but they will be connected with each other address like second node address will be available with first node, third node address will be available with second node. So this way these nodes are internally connected but basically they are available at different locations. Now let's say value or information is 10 for this node 1, this node 2 is having 20 and node 3 is having 30. So now we need to implement an algorithm so that we can grab each node of the languages and we can find out the information part of the language, right? So now I am going to write an algorithm, so name of algorithm will be backwards, it will be requiring one paragraph start, start will be the, will be containing address of first node then info and link or here you can also write next, right? So this is basically this part of node, so it is containing address of next node, so you can write next or you can write in whatever you want to write, you can write here. Now, step number one, so step number one will be set PTR equals to start, so PTR will be loop on them which will be moving from one node to another so that we can identify the values. So start is having address of first node, so now we are assigning that address into PTR, so PTR is also pointing to first node, so we can write it here like PTR equals to 1 over 0, PTR is pointing to first node. Then step number two, so in case of step number two, I need to implement a loop, so I am writing repeat steps, so some steps will be repeated here, so we are going to repeat step number three and four, right? So two steps will be repeated and condition will be PTR not equals to null, so if this PTR is having a particular address then this loop will repeat, if it is equals to null then this loop will be terminated, so this loop will repeat when PTR is not equal to null. So now I need to write step number three, so in case of step number three, I need to write a statement where it will look like we are traversing the algorithm. So here I can write process, process can be you can say count or you can say print, so it can be I am writing it can be counting of values, it can be printing of values, etc. So any process that you want to apply on these values you can write here, then so apply process to info of PTR, so info of PTR means PTR is pointing to this location, what number do you want and its information part is counting, so let's say here we are writing print info of PTR, so what will be printing of outputs PTR? So PTR is pointing to this node, so we expected the information part, now after printing that information we want PTR to be pointing to node number two, so how we can do that, so for that I am writing step number four. So in case of step number four, we need to set PTR equals to link of PTR, so PTR is basically pointing to this node which is internally divided into two parts, so you can say it as next or you can say it as link. So right now I consider it as link, you can also like next layer, so whatever you want to layer, you can use it here, so PTR link, PTR link is 2001, will be stored into PTR, so it means PTR is pointing to 1001, at this location in this part we are having, we are having values 2001, so that will be assigning to PTR, so new value PTR will be 2001. So this way if you want to move from node one to node two to node three, so you need to use this step in your time limit, right, and here I am writing end of loop, so PTR is pointing to 2001, so here we need to check PTR not equals to addition is two, now print info of PTR. So PTR is pointing to 2001, so it's information part is 20, so 20 will be processed and then PTR equals to link of PTR, so in this case PTR link is 2001, so that will be assigning to PTR, so it's new value will be 2001. So again we need to check this, it is not equals to null, so again the information of PTR is the process, so right now I am writing, then PTR equals to link of PTR, so PTR link is null, so this time PTR will be having null, now if we check this condition PTR not equals to null, so it is false, it means our process is completed, and at step number five you can type end, so this way you can traverse individual node or individual block of link list by moving from node number one to node number three to node number two to node number three, so I hope with this you understood how we can traverse a single link list from a particular node to another and if you want to know how we can convert this algorithm into a C program, so for that you can go to description of this video and you will find the link of place where I have uploaded all the algorithm converted with the help of C language, so you can watch that and you can understand how we can write link list programs with the help of C language. So I hope you understood whatever I have demonstrated in this video, thank you for watching this video.