Skip to content

Page-208. Problem-20 #4

Open
Open

Description

@cicadabear

The formula is not right, n/k*(n+k)/2->O(n^2) the cost per operation(Amortized complexity) should be O(n).
From More Exceptional C++

Fixed-increment growth. The new buffer should be a fixed amount larger than the current buffer.
For example, a 64-byte increment size would mean that all string buffers would be an integer
multiple of 64 bytes long.
Advantage: little wasted space. The amount of unused space in the buffer is bounded by
the increment size, and does not vary with the length of the string.
Disadvantage: moderate performance. This strategy requires both O(N) allocations and an
average of O(N) copy operations per char. That is, both the number of allocations and the
average number of times a given char is copied vary linearly with the length of the string.
However, control of the constant factor is in the hands of the String implementer

Activity

  1. added
    bug
    on Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions