Skip to content

Consider using records instead of plain values #478

Description

@wojtask

As mentioned on page 17 and in several other places in CLRS, the actual data type that arrays or other data structures store, is a record. A record consists of a key and other data, called satellite data. Keys are used to determine the positions of records in data structures and are often the only representation used in the book to illustrate algorithms and data structures. When not critical, satellite data is hidden for simplicity.

Consider using records whenever applicable in implementations. Make records comparable, so the algorithm should not explicitly compare records by exposing their key attributes.

As of now, certain implementations use KeyObject class as a record, while others use plain numbers (keys), e.g. Heap contains plain keys, while PriorityQueue contains KeyObjects. Consider renaming KeyObject -> Record and use records consistently.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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