CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #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.

  2. #2
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    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.

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    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
  •  





Click Here to Expand Forum to Full Width

Featured