-
January 11th, 2011, 10:27 AM
#1
Selection of Data Structure
Can you please give me guidelines in selection of a particular data structure like linked list,binary tree etc based on certain selection criteria? Pl provide me any link or readymade table if you have.
-
January 11th, 2011, 10:39 AM
#2
Re: Selection of Data Structure
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
January 12th, 2011, 12:44 AM
#3
Re: Selection of Data Structure
Choice of data structure is guided by (a) space requirements, (b) time requirements for various operations, and (c) expected usage pattern.
For instance, if you need to do a lot of searches on a batch of static data that is loaded once and then never changes, it may be best to put it all in a std::vector and then call std::sort() once. (Subsequent searches may be done with std::lower_bound().)
But if you know that you'll need to do lots of insertions and/or deletions interspersed with the lookups, then a std::set or std::map may be more suitable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|