COMS W1004 Lecture Notes - Lecture 11: Functional Decomposition

38 views2 pages

Document Summary

You can keep multiple objects in an array. Arrays start at index 0, but length starts at 1. If a = b then both a and b point towards to same location in memory. Functional decomposition = look at a repeated calculation for a problem. Some play on min and max int [] a = new int[10]; //a is a reference to the first element in a memory space with length 10 int[] b = { 1, 2, 3, 4, 5}; //list of values. System. out. println( b[0]); //will print 1 for(int i = 0; i < a. length; i++) a[i] = i * 10; //or can use enhanced for loop for(int value : a) Java page 1 return maxsofarloc; public static int linearsearch(int[] array, int x) int loc = -1; for(int i = 0; i < array. length; i++) if(array[i] == x) loc = i; break; return loc;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents