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
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

What is bubble sort? Bubble Sort: The basic idea in bubble sort is to scan the array to be sorted sequentially various times. Every pass puts the largest element in its corr

Q. Write  down a   programme  in  C  to  create  a  single  linked  list also  write the functions to do the following operations (i)  To insert a new node at the end (ii

how to learn about time complexity of a particular algorithm

Here,  m represents the unordered array of elements n  represents number of elements in the array and el  represents the value to be searched in the list Sep 1: [Initialize]

Write the non-recursive algorithm to traverse a tree in preorder.    The Non- Recursive algorithm for preorder traversal is as follows: Initially  push NULL onto stack and

This is a unit of which targeted on the emerging data structures. Red- Black trees, Splay trees, AA-trees & Treaps are introduced. The learner must explore the possibilities of app

algorithm of output restricted queue.

give some examples of least cost branch and bound method..

The size of stack was declared as ten. Thus, stack cannot hold more than ten elements. The major operations which can be performed onto a stack are push and pop. However, in a prog