loading...

RAM model, Big O what's that?

abisekhsubedi profile image अभिषेक सुबेदी ・1 min read

Here a question I don't understand. Can anybody help with that?

Use RAM model to estimate the big-oh of the running time for the following code segment.


for(i = 1; i < n; i++){
   small_pos = i;
   smallest = Array[samll_pos];
   for(j = i + 1; J <= n; j++){
     if(Array[j] < smallest){
       small_pos = j;
       smallest = Array[small_pos]
     }
   }
}
Array[small_pos] = Array[i];
Array[i] = smallest;

Discussion

markdown guide
 

Reference

The RAM (Random-access machine) is a set of assumptions. It assumes some basic operations exist and that they all take constant time. So you can ignore these operations and make your big-o estimations using only operations which vary based on the size of the input array, like for loops.