It completely depends on the problem.
eg. as far as I can tell, summing up the list of numbers O (N).
sum([],0). sum(List,Total) :- sum(List,0,Total). sum([],Total,Total). sum([Head|Rest],Accumulator,Total) :- SoFar is Head + Accumulator, sum(Rest,SoFar,Total).
The only actions are adding ("is") and a recursive call, which should cost 1 each. They will be executed ~ once per element in the list, so the total actions should be ~ 2N, which is equal to O (N).
source share