1 King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Information and Computer Science Department ICS 202-02: Data Structures Spring 2008-2009 Quiz#1, Wednesday March 11th 2009 Name: ID#: 1. (10 points) Suppose we have a container which contains only instances of the Integer class. Design a Visitor class, MaxVisitor, that will find the maximum value of all instances of the container after completing the execution of the accept method that takes an instance of MaxVisitor as its argument. 2 2. (10 points) For the following piece of code: a) (7 points) Find the number of times statement1 gets executed. b) (3 points) Express the running time of this piece of code in terms of big O() notation. n ; i++) { 1 for (i=1; i <= 2 sum[i] = 0; 3 for (j=1; j <= i2 ; j++) 4 sum[i] = sum[i] + j; //statement1 5 } 6 return true n c c 1 c . n m 1 i i m m n n i i 1 n i 2 i 1 n n 1 2 n n 1 2n 1 6 n n 1 i 2 i 1 n 2 3 a n 1 1 a ,a 1 a 1 i 0 n i