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

Preorder traversal of a binary tree struct NODE { struct NODE *left; int value;     /* can take any data type */ struct NODE *right; };   preorder(struct N

Q. Give the algorithm for the selection sort. Describe the behaviours of selection sort when the input given is already sorted.

what algorithms can i use for the above title in my project desing and implmentation of road transport booking system

1. Define the following terms in a rule-based expert system? a) Knowledge base b) Inference engine 2. What is a fuzzy rule? Explain the difference between classical and fuzzy

How to create multiple queue on single array?

What is a linear array? An array is a way to reference a series of memory locations using the similar name. Every memory location is shown by an array element. An  array elemen

implement multiple stack in single dimensionl array.write algorithms for various stack operation for them

In this assignment, you are invited to design and implement a software system for catalogue sale. A catalogue is organised in a tree structure. Each node of the catalogue tree repr

A stack is a last in, first out (LIFO) abstract data type and sequential data structure. A stack may have any abstract data type as a component, but is characterized by two fundame