ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!


    Question

    The amortized time for inserting into a dynamic array

    (like C++ vector) is:
    A O(1) Correct Answer Incorrect Answer
    B O(log n) Correct Answer Incorrect Answer
    C O(n) Correct Answer Incorrect Answer
    D O(n log n) Correct Answer Incorrect Answer
    E O(тИЪn) Correct Answer Incorrect Answer

    Solution

    Occasional reallocation takes O(n), but averaged over all insertions the amortized cost is constant.

    Practice Next
    More Algorithms Questions
    ask-question