PLAIN/TEXT — ISSUE 109/456 COMPUTER SCIENCE · FOUNDATION / CS · ARRAYS AND LINKED LISTS · ~4 MIN READING DATE: 2027-01-18 ARCHIVE: https://plaintext.click/newsletter/ SUBJECT: Why item ten can be easy to reach—or not Why item ten can be easy to reach—or not ======================================== / START HERE A playlist is an ordered collection, but a computer can store that order in more than one way. An array is a sequence whose equal-sized entries occupy consecutive memory positions, allowing direct access by position. A linked list stores separate records connected by stored directions to the next record, so reaching a later one means following those links. / WHY NOW Both arrangements can show the same playlist on screen. Their different costs appear when the app jumps to a numbered entry or inserts something near the beginning. / THE IDEA An address is a number identifying a memory location. In a fixed-entry-size array, the location of entry i is the starting location plus i times the entry size. The first entry is numbered zero in our example. No earlier entries must be read to calculate the address of a later one. A singly linked list has records called nodes, each holding a value and the address of the next node. Knowing the first node does not reveal where the tenth is stored. You must follow the chain. Once a particular node is already known, inserting immediately after it can change a few links without shifting every later value. / THE FORMAL IDEA array address(i) = base + i×s - Addresses count bytes here; base = address of the first entry; i = zero-based entry number; s = bytes per entry; a byte is a unit of stored data, here eight choices each read as 0 or 1. - A linked list has no corresponding direct-address formula from i alone. Its next-node addresses supply the route one step at a time. / RUN THE TINY EXAMPLE Change one thing. Predict what happens. Toy array: base = 1000; s = 4 bytes. Entry 3 starts at 1000+3×4 = 1012. Toy linked list: node 0 → node 1 → node 2 → node 3 requires three link follows from the first node. Change only the requested entry to 7: array address = 1028. The linked-list route now needs seven link follows, even though the position calculation for the array stays short. The numbers are invented memory labels, not addresses to inspect. The changed position lengthened the linked route but did not require reading the array’s earlier entries. This is the structural reason for different access costs, independent of the playlist’s visual appearance. / SO WHAT? Insertion changes the comparison. Inserting a new first entry in a packed array may require moving the existing entries to make room. A linked list can create a new head node pointing at the old head. However, “insert quickly” assumes you already know the insertion point; finding a position can consume the very traversal time the slogan leaves out. / ONE CAVEAT Real dynamic arrays reserve extra capacity, and arrays can store addresses rather than the full objects. Memory layout and caching affect stopwatch time. This comparison concerns basic packed arrays and singly linked nodes, not every language’s object named “list”. / KEEP THIS Arrays calculate a position directly; linked lists reach a position through connections, trading easy jumps for flexible local rearrangement. / SOURCE TRAIL [1] GLib — Array and linked-list data structures https://docs.gtk.org/glib/data-structures.html NEXT: Why a falling object can stop speeding up --- HARD IDEAS. PLAIN TEXT. You are receiving this because you asked for one clear computer-science or physics idea each day. Unsubscribe: https://plaintext.click/unsubscribe View in browser: https://plaintext.click/newsletter/2027/01/2027-01-18-array-linked-list-access.html From: Plain/Text / Brickston Consulting · 30 N Gould St Ste N, Sheridan, WY 82801 US · knowledge@plaintext.click