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 True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
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 True25
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True26
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True9
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____438
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
_______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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____547
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____6616
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____6647
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True24
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 True9
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____6671
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
________ 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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____6681
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____6694
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7006
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True70
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 True7015
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7016
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7017
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7020
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7021
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7038
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True7045
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7046
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7049
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052____17053
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____17058
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7060
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True7065
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7066
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True7053
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Đầ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 True7073
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7074
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7020
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7021
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7078
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 True7080
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 True7082
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7087
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True7092
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7093
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7095
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7021
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7097
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 True7099
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 True01
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True09
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 True11
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True13
Đầ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 True14
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True16
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True19
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True24
_______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 True24
_______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 True34
_______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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True30____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 True2
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 True44
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True45
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True47
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True48
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
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 True53
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 True61
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True64
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____045
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True71
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True74
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____045____20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True48
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 True83
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True84
_______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 True24
_______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 True94
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 True96
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True97_______09
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True99
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 True7051
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 True7053
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 True61
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
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 True9
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 True9
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 True94
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
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 True9
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True201
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
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 True206
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True209____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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True216
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
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 True24
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 True24
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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____5415
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____5425
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____5428
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____5428
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____5436
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True9
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 True24
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 True24
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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____5462
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____5470
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
_______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 True94
_______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 True94
_______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 True94
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____5487
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True271
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66008
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True281
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 True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True7056
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True281
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True280
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True7056
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True9
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 True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True279
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 True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True20
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 True279
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 True20
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 True281____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 True21____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 True9 ________ 2366 ________ 17055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True9
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 True7056
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 True224
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True24
_______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 True7056
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 True9
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 True20
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True9
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True9
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True9
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 True21
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
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 True9
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 True24
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 True281
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 True7056____66277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True9
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 True9
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 True281
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 True281____66277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____66298
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True9
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 True281
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 True7056
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 True7056
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 True7056
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
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 True277
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 True7056
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 True281____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 True281____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 True281____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 True277
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 True7056
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 True281____66358
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True281____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 True281____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 True277
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 True7056
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 True281____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 True281____66414
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True281____66419
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____66452
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____66458
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
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 True24
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 True7056
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True283
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
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 True277
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 True7056
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 True7056
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 True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True7056
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 True7056
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 True7056
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 True9
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 True7056
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 True7056____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 True7056
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 True22____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 True281____66536
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____66538
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
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 True281
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 True9
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 True24
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 True281
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 True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
_______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 True281____66564
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
_______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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True277
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 True7056
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 True7056
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 True292
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281____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 True7056
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 True7056
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 True281____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 True7056
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 True7056
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
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 True277
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 True7056
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 True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True7056
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 True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281____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 True9
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 True281____66683
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
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 True9
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 True7056
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 True277
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 True7056
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 True281____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 True281____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 True9
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 True24
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 True9
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 True262
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True9
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 True24
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 True271
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279_______66783
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
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 True7051
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 True7053
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66798
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66803
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279_______66808
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True281
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 True9
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True279____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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True279____66841
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True9
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 True281
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66865
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281____66870
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____66873
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True281____66018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True281____66893
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True7051
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 True7053
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9
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 True279
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 True279
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 True279
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 True281____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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
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 True279
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 True281____66018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True9____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 True24
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 True24
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 True24
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 True24
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 True24
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 True24
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 True24
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 True24
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 True24
_______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 True262
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True24
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 True24
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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70023
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70030
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70037
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____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 True70041
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True271
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70043
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True280
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____170051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True285
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____1289
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True290
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True292
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 True70062
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70063
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70064
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70065
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True271
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70072
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279____170075
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70077
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70080
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True292
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True20
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 True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70075
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70090
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70093
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70095
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 True281____170098
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True70102
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70104
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True290
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70108
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70108
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281____170116
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70104
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True290
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70128
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70128
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70136
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70139
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70149
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 True21____122
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70153
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True289
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70155
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70156
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70163
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 True70166
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70170
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True289
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70155
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70173
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True9
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 True290
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 True21____122
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70184
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True70188
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 True9 ________ 170193 ________ 17055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70196
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70200
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70202
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70204
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 True24
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70247
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True700
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 True70248
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70249
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70250
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70251
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70252
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 True70254
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 True70256
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70257
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True271
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70262
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281____170270
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70080
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70275
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 True24
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70280
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70283
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70285
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70291
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70294
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70296
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 True281____170299
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70301
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70304
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True20
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 True22
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 True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70311
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True24
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 True281____170324
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170326
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170328
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70330
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70332
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 True281____4336
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70336
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 True70339
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 True70341
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 True70343
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70350
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7060
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True70356
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 True70358
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 True70360
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 True70326
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 True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70368
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 True70371
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70304
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
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 True70377
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 True70371
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70332
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 True70385
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70386
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70387
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70389
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
_______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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____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 True70427____23
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True701
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 True70430
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70431
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70251
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70252
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 True70254
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 True70437
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70438
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True271
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70262
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True278
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
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 True281____170270
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70080
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70275
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 True24
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70280
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70283
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70466
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70472
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70475
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70477
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70480
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170482
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170484
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____170487
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True24
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 True281____170493
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170495
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70498
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70501
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 True70498
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 True7053
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70507
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 True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70510
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70513
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____170515
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70518
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True279
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70520
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 True281____170523
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70301____09
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7020
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7063
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 True281____170531
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170533
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True70540
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70541
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70387
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70389
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
_______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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70390
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 True24
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70578
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70580
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 True24
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True702
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 True703
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 True70583
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70584
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70585
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 True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70588
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 True7056
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 True70592
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 True281____66018
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True7055
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____170603
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7060
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70608
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 True70611
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70612
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____170603
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7060
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____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 True70622
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70623
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70626
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True704
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 True705
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 True706
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 True70627
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70628
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70629
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 True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70633
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
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 True70642
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True70645
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70648
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 True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True70622
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70659
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
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 True9
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 True70675
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70678
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 True70680
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70681
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70683
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 True70685
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70694
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
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 True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____122
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70701
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70702
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True707
Độ 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 True70703
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 True70705
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70707
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70710
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True70713
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70715
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70718
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70720
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70722
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 True70724
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
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 True281____170730
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True70733
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70736
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 True70718
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 True281____170742
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170744
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____66695
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70747
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 True70750
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 True70753
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 True281____170756
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170758
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____66683
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7055
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 True70764
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True70767
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 True7056
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 True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281____170773
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True70622
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70659
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
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 True9
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 True70680
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70681
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70800
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 True70678
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 True70753
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 True70810
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____170818
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70819
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70820
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 True7055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____170694
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True708
Độ 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 True70828
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70829
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 True70831
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 True70834
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True228
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 True224
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 True20
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 True70848
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
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 True70855
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70858
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70860
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70862
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
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 True7053
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 True70870
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True70855
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
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 True70878
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 True70862
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70883
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____170885
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____170887
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70889
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70891
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 True70893
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70896
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
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 True70855
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____170908
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70819
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70910
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True709
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 True70911
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 True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70914
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70675
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70678
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70848
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True70928
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 True281____170931
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
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 True7053
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 True22
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 True70939
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 True7052
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 True70947
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 True70949
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 True70951
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 True70954
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True70959
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70964
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True70967
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 True70893
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70659
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70837
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 True70975
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 True228
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 True224
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 True70985
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True20
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 True70988
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 True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70992
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052____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 True22
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 True000
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22____170908
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70819
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True006
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True0
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 True007
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 True009
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True011
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 True7056____0014
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
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 True000
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 True281
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True029
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 True281____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 True281
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
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 True281
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 True045
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True048
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True049
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 True70964
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True056
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 True9
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70964
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70893
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70659
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True224
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True085
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052____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 True22
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 True000
________ 17056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21 ________ 122
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True096 ________ 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 True1
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 True2
Python3
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True099
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True101
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True105
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 True7055
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70718
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70678
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True123____09
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True125
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True130
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True132
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True149
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281
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 True157
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 True159
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True048
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True161
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 True163
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 True166
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 True168
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True170
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 True7052____170312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True7055
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 True168
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True182
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 True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True149
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281____4336
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True157____66038
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True200
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 True168
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True170
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 True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True149
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281____4336
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True161____66038
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True163
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 True168
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True182
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 True9
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 True149
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True236
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 True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True240
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7051
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7053
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 True22
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 True000
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21____0251
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7060
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
_______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 True70622
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 True9 ________ 2366 ________ 17055
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70659
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True224
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True286
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True287
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True289
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True22
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True298
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True287
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True289
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True24
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____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 True3
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 True4
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 True4
Python3
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True305
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 True307
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True308
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True309
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True311
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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True316
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True318
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True320
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True322
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 True7056____0325
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____0327
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056____0329
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True332
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 True281____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 True281
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 True340
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 True342
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True048
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True344
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True346
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 True318
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70883
_______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 True281____4336
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True359
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 True361____6624
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True374
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True376
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 True7056____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 True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True383
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True385
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 True7056____0388
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
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 True361
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 True393
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True395
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 True7056____2362
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True372
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True406
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True408
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True415____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 True418
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True420
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
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 True423
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 True426
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True441
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 True342
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 True418
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 True24
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
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 True454
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 True277
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True457
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7056
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True459
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True70678
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
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 True466
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 True281____17052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True281
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True459
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 True281____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 True281______4336
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True161____66038
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True490
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 True494
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 True496
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True498
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70883
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 True7052
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70312
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True9
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 True149
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7052
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 True149
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 True470
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 True7055
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 True530
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 True532
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 True530
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 True536
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True538
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 True540
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 True149
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 True9
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 True281
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True459____170725
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True70725
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True555
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True556
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
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 True224
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 True70975
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 True563
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 True20