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
Define the External Path Length The External Path Length E of an extended binary tree is explained as the sum of the lengths of the paths - taken over all external nodes- from


Each data record contains a fixed place in a relative file. Each record ought to have associated with it in integer key value which will help identify this slot. Therefore, this ke

Importance of Object-Oriented over java Java is basically based on OOP notions of classes and objects. Java uses a formal OOP type system that should be obeyed at compile-t

The number of interchanges needed to sort 5, 1, 6, 2 4 in ascending order using Bubble Sort is 5

In internal sorting, all of the data to be sorted is obtainable in the high speed main memory of the computer. We will learn the methods of internal sorting which are following:

The disadvantages or limitations of the last in first out costing method are: The election of last in first out for income tax purposes is binding for all subsequent yea

State the Introduction to pseudocode No specific programming language is referred to; development of algorithms by using pseudocode uses generic descriptions of branching, loop

What is A Container Taxonomy It's useful to place containers in a taxonomy to help understand their relationships to one another and as a basis for implementation using a class

In this part, students are allowed to implement the following simplifications in their table and data design. o Availability for the beauty therapists don't have to be considere