Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Memory space required for java 6 queue

1. ## Memory space required for java 6 queue

I have a question from my assignment which I don't entirely understand. Can anyone please look at it and see if it's as easy as I thought it was or if I'm wrong, in which case can anyone help? This is the question; the answers follow:

Assume that an integer requires 2 bytes of space and a reference requires 4 bytes of space. Also assume the maximum queue size is 200. We define "overhead" space as the space required by the structure that does not include the space used by the elements the structure contains.
a) How much overhead space is needed for:
i. A bounded array-based queue holding 20 elements? 40
ii. A bounded array-based queue holding 100 elements? 200
iii. A bounded array-based queue holding 200 elements? 400
iv. A reference-based queue holding 20 elements? 80
v. A reference-based queue holding 100 elements? 400
vi. A reference-based queue holding 200 elements? 800
b) For what size queue do the array-based and reference-based approaches use approximately the same amount of overhead space?

2. ## Re: Memory space required for java 6 queue

Check your answers to parts i-iii. that's only true for an empty queue with that capacity.

3. ## Re: Memory space required for java 6 queue

Originally Posted by helloworld922
Check your answers to parts i-iii. that's only true for an empty queue with that capacity.
Added: If and only if it's of type Integer.