You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removing the first element from a LinkedList is fast, however, removing the last element is slow.
The problem seems to be that in the removeElementAtIndex function rather than simply accessing the lastNode element, the nodeAtIndex is called, fetching the second to last element, which is done by iterating over the entire list.
Removing the last element from a LinkedList is very common, so it being crippled severely hampers the usability of the data structure.
Thanks
The text was updated successfully, but these errors were encountered:
Removing the first element from a LinkedList is fast, however, removing the last element is slow.
The problem seems to be that in the removeElementAtIndex function rather than simply accessing the lastNode element, the nodeAtIndex is called, fetching the second to last element, which is done by iterating over the entire list.
Removing the last element from a LinkedList is very common, so it being crippled severely hampers the usability of the data structure.
Thanks
The text was updated successfully, but these errors were encountered: