Algorithm to count number of nodes, Data Structure & Algorithms

Write an algorithm to count number of nodes in the circular linked list.                           

Ans.

Counting No of Nodes in Circular List

Let list be a circular header list in memory. This algorithm traverse and counts number of nodes in a LIST.

0.   set COUNT: = 0

1. Set PTR: = LINK [START]. {Initializes the

pointer PTR}

2. Repeat steps 3, 4, 5 while PTR  =   START;

3. COUNT = COUNT + 1

4. Set PTR = LINK [PTR]. [PTR now points to next

node]

[End of step 2 loop]

5. Exit

 

Posted Date: 7/12/2012 8:27:44 AM | Location : United States







Related Discussions:- Algorithm to count number of nodes, Assignment Help, Ask Question on Algorithm to count number of nodes, Get Answer, Expert's Help, Algorithm to count number of nodes Discussions

Write discussion on Algorithm to count number of nodes
Your posts are moderated
Related Questions
what is an algorithms

Explain the bubble sort algorithm. Answer This algorithm is used for sorting a list. It makes use of a temporary variable for swapping. It compares two numbers at an insta

Enumerate about the Data structure An arrangement of data in memory locations to signify values of the carrier set of an abstract data type. Realizing computational mechanis

Determine YIQ Colour Model Whereas an RGB monitor requires separate signals for the red, green, and blue components of an image, a television monitor uses a single composite si

Give the example of bubble sort algorithm For example List: - 7 4 5 3 1. 7 and 4 are compared 2. Since 4 3. The content of 7 is now stored in the variable which was h

If a node in a BST has two children, then its inorder predecessor has No right child

Binary Space Partition A binary space-partitioning (BSP) tree is an efficient method for determining object visibility by painting surfaces onto the screen from back to front,

There are ten stations on a railway line: Train travels in both directions (i.e. from 1 to 10 and then from 10 to 1).  Fare between each station is $2. A passenger input

an electrical student designed a circuit in which the impedence in one part of a series circuit is 2+j8 ohms and the impedent is another part of the circuit is 4-j60 ohm mm program

Question a) Describe how the endogenous model is an improvement to the neo-classical model in explaining the long-run effect of investment on economic growth of a country.