I Want to know what is the algorithmic complexity of following
1. Java String tokenizer
2. C++ STL based tokenizer
3. strtok.
Is there any faster algorithm then rudimentary strtok to tokenize a string based on custom delimeter.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Regarding Java, there are 3 main techniques for tokenizing (String.split(), StringTokenizer and StreamTokenizer). if you refer to the java.util.StringTokenizer class (which tokenizes by breaking the input string S on every occurrence of a character from a given string D), then the complexity is O(|S|*|D|). I.e., if you have only one delimiter char, this will be linear.
Note that the other tokenizers are more powerful in their abilities. String.split() for example can split around any pattern matching a given regex.