Exercises for Chapter #2 of A Common-Sense Guide To Data Structures and Algorithms

Get The Book!There’s an age old puzzle that goes as follows: You’re at a river with two buckets. One holds exactly 3 liters, and one holds exactly 5 liters. Figure out how to measure out exactly 4 liters using those two buckets.

- Develop two different algorithms for measuring out 4 liters.
- Which of your algorithms is more efficient? That is, how many steps does each algorithm take?

How many steps would it take to insert the number 7 into the ordered array of [2, 4, 6, 8, 10, 12]?

How many steps would it take to search for the number 8 in the ordered array: [2, 4, 6, 8, 10, 12]?

How many steps does it take to perform binary search on array of size 200?

How many steps does it take to perform binary search on array of size 400?

Use your favorite object-oriented programming language to create a class that represents an ordered array. It should include functions/methods that serve as the key operations: Read, search, insert, and delete. Ensure that the insert operation inserts the value in the correct place within the ordered array.