Algorithm that counts number of nodes in a linked list, Data Structure & Algorithms

Q. Write an algorithm that counts number of nodes in a linked list.                                     

Ans.

Algorithm to Count No. of Nodes in Linked List

COUNT (INFO, LINK, START, NUM)

1. Set NUM: = 0 [initializes counter]

2. Set PTR=START [ initializes pointer]

3. Repeat steps 4 & 5 while PTR! = NULL

4. Set NUM:= NUM + 1 [ increases NUM by 1]

5. Set PTR: =LINK [PTR] . [updates pointer to point to next node]

[End of step 3 loop]

6. Return

 

 

Posted Date: 7/13/2012 2:10:41 AM | Location : United States







Related Discussions:- Algorithm that counts number of nodes in a linked list, Assignment Help, Ask Question on Algorithm that counts number of nodes in a linked list, Get Answer, Expert's Help, Algorithm that counts number of nodes in a linked list Discussions

Write discussion on Algorithm that counts number of nodes in a linked list
Your posts are moderated
Related Questions
human resource management project work in c++

Q. Write a procedure to the insert a node into the linked list at a particular position and draw the same by taking an example?

Write a detailed description of a function that takes in an integer as an argument, then prints out the squares of all positive integers whose squares are less than the input. (The

how to convert 12 hour format into 24 hour format using c program


State in detail about the Integer Carrier set of the Integer ADT is the set {..., -2, -1, 0, 1, 2, ...}, and  operations on these values are addition, multiplication, subtrac

Program Insertion of a node into any Circular Linked List Figure depicts a Circular linked list from which an element was deleted. ALGORITHM (Deletion of an element from a

Describe an algorithm to play the Game of Nim using all of the three tools (pseudocode, flowchart, hierarchy chart)

Insertion: Records has to be inserted at the place dictated by the sequence of keys. As is obvious, direct insertions into the main data file would lead to frequent rebuilding of