Like Tree1Likes
  • 1 Post By manasij7479

resize funtion complexity

This is a discussion on resize funtion complexity within the C++ Programming forums, part of the General Programming Boards category; If my string s size is n and I do something like s.resize(c); // c < n will it take ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    28

    resize funtion complexity

    If my string s size is n and I do something like

    s.resize(c); // c < n

    will it take constant time or linear?

    What will it be in case of c > n.

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,508
    King Mir likes this.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,370
    O_o

    The size is not the same as capacity.

    If you want to fit the capacity to the contents you'll have to depend on a linear solution or one that isn't portable.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time Complexity
    By Stuart Dickson in forum C Programming
    Replies: 7
    Last Post: 07-20-2010, 04:13 AM
  2. Complexity
    By spikestar in forum C Programming
    Replies: 9
    Last Post: 02-09-2010, 05:11 PM
  3. complexity
    By ibrahim630 in forum C Programming
    Replies: 7
    Last Post: 06-04-2009, 11:42 AM
  4. Complexity
    By mMarko in forum C Programming
    Replies: 7
    Last Post: 01-07-2009, 04:51 AM
  5. Complexity Problem
    By QuestionC in forum Tech Board
    Replies: 14
    Last Post: 03-26-2007, 02:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21