Skip to content

Removing the last element from a LinkedList is unnecessarily slow #19

@tom-churchill

Description

@tom-churchill

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions