Time complexity of variable assignation

I know that if I have a function like:

public int addOne(int a){
    return (a+1)

The time complexity order will be O(1) since we only do one operation (the sum).

But what if I have a function that doesn't do any operations, just assigns some values to some global variables. Like this:

public void assignValues(){
    a = 2;
    b = 3;
    c = 4;
    //maybe more

What would the time complexity be for this function? My guess is that it would still O(1). Is that correct?

Read more here: https://stackoverflow.com/questions/64388786/time-complexity-of-variable-assignation

Content Attribution

This content was originally published by ROBlackSnail at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: