COMP 1020 Study Guide - Midterm Guide: Double-Precision Floating-Point Format, Sorting Algorithm, Data Element
lavenderbeaver188 and 10 others unlocked
12
COMP 1020 Full Course Notes
Verified Note
12 documents
Document Summary
Cs1020 - data structures and algorithms i - spring 2015. Section a (6 multiple choice questions: 18 marks) System. out. println(b2. getnum1() + ", " + b2. getnum2()); (a) 4, 9. Cs1020: study the following 3 code fragments. The api of arraylist class is given in appendix b. (i) Arraylist> outer = new arraylist>(); int count = 0; for (int i=0; i<2; i++) { Arraylist inner = new arraylist(); for (int j=0; j<3; j++) { count++; inner. add(count); outer. add(inner); Arraylist inner = new arraylist(); int count = 0; for (int i=0; i<2; i++) { for (int j=0; j<3; j++) { count++; inner. add(count); outer. add(inner); Arraylist inner = new arraylist(); int count = 0; for (int i=0; i<2; i++) { inner. clear(); for (int j=0; j<3; j++) { count++; inner. add(count); outer. add(inner); // maxval() returns the maximum element value in the part of the. // array from a[startindex] to a[endindex], inclusive. public static int maxval(int[] a, int startindex, int endindex) {