Refactor benchmark to use randomized vectors instead of sets

- Replaced std::set with std::vector for sequence handling.
- Added randomization of sequences to avoid ordered input bias.
- Removed unused balance function and related code in bst.cpp and bst.h.
- Fixed bugs in list insertion and search logic.
- Updated plot.py to allow custom y-axis labels and enable log scale for build plots.
This commit is contained in:
2025-05-14 19:42:14 +02:00
parent aae0ce7241
commit 899c844c78
5 changed files with 36 additions and 59 deletions
+12 -16
View File
@@ -16,9 +16,10 @@ List *insert(List *head, int value) {
head = newHead;
} else {
List *tmp = head;
while (tmp->next != nullptr && tmp->data < value) {
tmp = tmp->next;
while (tmp->next != nullptr && tmp->next->data < value) {
tmp = tmp->next;
}
List *tail = new List();
tail->data = value;
// Set the pointer to the next, we don't know if its at the end or not
@@ -32,24 +33,19 @@ List *insert(List *head, int value) {
List *search(List *list, int value) {
List *ptr = list;
while (ptr != nullptr && ptr->data != value) {
ptr = ptr->next;
if (ptr->data > value) return nullptr;
ptr = ptr->next;
}
if (ptr->data == value) {
return ptr;
}
return nullptr;
return ptr;
}
// Remove the first element
List *remove(List *head) {
if (head == nullptr) {
return nullptr;
}
List *newHead = head->next;
delete head;
return newHead;
if (head == nullptr) {
return nullptr;
}
List *newHead = head->next;
delete head;
return newHead;
}