• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

data structure question

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A series of objects are to be placed in a collection. The usage pattern for the collection indicates that
order of the objects is important, and insert operations and remove operations are very common. Which
of the following is the most appropriate data structure for that collection:

A. Queue
B. Set
C. HashMap
D. LinkedList
E. ArrayList
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this question taken from somewhere, or did you make it up? If you got it from somewhere, we require you cite your sources. Also, we don't just hand out answers, so tell us what YOU think the answer is, and we can discuss. Any post that is simply the answer will most likely be deleted by a moderator.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This seems like an assignment question to me, to make it easier for you to answer,
let me highlight some hints in the question you provided.

auvrm papu wrote:A series of objects are to be placed in a collection. The usage pattern for the collection indicates that
order of the objects is important, and insert operations and remove operations are very common. Which
of the following is the most appropriate data structure for that collection:

A. Queue
B. Set
C. HashMap
D. LinkedList
E. ArrayList



order of the objects is important: find out which collection honors the order
insert,remove : Assuming its not 'add' but 'insert' or rather 'random insert', which collection allows you to do so ?
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edited to remove answer
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read DoYourOwnHomework.
 
auvrm papu
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my friend asked this question, i guess, probably he made it up..
i was saying it's linked list..but he says it's arraylist.

so I posted it to verify with you guys. that's it
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, can you figure out the reason he's saying what he's saying?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

auvrm papu wrote:my friend asked this question, i guess, probably he made it up..
i was saying it's linked list..but he says it's arraylist.

so I posted it to verify with you guys. that's it


One of you has it spot on, the other one is very very close. The difference is in the requirement that inserting and removing are "very common". That makes one better than the other. Do you stay with your original answer or are you going to follow your friend? And more importantly, why?
 
auvrm papu
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm staying with my answer linked list, as my old school data structure teacher once told me that linked list is best for insert/delete.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not a particularly good reason why--what's *your* reason?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should get into the habit of looking through the Java™ Tutorials because there is always something useful to be found there.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic