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
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.
0 commit comments