DSA Arrays
An array-like sequence stores items in an ordered set of positions. Decide whether a position is just a current offset or a stable identity before using it in another structure.
How it works
Python lists are dynamic arrays of object references, not fixed C arrays of inline integers. Indexing a valid position is convenient, while insertion near the front shifts later references. The fixture inserts a new orchard observation and shows that the old second observation now has another index. Business identity should normally be stored separately if it must survive sorting, insertion or deletion.
Run the code
Select Try in playground to load this complete source into the existing Python editor. It does not run automatically; choose Run when ready. These examples use only the Python standard library and small fictional inputs. They do not need database services, extra packages or personal files.
For local work, save the complete source as arrays.py and run python arrays.py. The local review uses Python 3.12.14; the browser uses the existing Pyodide 0.27.7 runtime. Keep inputs small, respect explicit table/tour budgets and account for recursion limits before increasing a fixture’s size.
Example
observations = [(301, 7), (302, 4), (303, 6)]
observations.insert(1, (304, 2))
print([record[0] for record in observations])
print(observations[2])
removed = observations.pop(1)
print(removed[0], len(observations))
Expected result
[301, 304, 302, 303] (302, 4) 304 3
Observation 302 survives with its original identity even though its current offset changes. Removing the inserted record restores the count but does not imply that every sequence operation has the same cost or preserves an external index reference.
Time, space and assumptions
Valid list indexing is O(1) under the usual reference-access model; middle insertion/deletion is O(n). Python list append is amortized O(1), with occasional growth work rather than a constant worst-case guarantee.
Consult the Python 3.12 standard-library reference for container and language contracts; an example result is not a proof of every possible input or real-world performance.