CSC365 Quiz 1

  1. Given Tree Node declarations with parent fields, write method Node predecessor(Node t) that returns the inorder predecessor of t; or null if none.
  2. Draw the red-black tree obtained by inserting 7, 4, 3, 6, 1, 2, 5, 8, 9.
  3. Write a method void printNumberOfDups(String[] strings)that accepts an array of Strings, and prints the number of duplicates strings in the array. Use a Collection that provides an efficient solution. For example printNumberOfDups({"i", "came", "i", "saw", "i", "left", "i", "came"}) should print 4 (3 extra "i" plus 1 extra "came");