From ebc193a785bfc13bdccb775104688626ffaf735b Mon Sep 17 00:00:00 2001 From: kimzieun <10wldms14@gmail.com> Date: Wed, 19 Mar 2025 16:47:25 +0900 Subject: [PATCH 1/5] Update main.py --- main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 5a3e755..11d28c0 100644 --- a/main.py +++ b/main.py @@ -1,14 +1,14 @@ from priority_queue import PriorityQueue def main(): - pq = PriorityQueue() + pq = PriorityQueue() - pq.push("Task 1", 3) - pq.push("Task 2", 1) - pq.push("Task 3", 2) + pq.push("Task 1", 3) + pq.push("Task 2", 1) + pq.push("Task 3", 2) - print(pq.pop()) - print(pq.pop()) - print(pq.pop()) + print(pq.pop()) + print(pq.pop()) + print(pq.pop()) if __name__ == "__main__": - main() \ No newline at end of file + main() From 65066724b2619d8fd363da03614129b7bc8ce953 Mon Sep 17 00:00:00 2001 From: kimzieun <10wldms14@gmail.com> Date: Wed, 19 Mar 2025 16:49:16 +0900 Subject: [PATCH 2/5] Update main.py --- main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/main.py b/main.py index 11d28c0..940e33a 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,9 @@ from priority_queue import PriorityQueue def main(): pq = PriorityQueue() - pq.push("Task 1", 3) pq.push("Task 2", 1) pq.push("Task 3", 2) - print(pq.pop()) print(pq.pop()) print(pq.pop()) From 5f41552a4aa0a9bd5b7e21f1c4eacbb3d21be077 Mon Sep 17 00:00:00 2001 From: kimzieun <10wldms14@gmail.com> Date: Wed, 19 Mar 2025 16:51:11 +0900 Subject: [PATCH 3/5] Update priority_queue.py --- priority_queue.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priority_queue.py b/priority_queue.py index 6994ec7..9bc9135 100644 --- a/priority_queue.py +++ b/priority_queue.py @@ -10,11 +10,11 @@ def push(self, item, priority): def pop(self): if len(self.heap) > 1: self._swap(0, len(self.heap) - 1) - priority, item = self.heap.pop() + _, item = self.heap.pop() self._sift_down(0) return item elif len(self.heap) == 1: - priority, item = self.heap.pop() + _, item = self.heap.pop() return item else: return None From 62a8849640a690be55b5cf2c8605b80fa9867acc Mon Sep 17 00:00:00 2001 From: kimzieun <10wldms14@gmail.com> Date: Wed, 19 Mar 2025 16:55:46 +0900 Subject: [PATCH 4/5] Rename test.py to test_.py --- test.py => test_.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test.py => test_.py (100%) diff --git a/test.py b/test_.py similarity index 100% rename from test.py rename to test_.py From 865a8baa6deb320af41691d61313c85a7fd9cf05 Mon Sep 17 00:00:00 2001 From: kimzieun <10wldms14@gmail.com> Date: Wed, 19 Mar 2025 16:59:57 +0900 Subject: [PATCH 5/5] Update priority_queue.py --- priority_queue.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priority_queue.py b/priority_queue.py index 9bc9135..f54f6be 100644 --- a/priority_queue.py +++ b/priority_queue.py @@ -35,11 +35,11 @@ def _sift_down(self, index): smallest = index if left_child_index < len(self.heap) and \ - self.heap[left_child_index][0] > self.heap[smallest][0]: + self.heap[left_child_index][0] < self.heap[smallest][0]: smallest = left_child_index if right_child_index < len(self.heap) and \ - self.heap[right_child_index][0] > self.heap[smallest][0]: + self.heap[right_child_index][0] < self.heap[smallest][0]: smallest = right_child_index if smallest != index: