Hướng dẫn what is the time complexity of min () and max () method in python? - độ phức tạp về thời gian của phương thức min() và max() trong python là bao nhiêu?

Các chức năng O lớn của minmax trong Python là gì? Họ có phải là O(n) hay Python có cách tốt hơn để tìm thấy mức tối thiểu và tối đa của một mảng không? Nếu chúng là O(n), không nên sử dụng vòng lặp để tìm các giá trị mong muốn hay chúng hoạt động giống như một vòng lặp?

Hướng dẫn what is the time complexity of min () and max () method in python? - độ phức tạp về thời gian của phương thức min() và max() trong python là bao nhiêu?

hỏi ngày 13 tháng 2 năm 2016 lúc 23:25Feb 13, 2016 at 23:25

1

Đó là O(n). Đó là một thuật toán chung, bạn không thể tìm thấy tối đa/phút trong trường hợp chung mà không kiểm tra tất cả chúng. Python thậm chí không có loại bộ sưu tập được sắp xếp tích hợp sẽ giúp kiểm tra dễ dàng chuyên môn.

Một vòng lặp

Maximum of 4,12,43.3,19 and 100 is : 100
2 sẽ có cùng độ phức tạp của thuật toán, nhưng sẽ chạy chậm hơn trong trường hợp điển hình, vì ____ 7/________ 8 (trên CPYThon dù sao) đang chạy một vòng lặp tương đương ở lớp C, tránh trình thông dịch bytecode trên đầu, trong đó vòng lặp
Maximum of 4,12,43.3,19 and 100 is : 100
2.

Đã trả lời ngày 13 tháng 2 năm 2016 lúc 23:28Feb 13, 2016 at 23:28

Hướng dẫn what is the time complexity of min () and max () method in python? - độ phức tạp về thời gian của phương thức min() và max() trong python là bao nhiêu?

ShadowrangershadowrangerShadowRanger

Huy hiệu vàng 134K1212 gold badges173 silver badges251 bronze badges

6

Để tìm mức tối đa hoặc tối thiểu của một chuỗi, bạn phải nhìn vào từng phần tử một lần, do đó bạn không thể tốt hơn O (n).

Tất nhiên, Python minmax cũng có o (n) quá: Docs.

Bạn có thể viết chức năng tối đa/tối đa của riêng mình với một vòng lặp và nó sẽ có cùng độ phức tạp, nhưng sẽ chậm hơn vì nó không được tối ưu hóa trong C.

Đã trả lời ngày 13 tháng 2 năm 2016 lúc 23:29Feb 13, 2016 at 23:29

Hướng dẫn what is the time complexity of min () and max () method in python? - độ phức tạp về thời gian của phương thức min() và max() trong python là bao nhiêu?

Timgebtimgebtimgeb

75K20 Huy hiệu vàng117 Huy hiệu bạc143 Huy hiệu Đồng20 gold badges117 silver badges143 bronze badges

2

Cả hai đều là O (N) và không có cách nào để tìm Min Max trong một mảng. Trên thực tế, việc triển khai cơ bản của MIN/MAX là một vòng lặp.

Đã trả lời ngày 13 tháng 2 năm 2016 lúc 23:29Feb 13, 2016 at 23:29

TimgebtimgebSalvador Dali

75K20 Huy hiệu vàng117 Huy hiệu bạc143 Huy hiệu Đồng142 gold badges687 silver badges748 bronze badges

Cả hai đều là O (N) và không có cách nào để tìm Min Max trong một mảng. Trên thực tế, việc triển khai cơ bản của MIN/MAX là một vòng lặp.

Salvador Dalisalvador Dali

206K142 Huy hiệu vàng687 Huy hiệu bạc748 Huy hiệu Đồng

Như đã nêu trong trường hợp chung (về mặt lý thuyết) tìm thấy mức tối thiểu hoặc tối đa của một bộ sưu tập giá trị chưa được phân loại yêu cầu bạn phải xem xét từng giá trị (do đó

Maximum of 4,12,43.3,19 and 100 is : 100
8), bởi vì nếu bạn không nhìn vào giá trị, giá trị đó có thể lớn hơn Tất cả các giá trị khác của bộ sưu tập của bạn.

[..] Không phải là tốt hơn khi sử dụng vòng lặp để tìm các giá trị mong muốn hoặc chúng hoạt động giống như một vòng lặp?Feb 14, 2016 at 0:08

Không. Lập trình là về sự trừu tượng: ẩn các chi tiết về việc thực hiện (vòng lặp đó) đằng sau một cái tên lạ mắt. Nếu không, bạn có thể viết vòng lặp đó trong lắp ráp, phải không?Daniel Jour

Bây giờ đối với trường hợp "đặc biệt": Chúng tôi thường không làm việc với số lượng lớn tùy ý. Giả sử một số nguyên không dấu 2 bit: Các giá trị duy nhất có thể là 0, 1, 2 và 3. Ngay khi bạn tìm thấy 3 trong một số bộ sưu tập (tùy ý lớn), bạn có thể chắc chắn rằng sẽ không có giá trị lớn hơn. Trong một trường hợp như thế có thể có ý nghĩa khi có một kiểm tra đặc biệt để biết liệu người ta đã tìm thấy giá trị tối đa (tối thiểu) có thể.2 gold badges35 silver badges63 bronze badges

Đã trả lời ngày 14 tháng 2 năm 2016 lúc 0:08

Daniel Jourdaniel Jour

15.7K2 Huy hiệu vàng35 Huy hiệu bạc63 Huy hiệu Đồng

Đối với độ phức tạp về thời gian O (1) bạn có thể sử dụng điều này:Jan 18 at 11:09

Hướng dẫn what is the time complexity of min () and max () method in python? - độ phức tạp về thời gian của phương thức min() và max() trong python là bao nhiêu?

1

Bài viết này mang đến cho bạn một chức năng rất thú vị và ít được biết đến của Python, cụ thể là Max () và Min (). Bây giờ khi so sánh với đối tác C ++ của họ, chỉ cho phép hai đối số, quá nghiêm ngặt là nổi, int hoặc char, các chức năng này không chỉ giới hạn ở 2 yếu tố, mà còn có thể giữ nhiều yếu tố như đối số và cũng hỗ trợ các chuỗi trong các đối số của chúng, từ đó Cho phép hiển thị chuỗi nhỏ nhất hoặc lớn nhất về mặt từ vựng. Chức năng chi tiết được giải thích dưới đây. & NBSP;not only limited to 2 elements, but can hold many elements as arguments and also support strings in their arguments, hence allowing to display lexicographically smallest or largest string as well. Detailed functionality are explained below.
 

Hàm này được sử dụng để tính toán tối đa các giá trị được truyền trong đối số của nó và giá trị lớn nhất về mặt từ vựng nếu các chuỗi được truyền dưới dạng đối số. & NBSP;
 

Syntax : 
max(a,b,c,..,key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the maximum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.

Python3

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
1
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
2
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
3
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
4

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0max
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
8
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
9
Minimum of 4,12,43.3,19 and 100 is : 4
0 ____31____________
Minimum of 4,12,43.3,19 and 100 is : 4
3
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
5
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
8

Đầu ra: & nbsp; & nbsp;
 

Maximum of 4,12,43.3,19 and 100 is : 100

Hàm này được sử dụng để tính toán tối thiểu các giá trị được truyền trong đối số của nó và giá trị nhỏ nhất về mặt từ vựng nếu các chuỗi được truyền dưới dạng đối số. & NBSP;
 

Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.

Python3

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0
Minimum of 4,12,43.3,19 and GeeksforGeeks is : 
1
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
2
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
3
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
4

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0min
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
8
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
9
Minimum of 4,12,43.3,19 and 100 is : 4
0 ____31____________
Minimum of 4,12,43.3,19 and 100 is : 4
3
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
5
Minimum of 4,12,43.3,19 and 100 is : 4
030
Minimum of 4,12,43.3,19 and 100 is : 4
8

Đầu ra: & nbsp; & nbsp;
 

Minimum of 4,12,43.3,19 and 100 is : 4

Hàm này được sử dụng để tính toán tối thiểu các giá trị được truyền trong đối số của nó và giá trị nhỏ nhất về mặt từ vựng nếu các chuỗi được truyền dưới dạng đối số. & NBSP;

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0min
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
8
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
9
Minimum of 4,12,43.3,19 and 100 is : 4
0 ____31____________
Minimum of 4,12,43.3,19 and 100 is : 4
3
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
5
Minimum of 4,12,43.3,19 and 100 is : 4
030
Minimum of 4,12,43.3,19 and 100 is : 4
8
These functions throw TypeError when conflicting data types are compared.
 

Python3

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0
The word occurring 1st in dict. among given is : algorithm
The word occurring last in dict. among given is : programming
1
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
2
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
3
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
4

Ngoại lệ

Đầu ra: & nbsp; & nbsp;
 

Minimum of 4,12,43.3,19 and GeeksforGeeks is : 

Hàm này được sử dụng để tính toán tối thiểu các giá trị được truyền trong đối số của nó và giá trị nhỏ nhất về mặt từ vựng nếu các chuỗi được truyền dưới dạng đối số. & NBSP;
 

Traceback (most recent call last):
  File "/home/b5da1d7f834a267f94fbbefe1b31a83c.py", line 7, in 
    print (min( 4,12,43.3,19,"GeeksforGeeks" ) )
TypeError: unorderable types: str() < int()

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0min
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
8
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
9
Minimum of 4,12,43.3,19 and 100 is : 4
0 ____31____________
Minimum of 4,12,43.3,19 and 100 is : 4
3
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
5
Minimum of 4,12,43.3,19 and 100 is : 4
030
Minimum of 4,12,43.3,19 and 100 is : 4
8

Ngoại lệlexicographically largest and smallest of Strings i.e String appearing first in dictionary or last.
 

Python3

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0max1
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
2
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
3
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
4

1. Kiểu hàng hóa: Các chức năng này ném loại khi so sánh các loại dữ liệu xung đột. & NBSP;

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0O(n)9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
2
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
3
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
4

Maximum of 4,12,43.3,19 and 100 is : 100
9
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
0min
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
8
Syntax : 
min(a,b,c,.., key,default)
Parameters : 
a,b,c,.. :  similar type of data.
key : key function where the iterables are passed and comparison is performed
default : default value is passed if the given iterable is empty
Return Value : 
Returns the minimum of all the arguments.
Exceptions : 
Returns TypeError when conflicting types are compared.
9
Minimum of 4,12,43.3,19 and 100 is : 4
0 ____31____________
Minimum of 4,12,43.3,19 and 100 is : 4
3
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
5
Minimum of 4,12,43.3,19 and 100 is : 4
0
Minimum of 4,12,43.3,19 and 100 is : 4
8

Đầu ra: & nbsp; & nbsp;
 

The word occurring 1st in dict. among given is : algorithm
The word occurring last in dict. among given is : programming

Hàm này được sử dụng để tính toán tối thiểu các giá trị được truyền trong đối số của nó và giá trị nhỏ nhất về mặt từ vựng nếu các chuỗi được truyền dưới dạng đối số. & NBSP;Manjeet Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
 


Độ phức tạp thời gian của Max () trong Python là gì?

Đó là O (N), vì nó phải kiểm tra mọi yếu tố.Nếu bạn muốn hiệu suất tốt hơn cho Max, bạn có thể sử dụng mô -đun FEAPQ.Tuy nhiên, bạn phải phủ định từng giá trị, vì FEAPQ cung cấp một đống tối thiểu.Chèn một phần tử vào một đống là O (log n).O(n), since it must check every element. If you want better performance for max, you can use the heapq module. However, you have to negate each value, since heapq provides a min heap. Inserting an element into a heap is O(log n).

Độ phức tạp thời gian của thuật toán Minmax là gì?

Độ phức tạp về thời gian của minimax là O (b^m) và độ phức tạp không gian là O (BM), trong đó B là số lượng di chuyển pháp lý tại mỗi điểm và M là độ sâu tối đa của cây.O(b^m) and the space complexity is O(bm), where b is the number of legal moves at each point and m is the maximum depth of the tree.

Sự phức tạp về thời gian trong Python là gì?

Độ phức tạp thời gian thường được ước tính bằng cách đếm số lượng hoạt động cơ bản được thực hiện bởi thuật toán, giả sử rằng mỗi thao tác cơ bản cần một lượng thời gian cố định để thực hiện.Khi phân tích độ phức tạp về thời gian của thuật toán, chúng ta có thể tìm thấy ba trường hợp: trường hợp tốt nhất, trường hợp trung bình và trường hợp xấu nhất.commonly estimated by counting the number of elementary operations performed by the algorithm, supposing that each elementary operation takes a fixed amount of time to perform. When analyzing the time complexity of an algorithm we may find three cases: best-case, average-case and worst-case.