Computer Science EngineeringHard
Appending n elements one at a time to a dynamic array that doubles its capacity when full costs, per append, an amortized
- A. O(n)
- B. O(log n)
- C. O(1)
- D. O(n log n)
Correct answer: C. O(1)
Total copying across all doublings is below 2n, so the amortized cost per append is constant.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- With open addressing and uniform hashing, the expected number of probes in an unsuccessful search is at most 1/(1-alpha). What is this…
- A connected undirected graph has 9 vertices and 12 edges. Its cyclomatic number (number of independent cycles) is
- How much extra space does reversing a singly linked list in place (iteratively) require?
- A queue starts empty. Operations: enqueue 1, enqueue 2, enqueue 3, dequeue, enqueue 4, dequeue, enqueue 5. Which element is now at the…
- The textbook minimum number of stacks needed to implement a queue is
- In a binary search tree, the inorder successor of a node that has a non-empty right subtree is