Algorithms by Robert Sedwick, It was mentioned that linked list can be represented using Arrays, at following link
http://flylib.com/books/en/3.55.1.34/1/
Fig 3.8, here if 5 is removed from my understanding next 4 should be changed to index 6 as val 5 is removed, as we go thourgh the figure at item 4 is removed next of val 3 is chaned. I am not following the logic of the figure. can aany one please help me.
Thanks!
the index is zero-based as opposed to the value itself (letters would be better values).
Example of removing the value
5: before removing, next index of the node with value4is 4, which points to value5; after removing, next index is changed to 5, pointing to value6(next changed from 4 to 5).Or, using the prefix
vto indicate values:before
after
as you can see the node
v4is followed byv6(index 5) practically removingv5from the chain.