From 62da660403de4556f1ec0462e3847716a83293d0 Mon Sep 17 00:00:00 2001 From: Rene Argento Date: Tue, 21 May 2024 19:50:51 +0200 Subject: [PATCH] Updated exercise 1.5.4 --- src/chapter1/section5/Exercise4.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/chapter1/section5/Exercise4.txt b/src/chapter1/section5/Exercise4.txt index 92208aac..707dde25 100755 --- a/src/chapter1/section5/Exercise4.txt +++ b/src/chapter1/section5/Exercise4.txt @@ -34,7 +34,7 @@ sz[] 0 1 2 3 4 5 6 7 8 9 1 1 1 1 3 1 1 1 1 1 -Array accesses: 4 (2 for find(3), 1 for find(8) and 1 for updating parent) +Array accesses: 5 (3 for find(3), 1 for find(8) and 1 for updating parent) 6-5 @@ -82,7 +82,7 @@ sz[] 0 1 2 3 4 5 6 7 8 9 1 1 2 1 4 1 2 1 1 1 -Array accesses: 4 (2 for find(8) and 2 for find(9)) +Array accesses: 6 (3 for find(8) and 3 for find(9)) 5-0 @@ -94,7 +94,7 @@ sz[] 0 1 2 3 4 5 6 7 8 9 1 1 2 1 4 1 3 1 1 1 -Array accesses: 4 (1 for find(0), 2 for find(5) and 1 for updating parent) +Array accesses: 5 (3 for find(5), 1 for find(0) and 1 for updating parent) 7-2 @@ -118,7 +118,7 @@ sz[] 0 1 2 3 4 5 6 7 8 9 1 1 3 1 4 1 6 1 1 1 -Array accesses: 4 (1 for find(6), 2 for find(1) and 1 for updating parent) +Array accesses: 5 (1 for find(6), 3 for find(1) and 1 for updating parent) 1-0 @@ -130,7 +130,7 @@ sz[] 0 1 2 3 4 5 6 7 8 9 1 1 3 1 4 1 6 1 1 1 -Array accesses: 5 (3 for find(1) and 2 for find(0)) +Array accesses: 8 (5 for find(1) and 3 for find(0)) 6-7 @@ -142,7 +142,7 @@ sz[] 0 1 2 3 4 5 6 7 8 9 1 1 3 1 4 1 6 1 1 1 -Array accesses: 4 (1 for find(6) and 3 for find(7)) +Array accesses: 6 (1 for find(6) and 5 for find(7)) Worst-case input @@ -241,4 +241,6 @@ sz[] Array accesses: 3 (1 for find(0), 1 for find(4) and 1 for updating parent) Thanks to sergiovasquez122 (https://github.com/sergiovasquez122) for noticing that there were extra array fields in the worst case: -https://github.com/reneargento/algorithms-sedgewick-wayne/issues/168 \ No newline at end of file +https://github.com/reneargento/algorithms-sedgewick-wayne/issues/168 +Thanks to xzy2022 (https://github.com/xzy2022) for reporting an issue with the array access count in the find() method: +https://github.com/reneargento/algorithms-sedgewick-wayne/issues/307 \ No newline at end of file