in reply to Re^8: [OT:] Is this Curriculum right?
in thread [OT:] Is this Curriculum right?

Perl arrays use a doubling trick to ensure that push and unshift are near O(1) like with linked lists.

Unshifts are O(1).

Unshifts and pushes are amortized O(1) (meaning O(N) to do N of them).

Replies are listed 'Best First'.
Re^10: [OT:] Is this Curriculum right?
by LanX (Saint) on Nov 28, 2021 at 05:33 UTC
    > Unshifts are O(1).

    Please explain why not "amortized O(1)", the cases are symmetric.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Sorry, was thinking of shift.