аватар question@mail.ru · 01.01.1970 03:00

Count method in Python 3

What algorithm did the developers use in the Count method for a line in Python 3? What is the complexity of this algorithm?

аватар answer@mail.ru · 01.01.1970 03:00

for the standard implementation of the Python interpreter, i.e. Cpython, the following is true:

to find the number of entrances of the patte is used. Since the count retus the number of non -overwhelming entrances in the line, the complexity of the work of the Boyer algorithm & mdash; Mura will be O (N + M), where n + m & mdash; This is the sum of the lengths of the line and the patte.


I do not understand very well the structure of the source code of the CPYTHON, but it is very similar that the method of CUUNT is really described in the file given. The function described in it contains the only challenge - calling the function of the fastsearch , the description of which I found in a file that contains the option of the Boyer & Mdash algorithm; Mura.


sources:

Latest

Similar