Update README.md

This commit is contained in:
marina 2023-08-02 17:48:09 -07:00 committed by GitHub
parent 31c7cc4654
commit 17ca5877bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,13 @@
* unlike an array, a list does not provide constant time access to an index (as it needs to interact through all k elements), however addition and removal of elements are constant time.
* to remove a node you set `prev.next` equal to `node.next`. if it's a double list, you also update `node.next` with `node.next.prev` to `node.prev` (and deallocate the memory).
<br>
### detecting cycles
<br>
* can be done with hash table or the two-pointer technique, where if there is no cycle, the faster pointer (going 2 steps) will stop at the end of the list, but if there is a cycle, the fast pointer will eventually meet the slow pointer (going 1 step). if there is no cycle, the faster pointer takes `N/2` to reach the end of the list (`N` being the length).
<br>