Hướng dẫn data structure and algorithm python - cấu trúc dữ liệu và thuật toán python
Hướng dẫn này là một hướng dẫn thân thiện với người mới bắt đầu để học các cấu trúc dữ liệu và thuật toán sử dụng Python. Trong bài viết này, chúng tôi sẽ thảo luận về các cấu trúc dữ liệu được xây dựng 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 Với sự giúp đỡ của các ví dụ tốt và được giải thích tốt và các câu hỏi thực hành. Show
Danh sáchDanh sách Python được đặt hàng các bộ sưu tập dữ liệu giống như các mảng trong các ngôn ngữ lập trình khác. Nó cho phép các loại yếu tố khác nhau trong danh sách. Việc triển khai danh sách Python tương tự như các vectơ trong C ++ hoặc ArrayList trong Java. Hoạt động 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ử là cần thiết để được thay đổi. Chèn và xóa vào cuối danh sách cũng có thể trở nên tốn kém trong trường hợp bộ nhớ được phân bổ trước. Ví dụ: Tạo danh sách PythonPython3Is Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True5 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Đầu ra [1, 2, 3, 'GFG', 2.3] Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là (nếu n phần tử có) N-1. Ví dụ: Hoạt động danh sách PythonPython3Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s7 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__55555547 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}3 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True5 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}9 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]1 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]4 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]5 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]7 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')0 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks02 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là (nếu n phần tử có) N-1.Ví dụ: Hoạt động danh sách Python Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s7 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__55555547
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}9Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]1[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]4[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]5[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]7Python3Tuple Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks27 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Các bộ dữ liệu python tương tự như danh sách nhưng các bộ dữ liệu có tính chất bất biến, tức là một khi được tạo ra, nó không thể được sửa đổi. Giống như một danh sách, một tuple cũng có thể chứa các yếu tố của nhiều loại khác nhau. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks48 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Trong Python, các bộ dữ liệu được tạo ra 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. & NBSP; Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks56 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks66 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks77 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Đầu ra Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4 Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là (nếu n phần tử có) N-1.Ví dụ: Hoạt động danh sách Python Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s5 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s7 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__55555547
TuplePython3Các bộ dữ liệu python tương tự như danh sách nhưng các bộ dữ liệu có tính chất bất biến, tức là một khi được tạo ra, nó không thể được sửa đổi. Giống như một danh sách, một tuple cũng có thể chứa các yếu tố của nhiều loại khác nhau. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 406 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks86 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 414 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Trong Python, các bộ dữ liệu được tạo ra 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. & NBSP; Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 423 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428 LƯU Ý: Để tạo một bộ phận của một yếu tố, phải có dấu phẩy kéo dài. Ví dụ: (8,) sẽ tạo một tuple chứa 8 là phần tử. Đầ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 Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là (nếu n phần tử có) N-1.Các bộ đông lạ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 bộ hoặc bộ đóng băng mà chúng được áp dụng. Mặc dù các phần tử của một tập hợp có thể được sửa đổi bất cứ lúc nào, các phần tử của bộ đông lạnh vẫn giữ nguyên sau khi tạo. Ví dụ: Bộ đóng băng PythonPython3Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 435 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 439 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 441 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4424243 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 447 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 450 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 451 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 453 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 455 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 457 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 459 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 463 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 466 Đầu ra Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'}) Sợi dâyChuỗ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ự duy nhất chỉ đơn giản là một chuỗi có chiều dài 1. Lưu ý: Vì các chuỗi là bất biế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. As strings are immutable, modifying a string will result in creating a new copy. Ví dụ: Các hoạt động của chuỗi PythonPython3Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 467 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 469 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 472 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 475 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 478 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 481 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 486 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 481 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Đầu ra Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s Sợi dâyChuỗ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ự duy nhất chỉ đơn giản là một chuỗi có chiều dài 1. Lưu ý: Vì các chuỗi là bất biế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.Python3Ví dụ: Các hoạt động của chuỗi Python Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 True12 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 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 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 496 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 467 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 469 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True35 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 True37 Từ điển Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True59 Đầu ra Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} Sợi dâyChuỗ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ự duy nhất chỉ đơn giản là một chuỗi có chiều dài 1. Lưu ý: Vì các chuỗi là bất biế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.Python3Ví dụ: Các hoạt động của chuỗi Python Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 467 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 469 Từ điển Từ điển Python là một bộ sưu tập dữ liệu không được đặt hàng 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 của O (1). Việc lập chỉ mục từ điển Python được thực hiện với sự trợ giúp của các khóa. Đây là bất kỳ loại băm nào, tức là 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 một từ điển bằng cách sử dụng niềng răng xoăn ({}) hoặc hiểu từ điển. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})07 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})10 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})13 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})13 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})19 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Ví dụ: Hoạt động từ điển Python Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})37 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})07 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 495 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 496 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 497 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2 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 True8 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True01 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8____39__ Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})50 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})07 Đầu ra [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Sợi dâyChuỗ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ự duy nhất chỉ đơn giản là một chuỗi có chiều dài 1. Lưu ý: Vì các chuỗi là bất biế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.Python3Ví dụ: Các hoạt động của chuỗi Python Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})67 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})73 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 True8 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 467 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 469 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})84 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})88 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})89 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})93 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})70 Đầu ra Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e') Sợi dâyChuỗ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ự duy nhất chỉ đơn giản là một chuỗi có chiều dài 1. Lưu ý: Vì các chuỗi là bất biế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.
Ví dụ: Xác định danh sách được liên kết trong PythonPython3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s08 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s16 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0224524____36 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút. Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s08 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s16 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0224524____36 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s58 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s64 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s66 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s68 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s74 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s80 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s86Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s89Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s91 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s94 Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s08 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s16 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0224524____36 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s58 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s64 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s66 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s68 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s58 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s64 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s66 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s68 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s74 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s80 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}85 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s86Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s89
Thêm các bài viết trong danh sách được liên kếtLiên kết danh sách chèn Xóa danh sách được liên kết (xóa một khóa đã cho)
Python3>>> Thêm Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}89 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Cây rơm Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}89 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]03 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]06 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]09 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]09 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]09 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]16 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]03 Một ngăn xếp là một cấu trúc dữ liệu tuyến tính lưu trữ các mục theo cách cuối cùng/đầu tiên (LIFO) hoặc đầu tiên/lần cuối (FIRO). Trong ngăn xếp, một phần tử mới được thêm vào ở một đầu và một phần tử chỉ được loại bỏ khỏi đầu đó. Các hoạt động chèn và xóa thường được gọi là đẩy và pop. Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: [] Các chức năng liên quan đến ngăn xếp là:
Thêm các bài viết trong danh sách được liên kếtLiên kết danh sách chèn Xóa danh sách được liên kết (xóa một khóa đã cho)
Python3[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]20 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]23 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]23 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}93 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]23 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]34 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]37 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]40 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]43 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]43 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]43 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]56 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]37 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks0 Thêm các bài viết về hàng đợi
Hàng đợi ưu tiênHàng đợi ưu tiên là các 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ý với tiêu đề kinh doanh, hoặc hạng nhất của nhóm đến sớm hơn phần còn lại. Hàng đợi ưu tiên là một phần mở rộng của hàng đợi với các thuộc tính sau.
Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]61 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]62 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0225771 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]76 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Is Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]92 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02. Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')06 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')11 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')18 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')21 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')37 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')39 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')21 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')41 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')42 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')21 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')45 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')47 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')39 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')21 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})7 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')54 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')39 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')21 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})7 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')61 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')63 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')64 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')69 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')71 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')777____36 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')79 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')81 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})57 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')81 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')81 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')90 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')81 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')94 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []02 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []05 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks1 Thêm các bài viết về hàng đợiThực hiện hàng đợi bằng cách sử dụng ngăn xếp Thực hiện ngăn xếp bằng hàng đợi
Python3Hàng đợi ưu tiên là các 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ý với tiêu đề kinh doanh, hoặc hạng nhất của nhóm đến sớm hơn phần còn lại. Hàng đợi ưu tiên là một phần mở rộng của hàng đợi với các thuộc tính sau. Một yếu tố có mức độ ưu tiên cao được khử trùng trước một phần tử có mức độ ưu tiên thấp. Nếu hai yếu tố có cùng mức độ ưu tiên, chúng được phục vụ theo đơn đặt hàng của chúng trong hàng đợi. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]61 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]62 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []32 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0225771 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0225771 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]76 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks2 Thêm các bài viết về hàng đợi
>>> Thêm Cây nhị phânMột cây là cấu trúc dữ liệu phân cấp của A & nbsp; trông giống như hình dưới đây - List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks3 Nút cao nhất của cây được gọi là gốc trong khi các nút Bottommost hoặc các nút không có trẻ em được gọi là các nút lá. Các nút trực tiếp dưới một nút được gọi là con của nó và các nút trực tiếp ở trên một cái gì đó được gọi là cha mẹ của nó. Một cây nhị phân là một cây có các yếu tố có thể có gần hai đứa con. Vì mỗi yếu tố trong một cây nhị phân chỉ có thể có 2 con, chúng tôi thường đặt tên cho chúng là con trái và phải. Một nút cây nhị phân chứa các phần sau.
Ví dụ: Xác định lớp nútPython3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74 Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới - List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks4 Ví dụ: Thêm dữ liệu vào câyPython3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74 Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới - Ví dụ: Thêm dữ liệu vào cây Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks0022____36 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks007Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks012 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks5 Cây truyền tải
Đặt hàng trước (gốc, trái, phải): 1 2 4 5 3
Ghé thăm gốc.
Traverse Subtree bên phải, tức là, gọi Inororder (bên phải-Subtree)
Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74 Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới - Ví dụ: Thêm dữ liệu vào cây Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks045 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks050 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks0022____36 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006 Ví dụ: Thêm dữ liệu vào cây Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks057 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks059 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks048 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Ví dụ: Thêm dữ liệu vào cây Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks048 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks072 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks074 Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới - Ví dụ: Thêm dữ liệu vào cây Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks0022____36 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks007 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks102 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks104 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks107 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks109 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks112 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks114
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks6 Cây truyền tải 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 để đi qua cây. Hãy để chúng tôi xem xét cây dưới đây - Độ sâu đầu tiên đi qua: Inorder (trái, gốc, phải): 4 2 5 1 3
Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74 Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới - Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Ví dụ: Thêm dữ liệu vào cây Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks152 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks157 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks162 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks164 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks168 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks173 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks179 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks182 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks188 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks080 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks085 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks012 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks095 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks216 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks218 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks7 Độ phức tạp về thời gian: O (n) & nbsp; Thêm bài viết về cây nhị phân
>>> Thêm Cây tìm kiếm nhị phânCây tìm kiếm nhị phân là một 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ác thuộc tính trên của cây tìm kiếm nhị phân cung cấp một đơn đặt hàng 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 nhất định. Yếu tố tìm kiếm
Python3Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks220 Is Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks233 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks236 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks239 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks242 Chèn một khóa & nbsp;
Python3Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks220 Is Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks233 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks236 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks239 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks242 Chèn một khóa & nbsp; So sánh phần tử chèn với gốc, nếu ít hơn root, sau đó tái phát cho bên trái, khác phục hồi cho bên phải. Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Sau khi đạt đến cuối, chỉ cần chèn nút đó ở bên trái (nếu nhỏ hơn hiện tại) khác phải. Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})98 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks266 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks311 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks314 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks316 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks275 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks227 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks230 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks233 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks289 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks236 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks085 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks294 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks080 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks301 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks233 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks352 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks8 Độ phức tạp về thời gian: O (n) & nbsp;
>>> Thêm Cây tìm kiếm nhị phânCây tìm kiếm nhị phân là một 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: Subtree bên trái của một nút chỉ chứa các nút có các phím nhỏ hơn phím nút.
Ma trận kềMa trận liền kề là một mảng 2D có kích thước v x v trong đó v là số lượng các đỉnh trong biểu đồ. Đặt mảng 2D là adj [] [], một khe adj [i] [j] = 1 chỉ ra rằng có một cạnh từ đỉnh i đến đỉnh j. Ma trận liền kề cho một biểu đồ không mong muốn luôn đối xứng. Ma trận liền kề cũng được sử dụng để biểu thị các biểu đồ có trọng số. Nếu adj [i] [j] = w, thì có một cạnh từ đỉnh i đến đỉnh j với trọng lượng w. & Nbsp; Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02. Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022377736 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks379 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221382 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks384 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks387 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})7 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True41 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks379 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks396 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1398 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks399 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks404 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks406 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022401409 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02214122 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221419 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks399 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks424 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks426 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks431 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks434 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks436 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks439 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221442 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks444 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221447 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks444 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks452 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks461 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks465 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1488 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')42 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks494 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks496 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks498 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks500 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks465 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks506 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221512 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks513 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks515 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks44 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks521 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks526 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks531 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks536 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}93 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Các List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks521 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks531 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True87 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks531 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks526 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})89 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks526 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks335 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks536 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks320 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}93 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks345 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks592 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks595 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks598 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks601 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks604 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks607 Đầu ra
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ố lượng đỉnh. Đặt mảng là một mảng []. Một mảng mục [i] đại diện cho danh sách các đỉnh liền kề với đỉnh ith. Biểu diễn này cũng có thể được sử dụng để thể hiện một biểu đồ có trọng số. Các 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 biểu đồ trên. & NBSP; Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks609 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221617 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks619 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022____1635 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks637 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1640 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})79 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True41 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks647 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks650 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks656 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks658 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks662 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221665 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks667 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks671 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks658 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks677 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221680 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks667 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks685 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks699 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s11 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks701 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks702 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []27 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}31 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks709 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks712 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks716 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s11 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks701 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks719 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []27 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}31 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}444 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks730 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')71 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks736 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks739 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks743 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks745 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 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 True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 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 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 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'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 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 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 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 True9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747 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 True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks789 Đầu ra List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks9 Đồ thị truyền tảiTìm kiếm đầu tiên hoặc BFSĐường ngang đầu tiên cho một biểu đồ tương tự như đường truyền đầu tiên của cây. Việc bắt duy nhất ở đây là, không giống như các biểu đồ, đồ thị có thể chứa các chu kỳ, vì vậy chúng ta có thể đến 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, người ta cho rằng tất cả các đỉnh có thể tiếp cận được từ đỉnh bắt đầu. Ví dụ, trong biểu đồ sau, chúng ta bắt đầu truyền từ Vertex 2. Khi chúng ta đến Vertex 0, chúng ta tìm kiếm tất cả các đỉnh liền kề của nó. 2 cũng là một đỉnh liền kề là 0. Nếu chúng ta 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. Một đường ngang đầu tiên của biểu đồ sau là 2, 0, 3, 1. Python3List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks790 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks791 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True60 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks793 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04______5022 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks810 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks815 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks818 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks8222 ____36 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks825 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})79 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True41 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')21 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9__ Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]20 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks841 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks843 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks845 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks848 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks850 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks168 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks857 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks869 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks825 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')42 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks875 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')42 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks869 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks845 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks880 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks882 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 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 True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 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 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 True9 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 True9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 True9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks915 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks917 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks919 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Đầu ra Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 40 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks9 Đồ thị truyền tảiTìm kiếm đầu tiên hoặc BFS Algorithm:
Python3List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks790 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks791 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True60 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks793 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})97 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04______5022 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks810 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks815 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks950 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks954 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks957 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]81 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks963 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks963 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks972 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks975 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks978 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks8222 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks988 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks880 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks882 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 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 True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 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 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 True9 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 True9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883 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 True9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4024 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4026 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Đầu ra Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 41 Thêm các bài viết về đồ thị
>>> Thêm Đệ quyQuá trình trong đó một hàm tự gọi 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à các tòa tháp của Hà Nội (TOH), các lần đi qua cây trước/đặt hàng/bưu điện, DF của đồ thị, 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. & NBSP; Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 42 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 một trường hợp cơ sở nhỏ hơn. 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ỳ hàm nào được gọi từ main (), bộ nhớ được phân bổ cho nó trên ngăn xếp. Một hàm đệ quy tự gọi, bộ nhớ cho một hàm được gọi là được phân bổ trên đầu 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 cuộc gọi hàm. Khi đạt được trường hợp cơ sở, hàm trả lại giá trị của nó cho chức năng mà nó được gọi là và bộ nhớ được phân bổ và quá trình tiếp tục. Chúng ta hãy lấy ví dụ về cách thức đệ quy hoạt động bằng cách lấy một chức năng đơn giản. & Nbsp; Python3Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4030 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4033 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4043 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4048 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4051 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4043 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4060 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4063 Ngăn xếp bộ nhớ đã được hiển thị trong sơ đồ dưới đây. Nhiều bài viết về đệ quy
>>> Thêm Đệ quyQuá trình trong đó một hàm tự gọi 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à các tòa tháp của Hà Nội (TOH), các lần đi qua cây trước/đặt hàng/bưu điện, DF của đồ thị, 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. & NBSP;
Khi bất kỳ hàm nào được gọi từ main (), bộ nhớ được phân bổ cho nó trên ngăn xếp. Một hàm đệ quy tự gọi, bộ nhớ cho một hàm được gọi là được phân bổ trên đầu 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 cuộc gọi hàm. Khi đạt được trường hợp cơ sở, hàm trả lại giá trị của nó cho chức năng mà nó được gọi là và bộ nhớ được phân bổ và quá trình tiếp tục.Chúng ta hãy lấy ví dụ về cách thức đệ quy hoạt động bằng cách lấy một chức năng đơn giản. & Nbsp; Hãy để mô tả một trạng thái cho vấn đề DP của chúng tôi 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 tôi. Vì vậy, & nbsp; chúng ta cần tìm giá trị của trạng thái đích i.e dp [n]. Nếu chúng tôi bắt đầu chuyển đổi từ trạng thái cơ sở của chúng tôi, tức là DP [0] và tuân theo mối quan hệ chuyển đổi trạng thái của chúng tôi để đạt đến trạng thái đích của chúng tôi trạng thái cơ sở dưới cùng và đạt đến 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 thức lập bảng? Để biết điều này, trước tiên, hãy viết một số mã để tính toán 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, một lần nữa là 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 định nghĩa một trạng thái là dp [x], trong đó dp [x] là tìm giai đoạn của x. Bây giờ, rõ ràng là dp [x+1] = dp [x] * (x+1) Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 43 Ghi nhớMột lần nữa, một lần nữa, hãy để mô tả nó về mặt chuyển đổi nhà nước. Nếu chúng ta cần tìm giá trị cho một số trạng thái nói dp [n] và thay vì bắt đầu từ trạng thái cơ sở mà tức là dp [0] chúng ta hỏi câu trả lời của chúng ta từ các trạng thái có thể đến trạng thái đích DP [n] sau khi chuyển đổi trạng thái Mối quan hệ, sau đó nó là thời trang từ trên xuống của DP. Tại đây, chúng tôi bắt đầu hành trình từ trạng thái đích nhất hàng đầu và tính toán câu trả lời của nó bằng cách đếm các 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ở dưới cùng. Một lần nữa, hãy để viết mã cho vấn đề giai thừa theo kiểu từ trên xuống Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 44 Nhiều bài viết về lập trình động
>>> Thêm Thuật toán tìm kiếmTìm kiếm tuyến tính
Python3Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4065 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4076 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4079 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')45 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4087 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 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 True9 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 True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks53 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks335 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})7 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 True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks553 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4107 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4109 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4111 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4120 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4127 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4128 Đầu ra Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 45 Độ phức tạp thời gian của thuật toán trên là o (n). & Nbsp; Để biết thêm thông tin, hãy tham khảo tìm kiếm tuyến tính. Tìm kiếm nhị phânTìm kiếm một mảng được sắp xếp bằng cách liên tục chia khoảng thời gian tìm kiếm làm đôi. Bắt đầu với một khoảng 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 vào nửa dưới. Nếu không, thu hẹp nó xuống nửa trên. Nhiều lần kiểm tra cho đến khi giá trị được tìm thấy hoặc khoảng thời gian trống. Python3Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4130 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4133 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4135 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4137 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4139__1833 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4149 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4152 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4155 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks289 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4158 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4161 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4164 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4170 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4173 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4087 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4183 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 True9 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 True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks53 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks335 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})7 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 True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks553 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4107 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4109 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4111 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4120 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Đầu ra Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 46 Độ phức tạp thời gian của thuật toán trên là o (n). & Nbsp; Để biết thêm thông tin, hãy tham khảo tìm kiếm tuyến tính. Tìm kiếm nhị phânTìm kiếm một mảng được sắp xếp bằng cách liên tục chia khoảng thời gian tìm kiếm làm đôi. Bắt đầu với một khoảng 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 vào nửa dưới. Nếu không, thu hẹp nó xuống nửa trên. Nhiều lần kiểm tra cho đến khi giá trị được tìm thấy hoặc khoảng thời gian trống.Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4130 Lưu đồ của loại lựa chọn: & nbsp;Python3Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True60 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4227 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4228 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4231 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 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'})57 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 True95____39 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True91____47 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 42247 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')45 Is Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4265 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4269 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4271 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4273 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4276 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 42247 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')45 Is Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 47
Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4271Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4273Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4276 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Python3Đầu ra Độ phức tạp về thời gian: O (N2) vì có hai vòng lồng nhau. Không gian phụ trợ: O (1) & NBSP; 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 liên tục hoán đổi các phần tử liền kề nếu chúng theo thứ tự sai. Minh họa: & nbsp; Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4292 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4350 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4303 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9__92311111118 Is Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 48
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4269Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4271 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4273
Illustration: Python3Độ phức tạp về thời gian: O (N2) vì có hai vòng lồng nhau. Không gian phụ trợ: O (1) & NBSP; 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 liên tục hoán đổi các phần tử liền kề nếu chúng theo thứ tự sai. Minh họa: & nbsp; Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4292 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4303 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9__92311111118 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4429 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4303 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9__92311111118
CácTuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4087 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4231 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4338 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 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'})57____39 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True95 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 True91 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 49 Python3Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4353 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4361 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4288 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4217 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4367 Độ phức tạp về thời gian: O (N2) Sắp xếp chèn Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4468 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4470 Để sắp xếp một mảng kích thước N theo thứ tự tăng dần bằng cách sử dụng sắp xếp chèn: Lặp 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 người tiền nhiệm của nó. Nếu phần tử chính nhỏ hơn người 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 một vị trí lên để tạo không gian cho phần tử hoán đổi. Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4369 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')28 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 True8 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__7979 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4381 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4383 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')45 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4392 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4395 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4396 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4398 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 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'})79 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4403 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4485 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4487 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4492 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4506 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4485 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4487 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4492 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4506 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4567 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4556 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4599 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4600 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4602 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4605 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4607 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4611 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4600 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4602 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4605
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True0
CácĐầu ra Độ phức tạp về thời gian: O (n (logn))
Luôn chọn phần tử cuối cùng làm trục (được triển khai bên dưới) Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True1 Chọn một yếu tố ngẫu nhiên làm trục. Chọn trung bình làm trục. Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True1 Python3Quá trình chính trong QuickSort là phân vùng (). Mục tiêu của các phân vùng là, được đưa ra một mảng và phần tử x của mảng làm trục, đặt x ở vị trí chính xác của nó trong mảng được 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 x. Tất cả điều này nên được thực hiện trong thời gian tuyến tính. Thuật toán phân vùng Có thể có nhiều cách để thực hiện phân vùng, theo mã giả áp dụng phương thức được đưa ra trong 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ỉ mục của các phần tử nhỏ hơn (hoặc bằng) như i. Trong khi đi qua, nếu chúng ta tìm thấy một phần tử nhỏ hơn, chúng ta trao đổi phần tử hiện tại với ARR [i]. Nếu không, chúng ta bỏ qua phần tử hiện tại. & NBSP; Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4619 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4621 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4623 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4625 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4627 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4630 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4633 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97__ Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4655 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4641 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4647 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4649 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4657 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4659 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4661 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4663 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4666 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4668 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4655 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4673 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4675 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 46777____108 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4680 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4710 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4711 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True3
CácĐầu ra Python3Độ phức tạp về thời gian: O (n (logn)) Sắp xếp nhanh chóng Giống như Merge sắp xếp, Quicksort là một thuật toán phân chia và chinh phục. Nó chọn một phần tử làm trục và phân vùng mảng đã cho xung quanh trục đượ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 (đượ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 bình làm trục. Quá trình chính trong QuickSort là phân vùng (). Mục tiêu của các phân vùng là, được đưa ra một mảng và phần tử x của mảng làm trục, đặt x ở vị trí chính xác của nó trong mảng được 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 x. Tất cả điều này nên được thực hiện trong thời gian tuyến tính. Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Thuật toán phân vùng Có thể có nhiều cách để thực hiện phân vùng, theo mã giả áp dụng phương thức được đưa ra trong 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ỉ mục của các phần tử nhỏ hơn (hoặc bằng) như i. Trong khi đi qua, nếu chúng ta tìm thấy một phần tử nhỏ hơn, chúng ta trao đổi phần tử hiện tại với ARR [i]. Nếu không, chúng ta bỏ qua phần tử hiện tại. & NBSP; Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4619 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4621 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4623 Creating Bytearray: bytearray(b'\x0c\x08\x19\x02') Accessing Elements: 8 After Modifying: bytearray(b'\x0c\x03\x19\x02') After Adding Elements: bytearray(b'\x0c\x03\x19\x02\x1e')34 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476 List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8 Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4716 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4144 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 41444____36 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})0 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4794 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})57 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4338 Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4801 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 True9 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})2 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4809 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4810 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4811 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})8 Normal Set {'a', 'b', 'c'} Frozen Set frozenset({'f', 'g', 'e'})9 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4814 Tuple with the use of String: ('Geeks', 'For') Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4810 Đầu ra Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True4 Độ phức tạp về thời gian: & nbsp; O (n2). & Nbsp; O(n2). Tôi có thể sử dụng Python cho các cấu trúc dữ liệu và thuật toán không?Trong các cấu trúc và thuật toán dữ liệu này thông qua khóa học sâu, các chương trình Python được sử dụng để thực hiện các khái niệm khác nhau, nhưng bạn có thể dễ dàng mã hóa chúng bằng bất kỳ ngôn ngữ lập trình nào khác như C ++, Java hoặc C#.Python programs are used for implementing various concepts, but you can easily code them in any other programming language like C++, Java or C#.
4 cấu trúc dữ liệu trong Python là gì?Các cấu trúc dữ liệu Python cơ bản trong Python bao gồm danh sách, bộ, bộ dữ liệu và từ điển.Mỗi cấu trúc dữ liệu là duy nhất theo cách riêng của nó.Cấu trúc dữ liệu là các container của người Viking, tổ chức và nhóm dữ liệu theo loại.list, set, tuples, and dictionary. Each of the data structures is unique in its own way. Data structures are “containers” that organize and group data according to type.
Thuật toán nào được sử dụng trong Python?Thuật toán hàng xóm gần nhất Thuật toán hàng xóm K-Newest (KNN) là một thuật toán đơn giản và hiệu quả có thể được sử dụng để giải quyết cả các vấn đề phân loại và hồi quy.
The k-nearest neighbor (KNN) algorithm is a simple and efficient algorithm that can be used to solve both classification and regression problems. |