Thuật toán nào được sử dụng trong python?

Timsort là một thuật toán sắp xếp lai, bắt nguồn từ sắp xếp hợp nhất và sắp xếp chèn, được thiết kế để hoạt động tốt trên nhiều loại dữ liệu trong thế giới thực. Nó được phát minh bởi Tim Peters vào năm 2002 để sử dụng trong ngôn ngữ lập trình Python. Thuật toán tìm các tập hợp con của dữ liệu đã được sắp xếp và sử dụng các tập hợp con đó để sắp xếp dữ liệu hiệu quả hơn. Điều này được thực hiện bằng cách hợp nhất một tập hợp con đã xác định, được gọi là một lần chạy, với các lần chạy hiện có cho đến khi đáp ứng một số tiêu chí nhất định. Timsort là thuật toán sắp xếp tiêu chuẩn của Python kể từ phiên bản 2. 3. Nó hiện cũng được sử dụng để sắp xếp các mảng trong Java SE 7 và trên nền tảng Android

Hướng dẫn này là hướng dẫn thân thiện với người mới bắt đầu để học cấu trúc dữ liệu và thuật toán bằng Python. Trong bài viết này, chúng ta sẽ thảo luận về các cấu trúc dữ liệu có sẵn như danh sách, bộ dữ liệu, từ điển, v.v. và một số cấu trúc dữ liệu do người dùng xác định như danh sách được liên kết, cây, biểu đồ, v.v., duyệt cũng như các thuật toán tìm kiếm và sắp xếp

danh sách

Danh sách Python là tập hợp dữ liệu được sắp xếp giống như mảng trong các ngôn ngữ lập trình khác. Nó cho phép các loại phần tử khác nhau trong danh sách. Việc triển khai Danh sách Python tương tự như Vectors trong C++ hoặc ArrayList trong JAVA. Thao tác tốn kém là chèn hoặc xóa phần tử từ đầu Danh sách vì tất cả các phần tử đều cần được dịch chuyển. Chèn và xóa ở cuối danh sách cũng có thể trở nên tốn kém trong trường hợp bộ nhớ được cấp phát trước trở nên đầy

Thí dụ. Tạo danh sách Python

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0_______21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____23
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
7
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7

Các phần tử danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong python chỉ mục bắt đầu của danh sách, một chuỗi là 0 và chỉ mục kết thúc là [nếu có N phần tử] N-1

Thí dụ. Thao tác danh sách Python

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
25

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
26

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0_______230
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____232
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
30
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
38
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
75

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
76

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
77
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
79____430
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
32
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
33
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
30
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
35

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____438
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______121____541

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
43

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
44

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____547
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
612

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
613

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6616
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
619

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0____6624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1____6604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
628

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6

Tuple

Các bộ dữ liệu trong Python tương tự như các danh sách nhưng về bản chất, các bộ dữ liệu là bất biến i. e. một khi được tạo ra nó không thể được sửa đổi. Giống như Danh sách, Tuple cũng có thể chứa các phần tử thuộc nhiều loại khác nhau

Trong Python, các bộ dữ liệu được tạo bằng cách đặt một chuỗi các giá trị được phân tách bằng 'dấu phẩy' có hoặc không sử dụng dấu ngoặc đơn để nhóm chuỗi dữ liệu.  

Ghi chú. Để tạo một bộ của một phần tử, phải có dấu phẩy ở cuối. Ví dụ: [8,] sẽ tạo một bộ chứa 8 là phần tử

Thí dụ. Thao tác tuple trong Python

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
636

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
637

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
638
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____430
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
32
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6647
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
638
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
636

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
655

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
656
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2______6663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
667
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6671
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

________ 6638 ________ 09 ________ 6675 ________ 6676

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
678

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6681
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6638
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
690

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
613

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6694
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____6638
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7006
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
638
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70

Bộ

Bộ Python là một tập hợp dữ liệu có thể thay đổi không cho phép bất kỳ sự trùng lặp nào. Các bộ về cơ bản được sử dụng để bao gồm kiểm tra tư cách thành viên và loại bỏ các mục nhập trùng lặp. Cấu trúc dữ liệu được sử dụng trong phần này là Băm, một kỹ thuật phổ biến để thực hiện thao tác chèn, xóa và truyền tải trung bình trong O[1].  

Nếu Nhiều giá trị xuất hiện ở cùng một vị trí chỉ mục, thì giá trị đó sẽ được thêm vào vị trí chỉ mục đó để tạo thành Danh sách được liên kết. Trong, Bộ CPython được triển khai bằng cách sử dụng từ điển với các biến giả, trong đó các sinh vật chính mà các thành viên đặt với mức độ tối ưu hóa cao hơn đối với độ phức tạp của thời gian

Đặt triển khai

Đặt với nhiều hoạt động trên một HashTable duy nhất

Thí dụ. Thao tác cài đặt Python

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7015

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7016

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7017

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7020
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7021
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
30
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
32
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
667
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
30
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7045

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7046

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7049
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052____17053
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____17058
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7060
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____17063

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7065

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7066

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
30
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True

Bộ đông lạnh

Các tập hợp cố định trong Python là các đối tượng bất biến, chỉ hỗ trợ các phương thức và toán tử tạo ra kết quả mà không ảnh hưởng đến tập hợp cố định hoặc các tập hợp mà chúng được áp dụng. Mặc dù các phần tử của tập hợp có thể được sửa đổi bất kỳ lúc nào, nhưng các phần tử của tập hợp cố định vẫn giữ nguyên sau khi tạo

Thí dụ. Bộ đông lạnh Python

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7073

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7074
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7020
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7021
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7078
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7080
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7082
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7087
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____17090

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7092

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7093
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7095
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7021
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7097
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7099
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
01
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______121____122____006

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
09

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
11

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
12

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
13

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]

Sợi dây

Chuỗi Python là mảng byte bất biến đại diện cho các ký tự Unicode. Python không có kiểu dữ liệu ký tự, một ký tự đơn giản chỉ là một chuỗi có độ dài là 1

Ghi chú. Vì các chuỗi là bất biến, nên việc sửa đổi một chuỗi sẽ dẫn đến việc tạo một bản sao mới

Thí dụ. Hoạt động chuỗi Python

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
14
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
16

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
19
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______121____122____027

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______121____030____6603

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
34

_______121____122____037

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
30____6624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
2

Từ điển

Từ điển Python là một tập hợp dữ liệu không có thứ tự lưu trữ dữ liệu ở định dạng khóa. cặp giá trị. Nó giống như các bảng băm trong bất kỳ ngôn ngữ nào khác với độ phức tạp về thời gian là O[1]. Lập chỉ mục của Từ điển Python được thực hiện với sự trợ giúp của các phím. Đây là bất kỳ loại băm nào tôi. e. một đối tượng không bao giờ có thể thay đổi như chuỗi, số, bộ dữ liệu, v.v. Chúng ta có thể tạo từ điển bằng cách sử dụng dấu ngoặc nhọn [{}] hoặc cách hiểu từ điển

Thí dụ. Thao tác từ điển Python

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
44

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
45
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
47
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
48
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
30
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
53
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
61

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
64
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____045
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
71

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
74
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____045____20
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
48
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
83

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
84

_______121____122____087

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______121____122____045____092

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
94

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
96

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
97_______09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
99
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
00
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
00
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
04
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
61

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
18

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3

ma trận

Ma trận là một mảng 2D trong đó mỗi phần tử có cùng kích thước. Để tạo ma trận, chúng tôi sẽ sử dụng gói NumPy

Thí dụ. Hoạt động ma trận Python NumPy

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
19
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
24
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
32
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
35
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
40

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
41
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
43
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
47
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
49
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
32
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
51
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
55
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
57
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
58

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
59
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
61____6663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
94

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
67

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
69

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
72
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
75
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

_______121____275____23____281____6603

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
604

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
85

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
59
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
88
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
91
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
93
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
51
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
96
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
201
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
67

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
206

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
59
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
209____21____240
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
216
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
67

đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
7

dòng nước mắt

Python Bytearray cung cấp một chuỗi số nguyên có thể thay đổi trong phạm vi 0 >> Thêm

Cây rơm

Ngăn xếp là cấu trúc dữ liệu tuyến tính lưu trữ các mục theo cách Nhập sau/Xuất trước [LIFO] hoặc Nhập trước/Xuất cuối [FILO]. Trong ngăn xếp, một phần tử mới được thêm vào ở một đầu và chỉ một phần tử bị xóa ở đầu đó. Thao tác chèn và xóa thường được gọi là đẩy và bật

Các chức năng liên quan đến ngăn xếp là

  • trống [] – Trả về xem ngăn xếp có trống không – Độ phức tạp về thời gian. Ô[1]
  • size[] – Trả về kích thước của ngăn xếp – Độ phức tạp về thời gian. Ô[1]
  • top[] – Trả về tham chiếu đến phần tử trên cùng của ngăn xếp – Độ phức tạp về thời gian. Ô[1]
  • push[a] – Chèn phần tử ‘a’ vào đầu ngăn xếp – Độ phức tạp về thời gian. Ô[1]
  • pop[] – Xóa phần tử trên cùng của ngăn xếp – Độ phức tạp về thời gian. Ô[1]

Python3




________ 4397 ________ 09 ________ 4399

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
401

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
402

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
403
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
404
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
403
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
407
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
403
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
404
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____5415
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5418

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
420

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
421

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
422

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____5425
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5428

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5428

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5428

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____5436
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5418

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
441

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
442

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
443

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
60

Các bài viết khác về Stack

  • Chuyển đổi tiền tố sang hậu tố bằng cách sử dụng ngăn xếp
  • Chuyển đổi tiền tố thành tiền tố
  • Chuyển đổi tiền tố sang hậu tố
  • Chuyển đổi tiền tố sang tiền tố
  • Postfix thành Infix
  • Kiểm tra các dấu ngoặc cân bằng trong một biểu thức
  • Đánh giá biểu thức Postfix

>>> Thêm

Xếp hàng

Là một ngăn xếp, hàng đợi là một cấu trúc dữ liệu tuyến tính lưu trữ các mục theo cách Nhập trước Xuất trước [FIFO]. Với một hàng đợi, mục được thêm gần đây nhất sẽ bị xóa trước. Một ví dụ điển hình về hàng đợi là bất kỳ hàng đợi nào của người tiêu dùng cho một tài nguyên mà người tiêu dùng đến trước được phục vụ trước

Các hoạt động liên quan đến hàng đợi là

  • xếp hàng. Thêm một mục vào hàng đợi. Nếu hàng đợi đầy, thì nó được gọi là điều kiện Tràn – Độ phức tạp về thời gian. Ô[1]
  • xếp hàng. Xóa một mục khỏi hàng đợi. Các mục được bật theo cùng thứ tự mà chúng được đẩy. Nếu hàng đợi trống, thì nó được cho là điều kiện Underflow – Độ phức tạp về thời gian. Ô[1]
  • Đổi diện. Lấy mục phía trước từ hàng đợi – Độ phức tạp về thời gian. Ô[1]
  • Ở phía sau. Lấy mục cuối cùng từ hàng đợi – Độ phức tạp về thời gian. Ô[1]

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
444

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
445
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
399

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
449

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
450
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
404
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
450
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
407
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
450
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
404
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____5462
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5465

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
467

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____5470
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______121____5473____6603

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
94

_______121____5473____6603

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
94

_______121____5473____6603

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
94

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____5487
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____5465

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
492

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
493

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
494

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
61

Các bài viết khác về Hàng đợi

  • Triển khai hàng đợi bằng cách sử dụng ngăn xếp
  • Triển khai ngăn xếp bằng cách sử dụng hàng đợi
  • Triển khai ngăn xếp bằng cách sử dụng hàng đợi đơn

Hàng đợi ưu tiên

Hàng đợi ưu tiên là cấu trúc dữ liệu trừu tượng trong đó mỗi dữ liệu/giá trị trong hàng đợi có mức độ ưu tiên nhất định. Ví dụ: Trong các hãng hàng không, hành lý có tiêu đề “Thương gia” hoặc “Hạng nhất” đến sớm hơn các hành lý còn lại. Hàng đợi ưu tiên là phần mở rộng của hàng đợi với các thuộc tính sau

  • Phần tử có mức ưu tiên cao được xếp trước phần tử có mức ưu tiên thấp
  • Nếu hai phần tử có cùng mức độ ưu tiên, chúng sẽ được phục vụ theo thứ tự của chúng trong hàng đợi

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
495

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
496

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
271
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
498____5499
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66008
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
399

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6014
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6019
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6020
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6021
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6022
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6027

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6030

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6033
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6041
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6047

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6050
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
280

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____1279____66055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6058

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6061
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

_______1281____66065____17055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6068
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6080

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6084
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6086
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6068
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6088

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6089
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6068
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6094
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6086
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6068
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6101
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6086
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6068
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6094

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66110
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6111

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____17063

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6116

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362 ________ 2363____09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9 ________ 2366 ________ 17055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6125
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6127

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6129
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
224
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6129
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6129
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6138
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6129
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6142
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______17056____121____66146

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6149
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6150

_______1281____121____66153

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
62

đống

mô-đun heapq trong Python cung cấp cấu trúc dữ liệu heap chủ yếu được sử dụng để biểu thị hàng đợi ưu tiên. Thuộc tính của cấu trúc dữ liệu này là nó luôn đưa ra phần tử nhỏ nhất [heap tối thiểu] bất cứ khi nào phần tử được bật lên. Bất cứ khi nào các phần tử được đẩy hoặc bật, cấu trúc heap được duy trì. Phần tử heap[0] cũng trả về phần tử nhỏ nhất mỗi lần. Nó hỗ trợ trích xuất và chèn phần tử nhỏ nhất trong O[log n] lần

Nói chung, Heaps có thể có hai loại

  • Heap tối đa. Trong Max-Heap, khóa có ở nút gốc phải lớn nhất trong số các khóa có ở tất cả các nút con của nó. Cùng một thuộc tính phải đúng một cách đệ quy cho tất cả các cây con trong Cây nhị phân đó
  • Min-Heap. Trong Min-Heap, khóa có ở nút gốc phải nhỏ nhất trong số các khóa có ở tất cả các nút con của nó. Cùng một thuộc tính phải đúng một cách đệ quy cho tất cả các cây con trong Cây nhị phân đó

 

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6154

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
19
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6156

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6158

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6159
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0_______6665
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66142
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6166
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6173

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6174

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6176

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6179
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6180
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6182

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____66185______66186

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6188

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6189

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6190
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6194

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____66197
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6180
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6182

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____66185______66186

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6206

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6209
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6180
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6182

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6214

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
63

Các bài viết khác về đống

  • đống nhị phân
  • Phần tử lớn thứ K trong mảng
  • Phần tử nhỏ nhất/lớn nhất thứ K trong mảng chưa sắp xếp
  • Sắp xếp một mảng gần như sắp xếp
  • Phân đoạn con liền kề có tổng lớn nhất thứ K
  • Tổng tối thiểu của hai số được tạo thành từ các chữ số của một mảng

>>> Thêm

Cây nhị phân

Cây là cấu trúc dữ liệu có thứ bậc giống như hình bên dưới –

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
64

Nút trên cùng của cây được gọi là gốc trong khi các nút ở dưới cùng hoặc các nút không có nút con được gọi là nút lá. Các nút trực tiếp bên dưới một nút được gọi là con của nó và các nút ngay phía trên một cái gì đó được gọi là cha mẹ của nó

Cây nhị phân là cây mà các phần tử của nó có thể có gần hai con. Vì mỗi phần tử trong cây nhị phân chỉ có thể có 2 con nên chúng ta thường đặt tên cho chúng là con trái và con phải. Nút Cây nhị phân chứa các phần sau

  • Dữ liệu
  • Con trỏ tới con trái
  • Con trỏ đến con bên phải

Thí dụ. Định nghĩa lớp nút

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6215

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6216

________ 1271 ________ 1272

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6223

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6226
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66231
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6236
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238

Bây giờ hãy tạo một cây có 4 nút trong Python. Giả sử cấu trúc cây trông giống như bên dưới -

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
65

Thí dụ. Thêm dữ liệu vào cây

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6239

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6241

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6242

________ 1271 ________ 1272

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6223

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6226
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66231
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6236
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6267

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6273

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____66277

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6279

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6285

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6286
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6285

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66277

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66298

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6300

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6301

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6304
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6285

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6313

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6315

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6317

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6318

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6277

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6279

cây ngang

Cây có thể được đi qua theo những cách khác nhau. Sau đây là những cách thường được sử dụng để duyệt cây. Chúng ta hãy xem xét cái cây dưới đây –

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
66

Chiều sâu đầu tiên

  • Thứ tự [Trái, Gốc, Phải]. 4 2 5 1 3
  • Đặt hàng trước [Gốc, Trái, Phải]. 1 2 4 5 3
  • Thứ tự sau [Trái, Phải, Gốc]. 4 5 2 3 1

Thứ tự thuật toán[cây]

  • Đi qua cây con bên trái, i. e. , gọi Inorder[left-subtree]
  • Thăm gốc
  • Đi qua cây con bên phải, i. e. , gọi Inorder[right-subtree]

Đặt trước thuật toán[cây]

  • Thăm gốc
  • Đi qua cây con bên trái, i. e. , gọi Preorder[left-subtree]
  • Đi qua cây con bên phải, i. e. , gọi Preorder[right-subtree]

Thuật toán Postorder[tree]

  • Đi qua cây con bên trái, i. e. , gọi Postorder[left-subtree]
  • Đi qua cây con bên phải, i. e. , gọi Postorder[right-subtree]
  • Thăm gốc

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6321

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6241

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6242

________ 1271 ________ 1272

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6331

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6226
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66231
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6236
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6349

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6351

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6355

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66358

_______1281____66360

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66363

_______1281____121____66366

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66369

_______1281____66371

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6374

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6376

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6355

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66358

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66385

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66388

_______1281____66390

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66393

_______1281____121____66366

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6399

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6401

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6355

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66408

_______1281____121____66366

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66414

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66416

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66419

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66421

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6424

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6430
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6435
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6304
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6445
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____66452
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6454

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____66458
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6460

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6464
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6466

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
67

Độ phức tạp của thời gian –  O[n]

Giao dịch theo thứ tự theo chiều rộng hoặc cấp độ

Duyệt theo thứ tự cấp độ của cây là duyệt theo chiều rộng đầu tiên của cây. Thứ tự duyệt của cây trên là 1 2 3 4 5

Đối với mỗi nút, đầu tiên, nút được thăm và sau đó các nút con của nó được đưa vào hàng đợi FIFO. Dưới đây là thuật toán cho cùng -

  • Tạo một hàng đợi trống q
  • temp_node = root /*bắt đầu từ root*/
  • Lặp lại trong khi temp_node không phải là NULL
    • in temp_node->dữ liệu
    • Enqueue con của temp_node [đầu tiên bên trái rồi đến con bên phải] đến q
    • Dequeue một nút từ q

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6467

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6468

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6470

________ 1271 ________ 1272

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6475

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6223

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
283
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6226
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66231
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6497

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6498

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6500

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6503

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6507
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6514

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6516

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
445
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
399

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6523

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____66525

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____66038
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6531
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66536

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66538

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6541____6603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6543

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6545
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6547
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____66552

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6555
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6507
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

_______4338____66561

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66564

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6567
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6507
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

_______4338____66573

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6575

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6430
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6435
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6304
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6445
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

________ 121 ________ 122 ________ 66604 ________ 124

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6606

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
68

Thời gian phức tạp. Trên]

Các bài viết khác về cây nhị phân

  • Chèn vào cây nhị phân
  • Xóa trong cây nhị phân
  • Inorder Tree Traversal mà không cần đệ quy
  • Inorder Tree Traversal không đệ quy và không ngăn xếp
  • In giao dịch sau khi đặt hàng từ các giao dịch đặt hàng trước và đặt hàng đã cho
  • Tìm chuyển đổi BST sau khi đặt hàng từ chuyển đổi đặt hàng trước

>>> Thêm

Cây tìm kiếm nhị phân

Cây tìm kiếm nhị phân là cấu trúc dữ liệu cây nhị phân dựa trên nút có các thuộc tính sau

  • Cây con bên trái của nút chỉ chứa các nút có khóa nhỏ hơn khóa của nút
  • Cây con bên phải của nút chỉ chứa các nút có khóa lớn hơn khóa của nút
  • Mỗi cây con bên trái và bên phải cũng phải là cây tìm kiếm nhị phân

Các thuộc tính trên của Cây tìm kiếm nhị phân cung cấp thứ tự giữa các khóa để các hoạt động như tìm kiếm, tối thiểu và tối đa có thể được thực hiện nhanh chóng. Nếu không có thứ tự, thì chúng ta có thể phải so sánh mọi khóa để tìm kiếm một khóa đã cho

Phần tử tìm kiếm

  • Bắt đầu từ gốc
  • So sánh phần tử đang tìm kiếm với root, nếu nhỏ hơn root thì đệ quy cho bên trái, ngược lại cho bên phải
  • Nếu tìm thấy phần tử cần tìm ở bất cứ đâu, trả về true, ngược lại trả về false

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6607

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6609

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6612

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6507
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6618
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6619
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6622

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6628

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6631

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6634

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6637

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6640

Chèn một phím

  • Bắt đầu từ gốc
  • So sánh phần tử chèn với root, nếu nhỏ hơn root thì đệ quy bên trái, ngược lại bên phải
  • Sau khi đến cuối, chỉ cần chèn nút đó ở bên trái [nếu nhỏ hơn hiện tại] ở bên phải

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6641

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6642

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6644

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6645

________ 1271 ________ 1272

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6331

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6226
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66231
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6236
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6669

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6670

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6672

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6507
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6681

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6619
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6622

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66695
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6631

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6435
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6700

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6430
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6707

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6268

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6712

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6714

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6355

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66719

_______1281____121____66722

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66724

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6727

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6728

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6729

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6730

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6731

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6732

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6733

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
379
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6738
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6742
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
262
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6742
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
47
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6742
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6753
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6742
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6758
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6742
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6763
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6735
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6742
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6768
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6771

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6772

Đầu ra

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
69

Các bài viết khác về cây tìm kiếm nhị phân

  • Cây tìm kiếm nhị phân – Phím xóa
  • Xây dựng BST từ giao dịch đặt hàng trước đã cho. Hiệp 1
  • Chuyển đổi cây nhị phân sang cây tìm kiếm nhị phân
  • Tìm nút có giá trị nhỏ nhất trong Cây tìm kiếm nhị phân
  • Chương trình kiểm tra xem cây nhị phân có phải là BST hay không

>>> Thêm

đồ thị

Biểu đồ là một cấu trúc dữ liệu phi tuyến bao gồm các nút và các cạnh. Các nút đôi khi còn được gọi là đỉnh và các cạnh là các đường hoặc cung nối hai nút bất kỳ trong biểu đồ. Chính thức hơn, Đồ thị có thể được định nghĩa là Đồ thị bao gồm một tập hợp hữu hạn các đỉnh [hoặc nút] và một tập hợp các cạnh kết nối một cặp nút

Trong Đồ thị trên, tập đỉnh V = {0,1,2,3,4} và tập cạnh E = {01, 12, 23, 34, 04, 14, 13}. Hai cách sau đây là cách biểu diễn đồ thị được sử dụng phổ biến nhất

  • Ma trận kề
  • Danh sách kề

Ma trận kề

Ma trận kề là một mảng 2D có kích thước V x V trong đó V là số đỉnh của đồ thị. Đặt mảng 2D là adj[][], một vị trí adj[i][j] = 1 cho biết có một cạnh từ đỉnh i đến đỉnh j. Ma trận kề của đồ thị vô hướng luôn đối xứng. Adjacency Matrix cũng được dùng để biểu diễn các đồ thị có trọng số. Nếu adj[i][j] = w, thì có một cạnh từ đỉnh i đến đỉnh j có trọng số w.  

Python3




Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6773

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
271
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6775

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6780

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279_______66783
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
79
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
00
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6790
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
04
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6795

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66798
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6790

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66803
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6805

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279_______66808
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
00
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6790

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6818
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6820
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6821
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6826
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6828
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6831

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66834
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6821
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6838

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66841
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6821

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6847
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6849
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6854
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6857

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6859
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6862

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66865
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6867

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66870

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____66873
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6867

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6879
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6808

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6889
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66893
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
399

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6903

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6903

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6916
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6089
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6922
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6924
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6926
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6928

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6893

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6935
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6783

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6943
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9____66945
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
667
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6948
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66951
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6948
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6956
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6948
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6961
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6948
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6966
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6948
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66971
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6948
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____5407
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6978
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6951
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66971
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66983
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6978
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6951
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66961
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____247
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______66978

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6961____22____66956
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
262
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6978
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6956
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66971
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6753
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6978
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6971____22____66966
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6738
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6978
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
407
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2____66971
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6763
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70023
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____170026

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70030
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____170033

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70037
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____170040

đầu ra

Các đỉnh của đồ thị

['a', 'b', 'c', 'd', 'e', ​​'f']

Các cạnh của đồ thị

[['a', 'c', 20], ['a', 'e', ​​10], ['b', 'c', 30], ['b', 'e', ​​40], [

Ma trận kề của đồ thị

[[-1, -1, 20, -1, 10, -1], [-1, -1, 30, -1, 40, -1], [20, 30, -1, -1, -1

Danh sách kề

Một mảng danh sách được sử dụng. Kích thước của mảng bằng số đỉnh. Đặt mảng là một mảng[]. Mảng đầu vào[i] đại diện cho danh sách các đỉnh liền kề với đỉnh thứ i. Biểu diễn này cũng có thể được sử dụng để biểu diễn biểu đồ có trọng số. Trọng số của các cạnh có thể được biểu diễn dưới dạng danh sách các cặp. Sau đây là biểu diễn danh sách kề của đồ thị trên.  

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70041

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
271
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70043

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
280

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____170051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
285

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____1289
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
290
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70062

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70063

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70064

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70065

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
271
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6775

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70072

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279____170075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70077

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70080
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
292
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
00
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70075

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70090

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70093
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70095

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170098

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6545______09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70102

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70104
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
290
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70108

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70108
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6545

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170116

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170118

________ 1281 ________ 66545 ________ 09 ________ 170122

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70104
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
290
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70128

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70128
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6545

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70136

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70139
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70149

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____122
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70153
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
289
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70155
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70156
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6182

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
331
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70163

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338____4336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70166

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70170
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
289
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70155
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70173
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6182

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
331
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
344
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
290

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____122
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70184
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70188

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362 ________ 2363______09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9 ________ 170193 ________ 17055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70196
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70200
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70202

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70204
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70247

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
700

Duyệt đồ thị

Tìm kiếm theo chiều rộng hoặc BFS

Breadth-First Traversal cho đồ thị tương tự như Breadth-First Traversal của cây. Điểm hấp dẫn duy nhất ở đây là, không giống như cây, đồ thị có thể chứa các chu trình, vì vậy chúng ta có thể quay lại cùng một nút. Để tránh xử lý một nút nhiều lần, chúng tôi sử dụng một mảng đã truy cập boolean. Để đơn giản, giả sử rằng tất cả các đỉnh đều có thể truy cập được từ đỉnh bắt đầu

Ví dụ, trong biểu đồ sau, chúng ta bắt đầu duyệt từ đỉnh 2. Khi đến đỉnh 0 ta tìm tất cả các đỉnh kề của nó. 2 cũng là đỉnh kề của 0. Nếu chúng tôi không đánh dấu các đỉnh đã truy cập, thì 2 sẽ được xử lý lại và nó sẽ trở thành một quá trình không kết thúc. A Breadth-First Traversal của đồ thị sau là 2, 0, 3, 1

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70248

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70249

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70250

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70251
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70252
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
19
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70254

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70256

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70257

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
271
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6775

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70262

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170270

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70080
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70275
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6185
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70280

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70283
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70285

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____1279____170288

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70291

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70294
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70296

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170299

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70301
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70304
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
00
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6068
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70311
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____170317

________ 1281 ________ 5445 ________ 09 ________ 4399

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170324

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170326

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170328

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70330
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70332

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____4336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70336

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70339

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70341

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70343
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6547
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70350
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7060
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70356

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70358

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70360

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70326

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70368

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70371
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70304
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6089
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70377

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6089
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70371
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70332

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6424

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70385

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70386

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70387
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70389

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______170390____23____22____6603

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____170423

_______66081____170425____124

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70427____23
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
701

Thời gian phức tạp. O[V+E] trong đó V là số đỉnh của đồ thị và E là số cạnh của đồ thị

Tìm kiếm theo chiều sâu hoặc DFS

Depth First Traversal cho đồ thị tương tự như Depth First Traversal của cây. Điểm hấp dẫn duy nhất ở đây là, không giống như cây, đồ thị có thể chứa các chu kỳ, một nút có thể được thăm hai lần. Để tránh xử lý một nút nhiều lần, hãy sử dụng mảng đã truy cập boolean

thuật toán

  • Tạo một hàm đệ quy lấy chỉ mục của nút và một mảng đã truy cập
  • Đánh dấu nút hiện tại là đã truy cập và in nút
  • Duyệt qua tất cả các nút liền kề và không được đánh dấu và gọi hàm đệ quy với chỉ mục của nút liền kề

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70430

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70431

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70251
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70252
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
19
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70254

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70437

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70438

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
271
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6775

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70262

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
278
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170270

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70080
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70275
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6185
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70280

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70283
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70466

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____1279____170288

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70472

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70475
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70477

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70480

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170482

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170484

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____170487
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6019
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170493

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170495

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70498
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70501

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70498
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70507

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70510

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70513

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____170515

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70518
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
279
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70520

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170523

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70301____09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7020
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7063

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170531

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170533

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____1279____170536

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6424

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70540

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70541

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70387
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70389

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______170390____23____22____6603

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3____22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70390
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70578
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70580
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
702

Thêm bài viết về đồ thị

  • Biểu diễn đồ thị sử dụng set và hash
  • Tìm đỉnh mẹ trong đồ thị
  • Độ sâu lặp lại Tìm kiếm đầu tiên
  • Đếm số lượng nút ở cấp độ nhất định trong cây bằng BFS
  • Đếm tất cả các đường đi có thể giữa hai đỉnh

>>> Thêm

đệ quy

Quá trình trong đó một hàm gọi chính nó một cách trực tiếp hoặc gián tiếp được gọi là đệ quy và hàm tương ứng được gọi là hàm đệ quy. Sử dụng các thuật toán đệ quy, một số vấn đề có thể được giải quyết khá dễ dàng. Ví dụ về các vấn đề như vậy là Towers of Hanoi [TOH], Inorder/Preorder/Postorder Tree Traversals, DFS of Graph, v.v.

Điều kiện cơ bản trong đệ quy là gì?

Trong chương trình đệ quy, giải pháp cho trường hợp cơ sở được cung cấp và giải pháp cho vấn đề lớn hơn được thể hiện dưới dạng các vấn đề nhỏ hơn.  

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
703

Trong ví dụ trên, trường hợp cơ sở cho n < = 1 được xác định và giá trị lớn hơn của số có thể được giải quyết bằng cách chuyển đổi thành trường hợp nhỏ hơn cho đến khi đạt đến trường hợp cơ sở

Làm thế nào bộ nhớ được phân bổ cho các cuộc gọi chức năng khác nhau trong đệ quy?

Khi bất kỳ chức năng nào được gọi từ main[], bộ nhớ được cấp phát cho nó trên ngăn xếp. Hàm đệ quy gọi chính nó, bộ nhớ cho hàm được gọi được phân bổ trên bộ nhớ được phân bổ cho hàm gọi và một bản sao khác của các biến cục bộ được tạo cho mỗi lần gọi hàm. Khi đạt đến trường hợp cơ sở, hàm sẽ trả về giá trị của nó cho hàm mà nó được gọi và bộ nhớ được giải phóng và quá trình tiếp tục

Hãy để chúng tôi lấy ví dụ về cách hoạt động của đệ quy bằng cách lấy một hàm đơn giản.  

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70583

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70584

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70585

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70588

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70592
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____170603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7060
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70608
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70611
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70612

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____170603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7060
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66018

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70622

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70623
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70626

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
704

Ngăn xếp bộ nhớ đã được hiển thị trong sơ đồ bên dưới

Các bài viết khác về đệ quy

  • đệ quy
  • Đệ quy trong Python
  • Câu hỏi thực hành cho đệ quy. Hiệp 1
  • Câu hỏi thực hành cho đệ quy. bộ 2
  • Câu hỏi thực hành cho đệ quy. bộ 3
  • Câu hỏi thực hành cho đệ quy. bộ 4
  • Câu hỏi thực hành cho đệ quy. Bộ 5
  • Câu hỏi thực hành cho đệ quy. Bộ 6
  • Câu hỏi thực hành cho đệ quy. Bộ 7

>>> Thêm

Lập trình năng động

Lập trình động chủ yếu là tối ưu hóa trên đệ quy đơn giản. Bất cứ khi nào chúng tôi thấy một giải pháp đệ quy có các lệnh gọi lặp lại cho cùng một đầu vào, chúng tôi có thể tối ưu hóa giải pháp đó bằng Lập trình động. Ý tưởng đơn giản là lưu trữ kết quả của các bài toán con, để chúng ta không phải tính toán lại chúng khi cần sau này. Tối ưu hóa đơn giản này làm giảm sự phức tạp về thời gian từ hàm mũ sang đa thức. Ví dụ: nếu chúng ta viết giải pháp đệ quy đơn giản cho Số Fibonacci, chúng ta sẽ nhận được độ phức tạp theo cấp số nhân và nếu chúng ta tối ưu hóa nó bằng cách lưu trữ các giải pháp của các bài toán con, độ phức tạp về thời gian sẽ giảm xuống tuyến tính

Lập bảng vs Ghi nhớ

Có hai cách khác nhau để lưu trữ các giá trị để có thể sử dụng lại các giá trị của một vấn đề con. Ở đây, sẽ thảo luận về hai mô hình giải bài toán quy hoạch động [DP].  

  • lập bảng. Từ dưới lên
  • ghi nhớ. Từ trên xuống

lập bảng

Như chính cái tên đã gợi ý bắt đầu từ phía dưới và tích lũy các câu trả lời lên trên cùng. Hãy thảo luận về chuyển đổi trạng thái

Hãy mô tả một trạng thái cho bài toán DP của chúng ta là dp[x] với dp[0] là trạng thái cơ sở và dp[n] là trạng thái đích của chúng ta. Vì vậy,  chúng ta cần tìm giá trị của trạng thái đích i. đp[n]

Nếu chúng ta bắt đầu quá trình chuyển đổi từ trạng thái cơ sở của mình, tôi. e dp[0] và tuân theo quan hệ chuyển tiếp trạng thái của chúng tôi để đạt tới trạng thái đích dp[n], chúng tôi gọi đó là cách tiếp cận Từ dưới lên vì rõ ràng là chúng tôi đã bắt đầu quá trình chuyển đổi từ trạng thái cơ sở dưới cùng và đạt tới trạng thái mong muốn cao nhất

Bây giờ, Tại sao chúng ta gọi nó là phương pháp lập bảng?

Để biết điều này, trước tiên chúng ta hãy viết một số mã để tính giai thừa của một số bằng cách sử dụng phương pháp từ dưới lên. Một lần nữa, như thủ tục chung của chúng tôi để giải quyết DP, trước tiên chúng tôi xác định trạng thái. Trong trường hợp này, chúng tôi xác định trạng thái là dp[x], trong đó dp[x] là để tìm giai thừa của x

Bây giờ, rõ ràng là dp[x+1] = dp[x] * [x+1]

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
705

ghi nhớ

Một lần nữa, hãy mô tả nó dưới dạng chuyển đổi trạng thái. Nếu chúng ta cần tìm giá trị cho một trạng thái nào đó, hãy nói dp[n] và thay vì bắt đầu từ trạng thái cơ sở mà tôi. e dp[0] chúng tôi hỏi câu trả lời của chúng tôi từ các trạng thái có thể đến trạng thái đích dp[n] theo quan hệ chuyển đổi trạng thái, thì đó là kiểu từ trên xuống của DP

Ở đây, chúng tôi bắt đầu hành trình của mình từ trạng thái đích cao nhất và tính toán câu trả lời của nó bằng cách tính giá trị của các trạng thái có thể đạt đến trạng thái đích, cho đến khi chúng tôi đạt đến trạng thái cơ sở thấp nhất

Một lần nữa, hãy viết mã cho bài toán giai thừa theo kiểu từ trên xuống

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
706

Các bài viết khác về Lập trình động

  • Thuộc tính cấu trúc con tối ưu
  • Thuộc tính bài toán con chồng chéo
  • số Fibonacci
  • Tập con có tổng chia hết cho m
  • Tổng tối đa Tăng Subsequence
  • Xâu con chung dài nhất

>>> Thêm

thuật toán tìm kiếm

Tìm kiếm tuyến tính

  • Bắt đầu từ phần tử ngoài cùng bên trái của mảng[] và lần lượt so sánh x với từng phần tử của mảng[]
  • Nếu x khớp với một phần tử, hãy trả về chỉ mục
  • Nếu x không khớp với bất kỳ phần tử nào, hãy trả về -1

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70627

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70628

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70629

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70633

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70642

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70645
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70648

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70622

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70659
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6983
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6753
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
04
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6983

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70675
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70678

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70680

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70681
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70683

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70685
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70694
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____122
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70701
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70702

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
707

Độ phức tạp thời gian của thuật toán trên là O[n].  

Để biết thêm thông tin, tham khảo Tìm kiếm tuyến tính

Tìm kiếm nhị phân

Tìm kiếm một mảng đã sắp xếp bằng cách chia đôi khoảng thời gian tìm kiếm nhiều lần. Bắt đầu với một khoảng thời gian bao gồm toàn bộ mảng. Nếu giá trị của khóa tìm kiếm nhỏ hơn mục ở giữa khoảng thời gian, hãy thu hẹp khoảng thời gian xuống nửa dưới. Nếu không, hãy thu hẹp nó ở nửa trên. Kiểm tra liên tục cho đến khi tìm thấy giá trị hoặc khoảng thời gian trống

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70703

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70705

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70707

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70710

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70713
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70715

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70718
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70720
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70722
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70724
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170730

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70733
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70736

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338____66018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70718

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170742

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170744

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66695
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70747

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70750
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70753

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170756

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170758

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____66683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70764
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70767

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170773

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70622

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70659
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
663
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6983
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6753
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
04
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6983

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70680

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70681
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70800
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70678
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70753

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70810
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____170818
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70819
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70820

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____170694
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
708

Độ phức tạp thời gian của thuật toán trên là O[log[n]].  

Để biết thêm thông tin, tham khảo Tìm kiếm nhị phân

thuật toán sắp xếp

Sắp xếp lựa chọn

Thuật toán sắp xếp lựa chọn sắp xếp một mảng bằng cách liên tục tìm phần tử tối thiểu [xét theo thứ tự tăng dần] từ phần chưa sắp xếp và đặt nó ở đầu. Trong mỗi lần lặp lại của sắp xếp lựa chọn, phần tử nhỏ nhất [xét theo thứ tự tăng dần] từ mảng con chưa sắp xếp được chọn và chuyển sang mảng con đã sắp xếp.  

Sơ đồ sắp xếp lựa chọn.  

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70828

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70829

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
19
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70831

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70834
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0_______170837
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
228
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
224
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
55
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
51
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70848

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70855

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70858

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70860

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70862
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70870
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70855

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70878

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70862
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70883

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____170885

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____170887

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70889
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70891

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70893

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70896
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70855

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____170908
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70819
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70910

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
709

Thời gian phức tạp. O[n2] vì có hai vòng lặp lồng nhau

Không gian phụ trợ. Ô[1]

Sắp xếp bong bóng

Sắp xếp bong bóng là thuật toán sắp xếp đơn giản nhất hoạt động bằng cách hoán đổi liên tục các phần tử liền kề nếu chúng sắp xếp sai thứ tự

Hình minh họa.  

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70911

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70914

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70675
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70678

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70848

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70928

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____170931

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70939
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
309

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70947

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70949

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70951

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70954
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1____170957

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70959
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70964
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70967

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70893

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70659
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70837
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70975
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
228
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
224
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
55
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
51
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70985
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70988

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70992
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052____17053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
000

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22____170908
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70819
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
006

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
0

Thời gian phức tạp. O[n2]

Sắp xếp chèn

Để sắp xếp một mảng kích thước n theo thứ tự tăng dần bằng sắp xếp chèn

  • Lặp lại từ mảng[1] đến mảng[n] trên mảng
  • So sánh phần tử hiện tại [khóa] với phần tử tiền nhiệm của nó
  • Nếu phần tử chính nhỏ hơn phần tử tiền nhiệm của nó, hãy so sánh nó với các phần tử trước đó. Di chuyển các phần tử lớn hơn lên một vị trí để tạo khoảng trống cho phần tử được hoán đổi

Hình minh họa

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
007

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
009

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
011

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0014

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
000

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
029

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0032

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____0034

_______1281____0036

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
045
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
048
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
049

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70964
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
056

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70964
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6238

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70893

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70659
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
224
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
51
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
93
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
667
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
085

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052____17053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
000

________ 17056

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21 ________ 122
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
096 ________ 170819 ________ 0098

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
1

Thời gian phức tạp. O[n2]]

Hợp nhất Sắp xếp

Giống như QuickSort, Merge Sort là thuật toán Chia để trị. Nó chia mảng đầu vào thành hai nửa, gọi chính nó cho hai nửa và sau đó hợp nhất hai nửa đã sắp xếp. Hàm merge[] được sử dụng để hợp nhất hai nửa. Việc hợp nhất[arr, l, m, r] là một quá trình quan trọng giả định rằng mảng[l. m] và mảng[m+1. r] được sắp xếp và hợp nhất hai mảng con đã sắp xếp thành một.  

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
2

 

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
099

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
101

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
105
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0110

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70718
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70678
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0121

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
123____09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
125

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0128

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
130
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
132

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0135

________ 1281 ________ 0137

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0140

_______1281____0142

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0154

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
157
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
159
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
048
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
161
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
163

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
166

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
168
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
170

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052____170312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6683
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
168
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
182

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______1281____0195

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____4336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
157____66038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
200

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
168
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
170

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____4336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
161____66038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
163

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
168
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
182

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906____170312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
236

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
240

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7051
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7053
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6075
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
000

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21____0251
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7060
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

_______17056____121____17063

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70622

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362 ________ 2363____09
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9 ________ 2366 ________ 17055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70659
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
224
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2_______251
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
93
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
667
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6142
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
286
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
287
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
289
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0292

_______17056____0294

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
21
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
22
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
298
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
287
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
289
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0292

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
3

Thời gian phức tạp. O[n[logn]]

Sắp xếp nhanh chóng

Giống như Hợp nhất Sắp xếp, QuickSort là thuật toán Chia để trị. Nó chọn một phần tử làm trục và phân vùng mảng đã cho xung quanh trục đã chọn. Có nhiều phiên bản khác nhau của quickSort chọn trục theo những cách khác nhau

Luôn chọn phần tử đầu tiên làm trục

  • Luôn chọn phần tử cuối cùng làm trục [triển khai bên dưới]
  • Chọn một yếu tố ngẫu nhiên làm trục
  • Chọn trung vị làm trục

Quá trình quan trọng trong quickSort là phân vùng[]. Mục tiêu của các phân vùng là, cho một mảng và một phần tử x của mảng làm trục, đặt x vào đúng vị trí của nó trong mảng đã sắp xếp và đặt tất cả các phần tử nhỏ hơn [nhỏ hơn x] trước x và đặt tất cả các phần tử lớn hơn [lớn hơn x] sau . Tất cả điều này nên được thực hiện trong thời gian tuyến tính

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
4

thuật toán phân vùng

Có thể có nhiều cách để thực hiện phân vùng, mã giả sau áp dụng phương pháp được đưa ra trong cuốn sách CLRS. Logic rất đơn giản, chúng ta bắt đầu từ phần tử ngoài cùng bên trái và theo dõi chỉ số của các phần tử nhỏ hơn [hoặc bằng] như i. Trong khi di chuyển ngang, nếu tìm thấy phần tử nhỏ hơn, chúng ta hoán đổi phần tử hiện tại bằng arr[i]. Nếu không, chúng tôi bỏ qua phần tử hiện tại.  

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
4

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
305

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
307

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
308

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
309

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
311

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

_______17056____0314

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
316
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
318

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
320
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
322

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0325

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0327

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0329

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
332

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____0335

_______1281____0337

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
340
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
342
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
048
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
344
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
346

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
318
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70883

_______1281____0354

_______1281____0356

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____4336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
359

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
361____6624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

_______1281____0367

_______1281____0369

_______1281____2362____0372

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
374
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
376

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0379

_______17056____0381

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
383
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
385

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____0388

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6018
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
361

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
393

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
395

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056____2362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
372

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

_______1281____0402

_______1281____0404

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
406
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
408

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

_______1281____0411

_______1281____0413

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
415____6624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
418

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
420
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
423

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6424

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
426
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6983
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6142
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
43
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6166
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
665
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
441
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
342
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
418

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

_______121____0451____0452

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
24

Đầu ra

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6

Thời gian phức tạp. O[n[logn]]

ShellSắp xếp

ShellSort chủ yếu là một biến thể của Sắp xếp chèn. Trong sắp xếp chèn, chúng ta chỉ di chuyển các phần tử lên phía trước một vị trí. Khi một yếu tố phải được di chuyển xa về phía trước, nhiều chuyển động được tham gia. Ý tưởng của shellSort là cho phép trao đổi các mục xa. Trong shellSort, chúng tôi sắp xếp mảng h cho giá trị lớn của h. Chúng tôi tiếp tục giảm giá trị của h cho đến khi nó trở thành 1. Một mảng được gọi là sắp xếp h nếu tất cả các danh sách con của mọi phần tử thứ h được sắp xếp

Python3




Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
454

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
277
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
457

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7056
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
459
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70678
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
466

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

________ 17056

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336 ________ 0470
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603 ________ 17055

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____17052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
603

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
459

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281____0483

_______1281____0485

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281______4336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
161____66038
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
490

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
618

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
494

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
496
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
498

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70883

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6906____170312
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6868

_______4338____0512

_______4338____0514

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7052

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
338
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
336
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
470
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7055

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
362
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
530
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
532

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6089
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
530
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
536
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
538
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
540

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
6081
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
149
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
624
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
1

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
281
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
459____170725
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70725
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
74

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
555

Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
556
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
224
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
70975
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
563
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
3
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Normal Set
{'a', 'b', 'c'}

Frozen Set
frozenset[{'f', 'g', 'e'}]
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
20

Chủ Đề