GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  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?


September 09, 2009 00:30:13 #4
 boyanamadhavilatha   Member Since: September 2009    Total Comments: 1 

RE: Static Queue Items
 
[F=front, R=rear, P= pointer, q[] is the array variable]
Algorithm:
     if F != R
       P= F
       count = 0
       while(P <= R)
       {
          count = count + 1;
          P = P+1;
        }
 //Display count which shows number of element
     

 

Back To Question