Logout

Home Topic 4 Last Next

4.3.2

Distinguish between fundamental and compound operations of a computer.

 

Teaching Note:

For example, “find the largest” is a compound operation.

 

Sample Question:

sdfsdfsf

JSR Notes:

So the 4.3.1 operations are fundamental (i.e. adding, subtracting, and comparing), and all others which combine them are "compound operations".

Look at Java for appreciating the example in the Teaching Note:

public int findTheLargest(int [ ] arr){
    int largest = arr[0];     //an obvious store, with the =
    for(int i = 0; i < arr.length; i++){     //an obvious add, with the ++
        if(arr[i] > largest){    //an obvious compare, with the >
            largest = arr[i];
        }
    }
    return largest;
}

 

At the highest level of compound operation, we have:

findTheLargest( ) method


At a second level down, the function is broken down into:

  • a method header, taking in a parameter
  • initializing a largest value (using the first element of the array)
  • looping through the array
  • and checking to see if any individual element is greater than the assumed largest,
  • and if so, making the value of the largest to be that larger value
  • returning the largest value


    But each of these, in turn is broken down into simpler operations

    For example, the fourth of six steps above, "and checking to see if any individual element is greater than the assumed largest" breaks down into:

      • if the arr element at index "i" > largest == true
      • assign largest = arr[i]


      • And even further, taking any one of those steps, for example "assign largeset = arr[i], they are broken down into absoutely fundamental steps:

        • variable largest STORE arr[i]

    etc. etc. etc. for each and every level, and sub-level, until you get right down to the fundamental operations

And the point is everything above boils down to the fundamental operations of add, compare, retrieve and store.

 

Another useful example we used in class was moving a window across the screen; each of millions of pixels will change color, which, ultimately is ADD of binary representations of colors. For example, a white pixel 0000 0000 0000 0000 0000 0000 being changed to a blue one, 0000 0000 0000 0000 1111 1111 via addition.