Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if sorting implementation is stable #177

Merged
merged 1 commit into from
Apr 1, 2024

Commits on Mar 30, 2024

  1. Check if sorting implementation is stable

    Introduced node numbering in qtest.c to evaluate the stability of
    q_sort's sorting algorithm. When the algorithm encounters two nodes
    with the same value, it searches for the address of the node record in
    the nodes array. It then compares the found node to the current node
    (cur). If the found node is the same as the current node, it indicates
    that these two duplicate nodes have not been swapped in position after
    sorting. However, if the found node is cur->next, it means that the
    position of the nodes has been swapped. That is, the sorting
    implementation is unstable.
    
    The performance of the testing code was evaluated by measuring the
    elapsed time for q_sort's operation on different numbers of nodes with
    duplicate values. Node counts ranging from 1000 to 500,000 were
    examined. Specifically, for the 1000-node count, the elapsed time
    was recorded as 0.0279 seconds, and for the 500,000-node count, it
    was 61.44 seconds. For the 100,000-node count, the elapsed time was
    2.45 seconds. The elapsed time showed a significant increase starting
    from the 100,000-node count, underscoring potential performance issues
    with larger datasets.
    
    This method relies on auxiliary data structures to track node pointers
    and their original order, avoiding alterations to the structure in
    queue.h. However, stability testing is limited to a maximum of 100,000
    elements (MAX_NODES) to address potential performance concerns.
    yenslife committed Mar 30, 2024
    Configuration menu
    Copy the full SHA
    b0aa080 View commit details
    Browse the repository at this point in the history