What is the valid index range of a zero-based array of length ?
The first element is at index , and the last element of an array of length is at index .
Study 02 Arrays and Dynamic Arrays with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is the valid index range of a zero-based array of length n?
The first element is at index 0, and the last element of an array of length n is at index n−1.
How is an array element’s address calculated?
address(A[i])=B+i×w, where B is the base address and w is the element size in bytes.
What is the typical time complexity of indexed array access?
Accessing or updating an element by a known index is typically O(1) because its address can be calculated directly.
How does an array index differ from an array value?
An index identifies a position; a value is the data stored at that position. For example, 29 is the value at index 2.
What is the time complexity of traversing an array?
Traversing an array of n elements takes O(n) time because each element is visited.
What happens to existing elements during array insertion?
Insertion at index i shifts every existing element from index i onward one position to the right.
Why does array insertion shift elements from right to left?
The loop moves elements from right to left so each value is copied before its destination can overwrite it.
How does array deletion close the removed element’s gap?
Deletion shifts later elements one position left to close the gap left by the removed element.
Why are middle insertions and deletions usually O(n)?
Insertion or deletion at the beginning or middle usually takes O(n) time because elements must be shifted.
What is the difference between dynamic-array size and capacity?
Size is the number of elements currently stored; capacity is the number of elements the allocated storage can hold.
What happens when a dynamic array becomes full?
It allocates a larger backing array, copies the existing elements, replaces the old backing array, and inserts the new element.
What is the amortized complexity of appending to a dynamic array?
With geometric capacity growth, appending is O(1) amortized, although an individual resize can take O(n) time.
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
A 14-question quiz on trees, binary trees, traversals, recursive algorithms, and binary search trees. The questions progress from foundational concepts to applied reasoning about structure, complexity, and BST operations.
A structured guide to comparison-based sorting algorithms, their complexity, stability, memory use, and practical selection criteria.
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.