isalnum(char) is a method which tells us, whether a given character is alphanumeric or not. What is the time complexity of this small function?
I have written a small subroutine :
bool check(string s,int i)
{
if((s[i]>='a' && s[i]<='z') ||
(s[i]>='0' && s[i]<='9') ||
(s[i]>='A' && s[i]<='Z'))
{
return true;
}
return false;
}
Is the above subroutine works same as isalnum(char) method? Are there time complexities same?
These functions are different, because
isalnumtakesint. If you ask about the actions they perform, they are also different.Time complexities in the both cases are similar, O(1). Your function may be faster, since it does not use locales.