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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Memory space required for java 6 queue

  1. #1
    Member
    Join Date
    Feb 2011
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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.
    Last edited by helloworld922; November 10th, 2011 at 01:46 AM.

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Memory space required for java 6 queue

    Quote Originally Posted by helloworld922 View Post
    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.

Similar Threads

  1. Source Code to Implement Circular Queue in Java
    By rainbow9 in forum Java Programming Tutorials
    Replies: 0
    Last Post: August 20th, 2011, 02:30 AM
  2. Java Heap Space
    By aussiemcgr in forum Java Theory & Questions
    Replies: 4
    Last Post: September 8th, 2010, 05:05 PM
  3. Memory Handling -de allocate memory in Java
    By 19world in forum Java Theory & Questions
    Replies: 4
    Last Post: June 15th, 2010, 04:05 AM
  4. AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    By nasi in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 25th, 2010, 10:37 PM
  5. Out of memory - Java heap space
    By fraxx in forum Java Theory & Questions
    Replies: 4
    Last Post: November 24th, 2009, 05:26 AM