ProgrammingModerate
A dynamic array grows from capacity 1 by doubling. How many doublings are needed to reach capacity 1024 from 1?
- A. 10
- B. 9
- C. 11
- D. 1024
Correct answer: A. 10
The capacities go 1, 2, 4, ..., 1024, which is 10 doublings since 2^10 = 1024.
More C Programming questions
- A list of 6 nodes is split into two halves by a slow and fast pointer. The slow pointer is at the start of the second half. Which node…
- A stack is kept as a linked list with the top at the head. Push A, push B, pop, push C, pop. Which element is on top at the end?
- A queue made from a singly linked list with a head and a tail pointer enqueues 1, 2 and 3, then dequeues once. What is the front value now?
- A binary search tree is built by inserting 5, 3, 8, 1 in that order. How many nodes are in the left subtree of the root?
- Keys 2, 7 and 12 are inserted into a table of size 5 with h(k) = k % 5 using linear probing. In which slot does 12 end up?
- A chained hash table is searched for a key that is absent. The chain at its bucket has 4 nodes. How many key comparisons are made?