× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
5
k
4
c
4
4
M
3
t
3
i
3
B
3
k
3
m
3
c
3
o
3
New Topic  
Stromile Stromile
wrote...
Posts: 299
Rep: 0 0
6 years ago
Challenge: Assume a function g(x) is defined as follows where x is an int parameter:
   g(x) = g(x - 1) * g (x - 3) if x is even and x > 3
        = g(x - 2) if x is odd and x > 3
        = x otherwise
Write a recursive method to compute g. In implementing a queue using an array, a problem might arise if the queue is implemented in such a way that items in the queue are inserted at the next available location and removed from the next leading position, but such that, once deleted, the emptied space is unused.  The problem that arises is one where there is free space still in the array, but it is not usable because it is not at the end.  Demonstrate this problem with a queue that is stored in an array of size 5 for the following instructions.  Next, explain how you might resolve this problem.
Queue q = new Queue(5);   //  assume the Queue constructor
                takes 5 as the size of the array
q.enqueue(3);
q.enqueue(4);
q.enqueue(1);
q.dequeue();
q.dequeue();
q.enqueue(6);
q.enqueue(5);
q.dequeue();    // at this point, there are only 2 items
   in the queue
q.enqueue(7);   // this enqueue can not occur, why??
Read 42 times
1 Reply
Replies
Answer verified by a subject expert
StingerStinger
wrote...
Posts: 310
Rep: 4 0
6 years ago
Sign in or Sign up in seconds to unlock everything for free
This verified answer contains over 280 words.
1

Related Topics

Stromile Author
wrote...

6 years ago
Brilliant
wrote...

Yesterday
I appreciate what you did here, answered it right Smiling Face with Open Mouth
wrote...

2 hours ago
Thanks
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  916 People Browsing
Related Images
  
 44
  
 304
  
 355
Your Opinion
How often do you eat-out per week?
Votes: 80

Previous poll results: Do you believe in global warming?