Memory allocation to function

Please tell whether following is stated correctly or not ?

Whenever we define one or more functions, no matter how big definition (code inside it) that function has unless we call it at least once our time and space complexity at time of execution is not affected right ? ( please ALSO answer with respect to competitive programming )

hi… so if u are declaring a function and using it only then ur time complexity would be affected… but if u are using it or not… space will be affected

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

@Vaibhav277
ohk…one more thing
if I use long long as datatype (instead of int) everywhere in my code like:-

int variable;
int arr[variable];
vector<int>
void function_name(int a[],int b)
for(int i=0; i<10 ; ++i)

… all such places I would be safe from TLE or TOO MUCH SPACE and OVERFLOWS right ?
(My concern is primarily towards online contests !)

Hi… long long doesn’t ensure that u won’t get TLE… it is just used to store larger range of number… like in int u can store only upto 10^9 but with long long range increases till 10^18…
and rest regarding TLE u get it when suppose ques can be solved in O(N) but ur codes complexity is O(N^N) or more then u get TLE

@Vaibhav277

.

TLE was a typo mistake …
Can you please reply the same (by ignoring TLE) ?

hi… so as i mentioned above long long is just used to store larger range of number… like in int u can store only upto 10^9 but with long long range increases till 10^18…

@Vaibhav277
from TOO MUCH SPACE I mean that if I’m using long long instead of int compiler might say that allowed storage limit is exceeded right !!

@Vaibhav277
yes I understood that but I am worried about following

from TOO MUCH SPACE -> I mean that if I’m using long long instead of int compiler might say that allowed storage limit is exceeded right !!

no it wont say… its just a data type and will store accordingly what u want to store… i haven’t come across any case till now where it gave this error or storage exceeded for just using long long instead of int…so don’t worry about the same…

1 Like

@Vaibhav277
thanks !