Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7978873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:36:39+00:00 2026-06-04T09:36:39+00:00

This is a follow up to Is a list implementation of binary tree scalable?

  • 0

This is a follow up to
Is a list implementation of binary tree scalable?

What can be the advantages or disadvantages of tree implementation done
using linear array(stl vector) or stl deque

rather than a binary tree with individual nodes having left and right pointers?

assumptions:
the tree will be precomputed and will not be modified once built, and will only be used for searching.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:36:40+00:00Added an answer on June 4, 2026 at 9:36 am

    Well, I’d say it’s something of these:

    • with a pointer-tree, you use memory for data and pointers to data, while with std::vector you only allocate memory for the data (the container deals with iterating through itself)
    • if you use std::vector, you memory is localized. E.g. if you want to access a single full level of a tree, that will be sequential in memory, while with individual nodes allocated separately, you would jump through the memory like a bunny rabbit accessing all that
    • if you allocate individual nodes, you actually have no way to allocate them except individually. That means a lot of calls to the malloc-euqivalent function. (There are some tricks you could use to avoid that in C, and they still work in C++, but why go with hacks if you have a ready std::vector solution).
    • when creating a vector, you can use std::vector.reserve() to preallocate all the memory. Additionally, if you know how vector operates, you know that it will call a malloc-equivalent for reserving memory approximately every time you start a new level of your tree – number of allocations should be roughly equal to number of levels in your tree
    • accessing elements of a vector is so easy, navigating through a vector-based fully populated binary tree is very intuitive and easy to work with
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is follow-up to: using xslt to create an xml file in c <element1
I tried to follow this but the default modelbinder let my array null on
Does this follow a common namespace design pattern for XML in such a way
My app crash giving this follow. *** -[MyItem respondsToSelector:]: message sent to deallocated instance
I follow this link site to integrate Twitter on Android. But the problem is
I follow this rule but some of my colleagues disagree with it and argue
I just follow this http://www.dotnetcurry.com/ShowArticle.aspx?ID=585 to do the project but have error ambiguity and
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
If you follow this link to one of the pages on my site and
I am learning C and attempting a crude implementation of a linked list in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.