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 q_sort's stability.
When encountering two nodes with the same value, the algorithm 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.
This method avoids altering the structure and instead relies on
auxiliary data structures to track node pointersand their original
order. However, stability testing is limited to a maximum number of
elements, currently set as MAX_NODES, to mitigate potential performance
issues. Note: If the dataset is too large, it may lead to excessively
long test times, hence the use of MAX_NODES.
Testing with the following script to measure the elapsed time for
inserting different numbers of nodes:
new
ih a 10000
sort
quit
| node count | elapsed time (seconds) |
| ---------- | ---------------------- |
| 1000 | 0.027906238 |
| 10000 | 0.058188249 |
| 100000 | 2.445569385 |
| 150000 | 5.453358783 |
| 200000 | 9.671944194 |
| 300000 | 21.581793918 |
| 400000 | 40.176436261 |
| 500000 | 61.437037665 |
The test results reveal a noticeable increase in elapsed time as the
number of nodes inserted grows. Specifically, exceeding 100,000 nodes
results in significant performance degradation.
0 commit comments