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 6613843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:16:00+00:00 2026-05-25T20:16:00+00:00

I am looking at big code base in C++. There is line mentioned as

  • 0

I am looking at big code base in C++. There is line mentioned as below

int capacity( ) const
{
    return ( 1 << theTrees.size( ) ) - 1;
}

Here theTrees is

vector<int> theTrees

What is statement 1 << theTrees.size( ) likely trying to achieve? Assume we have tree size of 25 elements.

  • 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-05-25T20:16:00+00:00Added an answer on May 25, 2026 at 8:16 pm

    A left shift by n is basically multiplying by 2 to the nth power. Whenever you have 1 << n you’re just calculating the nth power of 2. E.g.:

    1 << 0 = 1
    1 << 1 = 2
    1 << 2 = 4
    1 << 3 = 8
    

    Etc.

    I suspect theTrees.size() returns not the number of elements in the tree but the height of the tree (number of levels), because that’s the only way this makes sense. Given a full binary tree, the number of nodes is 2^N – 1, where N is the height of the tree. E.g., a tree with three levels (n = 3) can hold 2^3 – 1 = 7 nodes. Check it: The first level has one, the second has two and the third has four. 1 + 2 + 4 = 7.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking at the code for some big websites (as I sometimes do) I noticed
I've got a big big code base that includes two main namespaces: the engine
I'm currently working on a quite big (and old, sigh) code base, recently upgraded
I'm looking for a crypto library to use with Objective-C code. There is a
I looking for the function that prints file size on the mode-line in size-indication-mode.
I have quite a big code here... But fortunately it is not needed to
I am currently looking at some code which basically reads data line-by-line from a
Rather than have everything in one big dialog, I'm looking at being able to
Many applications have dialogs which have totally custom-looking dialogs, big fat tool-bars and non-rectangular
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools

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.