| |
GeekInterview.com > Interview Questions > Concepts > Data Structures
| Print | |
Question: Static Queue Items
Answer: Write an algorithm to calculate the number of items in a static queue? |
| February 02, 2009 07:25:35 |
#1 |
| sharmilag |
Member Since: February 2009 Total Comments: 1 |
RE: Static Queue Items |
[F=front, R=rear, P= pointer, q[] is the array variable] Algorithm: if F != R F = P count = 0 while(P <= R) { count = count + 1; P = P+1; } //Display count which shows number of elements in queue. |
| |
Back To Question | |