anatomy of a bug anatomy of a bug
![anatomy of a bug anatomy of a bug](https://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-1.jpg)
anatomy of a bug
![anatomy of a bug anatomy of a bug](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-2.jpg)
anatomy of a bug
![anatomy of a bug anatomy of a bug](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-3.jpg)
anatomy of a bug
![Anatomy of a bug AVL Trees Anatomy of a bug AVL Trees](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-4.jpg)
Anatomy of a bug AVL Trees
![I wrote java code for the avl tree: the data structure, a test/demo program I wrote java code for the avl tree: the data structure, a test/demo program](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-5.jpg)
I wrote java code for the avl tree: the data structure, a test/demo program and managed to display it … I felt … smug
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-6.jpg)
![smug ug sm smug g smu It was written all over me smug ug sm smug g smu It was written all over me](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-7.jpg)
smug ug sm smug g smu It was written all over me
![… so smug that I just HAD to demo it to a friend/colleague … … so smug that I just HAD to demo it to a friend/colleague …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-8.jpg)
… so smug that I just HAD to demo it to a friend/colleague … Dr. Chris “unworthy” Unsworth
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-9.jpg)
![… and this is what happened … and this is what happened](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-10.jpg)
… and this is what happened
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-11.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-12.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-13.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-14.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-15.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-16.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-17.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-18.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-19.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-20.jpg)
![Calm down … think Calm down … think](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-21.jpg)
Calm down … think
![1. 2. 3. you have code for btree the only difference between btree and 1. 2. 3. you have code for btree the only difference between btree and](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-22.jpg)
1. 2. 3. you have code for btree the only difference between btree and avl tree is restoring balance disable “restore balance” to confirm that’s were bug lies
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-23.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-24.jpg)
![Phew! No duplicates & size is right. Okay, bug is in restore. Balance Phew! No duplicates & size is right. Okay, bug is in restore. Balance](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-25.jpg)
Phew! No duplicates & size is right. Okay, bug is in restore. Balance
![Track it down to one of the rotations Track it down to one of the rotations](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-26.jpg)
Track it down to one of the rotations
![Edit out double. Rotate Edit out double. Rotate](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-27.jpg)
Edit out double. Rotate
![Compile and test … Compile and test …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-28.jpg)
Compile and test …
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-29.jpg)
![YES! The bug’s in double. Rotate! YES! The bug’s in double. Rotate!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-30.jpg)
YES! The bug’s in double. Rotate!
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-31.jpg)
![smug ug sm smug g smu It was written all over me smug ug sm smug g smu It was written all over me](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-32.jpg)
smug ug sm smug g smu It was written all over me
![Let’s get more information out of double. Rotate and fix this baby! Let’s get more information out of double. Rotate and fix this baby!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-33.jpg)
Let’s get more information out of double. Rotate and fix this baby!
![1. Turn double. Rotate back on 2. Print out information on before & after 1. Turn double. Rotate back on 2. Print out information on before & after](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-34.jpg)
1. Turn double. Rotate back on 2. Print out information on before & after double. Rotate
![Turn double. Rotate back on Print out the rotation made Turn double. Rotate back on Print out the rotation made](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-35.jpg)
Turn double. Rotate back on Print out the rotation made
![Print out information on nodes k 1, k 2, k 3 before & after Print out information on nodes k 1, k 2, k 3 before & after](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-36.jpg)
Print out information on nodes k 1, k 2, k 3 before & after double. Rotate Before & after
![Compile & run … Compile & run …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-37.jpg)
Compile & run …
![arrrrrrrgh! arrrrrrrgh!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-38.jpg)
arrrrrrrgh!
![Too much information! Keep it simple! Get smallest data set possible to demonstrate bug! Too much information! Keep it simple! Get smallest data set possible to demonstrate bug!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-39.jpg)
Too much information! Keep it simple! Get smallest data set possible to demonstrate bug!
![ll pp mm RLRotate ll pp mm RLRotate](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-40.jpg)
ll pp mm RLRotate
![Heck! It looks okay. What’s up? Heck! It looks okay. What’s up?](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-41.jpg)
Heck! It looks okay. What’s up?
![Maybe you should show the whole tree dude. Maybe you should show the whole tree dude.](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-42.jpg)
Maybe you should show the whole tree dude.
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-43.jpg)
![It’s back! It’s back It’s back! It’s back](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-44.jpg)
It’s back! It’s back
![Is it just a “right thing”? Is it just a “right thing”?](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-45.jpg)
Is it just a “right thing”?
![Arrrrrrgh! It happens on the left too! Arrrrrrgh! It happens on the left too!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-46.jpg)
Arrrrrrgh! It happens on the left too!
![Ma ke it go aw ay! !! Ma ke it go aw ay! !!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-47.jpg)
Ma ke it go aw ay! !!
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-48.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-49.jpg)
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-50.jpg)
![A brief intermission is now called for as our hero calms down Hero re-writes A brief intermission is now called for as our hero calms down Hero re-writes](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-51.jpg)
A brief intermission is now called for as our hero calms down Hero re-writes code for rotate … Hero wonders if there is something to do with call by reference, call by value … Hero wonders if there is something flawed in java Our hero clutches at straws … Hero even reads the book again!!!
![Hero has lunch at 12. 30 Hero has lunch at 12. 30](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-52.jpg)
Hero has lunch at 12. 30
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-53.jpg)
![Hero returns from lunch and tries again … Hero returns from lunch and tries again …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-54.jpg)
Hero returns from lunch and tries again …
![Holy smoke! Size is 4! I only entered 3 strings!! How the heck can Holy smoke! Size is 4! I only entered 3 strings!! How the heck can](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-55.jpg)
Holy smoke! Size is 4! I only entered 3 strings!! How the heck can that be? Where is size updated?
![t twa tw at tw a t twat t twa It was written all t twa tw at tw a t twat t twa It was written all](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-56.jpg)
t twa tw at tw a t twat t twa It was written all over him …
![It does this loop an extra time! It does this loop an extra time!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-57.jpg)
It does this loop an extra time!
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-58.jpg)
![Compile and run … Compile and run …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-59.jpg)
Compile and run …
![YES! YES!](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-60.jpg)
YES!
![Now do it on the left … Now do it on the left …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-61.jpg)
Now do it on the left …
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-62.jpg)
![Get rid of comments etc and try on large data set … Get rid of comments etc and try on large data set …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-63.jpg)
Get rid of comments etc and try on large data set …
![Edit out prints … Edit out prints …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-64.jpg)
Edit out prints …
![Go for it fat boy … Go for it fat boy …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-65.jpg)
Go for it fat boy …
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-66.jpg)
![at smug tw u sm t a smug tw at w gt at smug tw u sm t a smug tw at w gt](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-67.jpg)
at smug tw u sm t a smug tw at w gt
![What lessons have we learned? What lessons have we learned?](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-68.jpg)
What lessons have we learned?
![Lessons we can learn 1. 2. 3. 4. 5. if your program works … Lessons we can learn 1. 2. 3. 4. 5. if your program works …](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-69.jpg)
Lessons we can learn 1. 2. 3. 4. 5. if your program works … you have a subtle bug (worry) if data structure is complicated write code to test it (I didn’t) produce minimal test cases produce BIG test cases imagine if I didn’t have the btree code … would that be dangerous? What would your data structure testing program do? • check that we have a tree • no loops • check we have no orphans (nodes without parents) • no duplicates • height is okay • size is okay • avl balance is present • check EVERYTHING you can think of!!
![This took 1 day of my life This took 1 day of my life](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-70.jpg)
This took 1 day of my life
![](http://slidetodoc.com/presentation_image_h2/47b5c73909b158cc1c79c2ee16c4532b/image-71.jpg)
- Slides: 71