Advertisement

12.25.2007 at 07:41PM PST, ID: 23042708
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

Circular Queue Implementation - will this work?

Asked by rachitkh in Miscellaneous Programming, Programming Languages, Java Programming Language

Tags:

I have written the Circulat queue implementation of enqueue, dequeue and initialize for the first tie and I do not have the setup to test it. Could anyone please verify the code and also let me know the changes required. Also I have tried to make it thread safe using the Synchronize function.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
class CircularQueue 
{
  private int[] array;
  private int head=0; 
  private int tail=0; 
  private int count=0; 
  private int arraySize=0;
    
  CircularQueue() {
       initialize();
  }
  
  public void  enqueue(int val) throws Exception 
  { 
    synchronize {
     if(count>=arraySize) 
       throw new Exception(" queue full"); 
     q[tail]=val; // put the object to the 
     tail=(tail+1)%arraySize; // move the tail circulary 
     count++;   
    }
  } 
   
  public int dequeue() throws Exception
  { 
    synchronize { 
     if(count==0) 
       throw new Exception("queue empty"); 
     int res=data[head]; // take the object from the head 
     head=(head+1)%arraySize; // move the head circulary 
     count--; 
     return res; 
    }
  } 
  
  public void  initialize() throws Exception
  { 
      private static BufferedReader stdin = 
            new BufferedReader( new InputStreamReader( System.in ) );
      
      System.out.print( "Please enter the size of the queue" );
      String input = stdin.readLine();
      
      arraySize = Integer.parseInt(input);
      array = new int[arraySize] ; 
  } 
}
[+][-]12.25.2007 at 10:34PM PST, ID: 20528500

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Miscellaneous Programming, Programming Languages, Java Programming Language
Tags: Java
Sign Up Now!
Solution Provided By: ysnky
Participating Experts: 4
Solution Grade: A
 
 
[+][-]12.26.2007 at 04:17AM PST, ID: 20528956

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.27.2007 at 03:34AM PST, ID: 20533411

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.27.2007 at 08:47AM PST, ID: 20535138

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.27.2007 at 10:33AM PST, ID: 20535945

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.27.2007 at 12:02PM PST, ID: 20536702

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.27.2007 at 10:47PM PST, ID: 20540116

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 06:00AM PDT, ID: 21401171

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628