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.
Danh sách
Danh 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 Python
Python3
Is
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 Python
Python3
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
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
Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
8Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
9Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
5Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
1To create a tuple of one element there must be a trailing comma. For example, [8,] will create a tuple containing 8 as the element.
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
True
6 [[ 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
True
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]]
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
Python3
Tuple
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
Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
8Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
9Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
5Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
1
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
True
6 [[ 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
True
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]]
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
Tuple
Python3
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
Tuple with 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 Python
Python3
Tuple with 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ây
Chuỗi Python là mảng byte bất biến đại diện cho các ký tự Unicode. Python không có kiểu dữ liệu ký tự, một ký tự 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 Python
Python3
Tuple with 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ây
Chuỗi Python là mảng byte bất biến đại diện cho các ký tự Unicode. Python không có kiểu dữ liệu ký tự, một ký tự 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.
Python3
Ví 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ây
Chuỗi Python là mảng byte bất biến đại diện cho các ký tự Unicode. Python không có kiểu dữ liệu ký tự, một ký tự 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.
Python3
Ví 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ây
Chuỗi Python là mảng byte bất biến đại diện cho các ký tự Unicode. Python không có kiểu dữ liệu ký tự, một ký tự 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.
Python3
Ví 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ây
Chuỗi Python là mảng byte bất biến đại diện cho các ký tự Unicode. Python không có kiểu dữ liệu ký tự, một ký tự 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.
- Dữ liệu
- Con trỏ [hoặc tham chiếu] đến nút tiếp theo
Ví dụ: Xác định danh sách được liên kết trong Python
Python3
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
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.
Python3
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
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
4
21Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
86Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12 Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
89
Tuple with 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
Python3
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
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
4
21Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
86Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12 Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
89
Tuple with 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
21Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
91Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
12Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
94- Danh sách liên kết Traversal & NBSP;
- Trong chương trình trước, chúng tôi đã tạo một danh sách liên kết đơn giản với ba nút. Hãy để chúng tôi đi qua danh sách được tạo và in dữ liệu của từng nút. Đối với Traversal, chúng ta hãy viết một danh sách in chức năng đa năng [] in bất kỳ danh sách nào.
Tuple with 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
21Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
00Creating 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}
27Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
0221Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
31Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
022Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
36Creating 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}
37Creating 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}
38Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Creating 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}
40
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}
38Creating 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}
31Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 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}
444Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12
Thêm các bài viết trong danh sách được liên kết
Liê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]
- Xóa danh sách được liên kết [xóa khóa ở vị trí đã cho] Returns whether the stack is empty – Time Complexity: O[1]
- Tìm độ dài của một danh sách được liên kết [lặp và đệ quy] Returns the size of the stack – Time Complexity: O[1]
- Tìm kiếm một phần tử trong danh sách được liên kết [lặp và đệ quy] Returns a reference to the topmost element of the stack – Time Complexity: O[1]
- Nút thứ n từ cuối danh sách được liên kết Inserts the element ‘a’ at the top of the stack – Time Complexity: O[1]
- Đảo ngược một danh sách được liên kết Deletes the topmost element of the stack – Time Complexity: O[1]
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à:
- trống [] - Trả về liệu ngăn xếp có trống - độ phức tạp về thời gian: O [1]
- Kích thước [] - Trả về kích thước của độ phức tạp của Stack - Thời gian: O [1]
- top [] - Trả về một tham chiếu đến phần tử trên cùng của độ phức tạp của ngăn xếp - thời gian: O [1]
- Đẩy [A] - Chèn phần tử ’A ở đầu ngăn xếp - Độ phức tạp về thời gian: O [1]
- pop [] - Xóa phần tử trên cùng của độ phức tạp của Stack - Thời gian: O [1]
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}
86Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating 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}
88Creating 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}
89Creating 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}
93Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1
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}
38Creating 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}
31Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 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}
444Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12
Thêm các bài viết trong danh sách được liên kết
Liê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]
- Xóa danh sách được liên kết [xóa khóa ở vị trí đã cho] Adds an item to the queue. If the queue is full, then it is said to be an Overflow condition – Time Complexity: O[1]
- Dequeue: Loại bỏ một mục khỏi hàng đợi. Các mục được xuất hiện theo cùng một thứ tự mà chúng được đẩy. Nếu hàng đợi trống, thì nó được cho là điều kiện dòng chảy - Độ phức tạp về thời gian: O [1] Removes an item from the queue. The items are popped in the same order in which they are pushed. If the queue is empty, then it is said to be an Underflow condition – Time Complexity: O[1]
- Mặt trước: Lấy mục trước từ Hàng đợi - Độ phức tạp về thời gian: O [1]Get the front item from queue – Time Complexity: O[1]
- Phía sau: Nhận mục cuối cùng từ Hàng đợi - Độ phức tạp về thời gian: O [1] Get the last item from queue – Time Complexity: O[1]
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
- Thự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
- Thực hiện một ngăn xếp bằng cách sử dụng hàng đợi đơn lẻ
Hàng đợi ưu tiên
Hà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.
Python3
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
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 đợi
Thự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
- Thực hiện một ngăn xếp bằng cách sử dụng hàng đợi đơn lẻ In a Max-Heap the key present at the root node must be greatest among the keys present at all of it’s children. The same property must be recursively true for all sub-trees in that Binary Tree.
- Hàng đợi ưu tiênIn a Min-Heap the key present at the root node must be minimum among the keys present at all of it’s children. The same property must be recursively true for all sub-trees in that Binary Tree.
Python3
Hà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ự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
- Thực hiện một ngăn xếp bằng cách sử dụng hàng đợi đơn lẻ
- Sắp xếp một mảng gần như được sắp xếp
- SUBArray tiếp giáp lớn nhất của K-th
- Tổng tối thiểu của hai số được hình thành từ các chữ số của một mảng
>>> Thêm
Cây nhị phân
Mộ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.
- Dữ liệu
- Con trỏ đến trái con
- Con trỏ đến đúng đứa trẻ
Ví dụ: Xác định lớp nút
Python3
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
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ây
Python3
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
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
Geeks
007Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
70Normal 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
Geeks
006
List containing 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
- 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
Đặt hàng trước [gốc, trái, phải]: 1 2 4 5 3
- Bưu điện [trái, phải, gốc]: 4 5 2 3 1
- Thuật toán inorder [cây]
- Traverse Subtree bên trái, tức là, gọi inorder [bên trái-subtree]
Ghé thăm gốc.
- Thuật toán inorder [cây]
- Traverse Subtree bên trái, tức là, gọi inorder [bên trái-subtree]
- Ghé thăm gốc.
Traverse Subtree bên phải, tức là, gọi Inororder [bên phải-Subtree]
- Đơn đặt hàng trước thuật toán [cây]
- Traverse Subtree bên trái, tức là, gọi đặt hàng trước [bên trái-subtree]
- Thuật toán inorder [cây]
Python3
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
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
Geeks
012Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
70List containing 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
40List containing 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
006
List containing 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
- Đặt hàng trước [gốc, trái, phải]: 1 2 4 5 3
- Bưu điện [trái, phải, gốc]: 4 5 2 3 1
- Thuật toán inorder [cây]
- Traverse Subtree bên trái, tức là, gọi inorder [bên trái-subtree]
- Ghé thăm gốc.
- Traverse Subtree bên phải, tức là, gọi Inororder [bên phải-Subtree]
Python3
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
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
- Chèn vào cây nhị phân
- Xóa trong một cây nhị phân
- Thứ thứ tự truyền tải cây mà không có đệ quy
- Cây thứ tự truyền tải không có đệ quy và không có ngăn xếp!
- In Traversal PostorDeral từ đã đưa ra trước và đặt hàng trước các lần đi qua
- Tìm bưu điện của BST từ Traversal trước khi đặt hàng
>>> Thêm
Cây tìm kiếm nhị phân
Câ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.
- Subtree bên phải của một nút chỉ chứa các nút có các phím lớn hơn phím nút.
- Cây con bên trái và bên phải cũng phải là một cây tìm kiếm nhị phân.
Các thuộc tính trên của cây tìm kiếm nhị phân cung cấp 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
- Bắt đầu từ gốc.
- So sánh phần tử tìm kiếm với gốc, nếu ít hơn root, sau đó recurse cho bên trái, khác phục hồi cho bên phải.
- Nếu phần tử để tìm kiếm được tìm thấy ở bất cứ đâu, hãy trả về đúng, nếu không trả về sai.
Python3
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 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;
- Bắt đầu từ gốc.
- So sánh phần tử tìm kiếm với gốc, nếu ít hơn root, sau đó recurse cho bên trái, khác phục hồi cho bên phải.
- Nếu phần tử để tìm kiếm được tìm thấy ở bất cứ đâu, hãy trả về đúng, nếu không trả về sai.
Python3
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 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 bài viết về cây nhị phân
- Chèn vào cây nhị phân
- Xóa trong một cây nhị phân
- Thứ thứ tự truyền tải cây mà không có đệ quy
- Cây thứ tự truyền tải không có đệ quy và không có ngăn xếp!
>>> Thêm
Cây tìm kiếm nhị phân
Câ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ề
- Danh sách kề
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;
Python3
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: 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
Các đỉnh của đồ thị
.
Các cạnh của đồ thị
[['A', 'C', 20], ['A', 'E', 10], ['B', 'C', 30], ['B', 'E', 40], [ 'c', 'a', 20], ['c', 'b', 30], ['d', 'e', 50], ['e', 'a', 10], ['e ',' B ', 40], [' e ',' d ', 50], [' e ',' f ', 60], [' f ',' e ', 60]]
Ma trận kề của đồ thị
[[-1, -1, 20, -1, 10, -1], [-1, -1, 30, -1, 40, -1], [20, 30, -1, -1, -1 , -1], [-1, -1, -1, -1, 50, -1], [10, 40, -1, 50, -1, 60], [-1, -1, -1, -1, 60, -1]]]
Danh sách kề
Một mảng danh sách được sử dụng. Kích thước của mảng bằng số 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;
Python3
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 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: s022____1665
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ải
Tì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.
Python3
List containing 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ải
Tìm kiếm đầu tiên hoặc BFS
Algorithm:
- Đườ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.
List containing 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
790List containing 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
791Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
60List containing 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
793
Python3
List containing 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ị
- Biểu đồ biểu đồ bằng cách sử dụng tập hợp và băm
- Tìm mẹ đỉnh trong đồ thị
- Độ sâu tìm kiếm đầu tiên
- Đếm số lượng nút ở mức nhất định trong cây bằng cách sử dụng BFS
- Đếm tất cả các đường dẫn có thể giữa hai đỉnh
>>> Thêm
Đệ quy
Quá 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 > Thêm
Đệ quy
Quá 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;
- Trong ví dụ trên, trường hợp cơ sở cho n >> Thêm
Thuật toán tìm kiếm
Tìm kiếm tuyến tính
- Bắt đầu từ phần tử ngoài cùng bên trái của ARR [] và từng người một so sánh x với mỗi phần tử của ARR []
- Nếu x khớp với một phần tử, hãy trả về chỉ mục.
- Nếu X không phù hợp với bất kỳ yếu tố nào, hãy trả về -1.
Python3
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
00Tuple with 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
065Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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: s
04Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
076Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
079Creating 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]]
80Creating 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']
45Tuple with 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
21[[ 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]]
80List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Tuple with 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
087Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
7Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
0Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
2Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9List containing 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
40Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9List containing 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
53Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9List containing 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
335Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
7Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
45Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6List containing 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
553Tuple with 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
103Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6[[ 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]]
97Tuple with 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
106Tuple with 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
107Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
109Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
111Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
21Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
120Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1List containing 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
277Tuple with 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
20Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
127Tuple with 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
128Đầ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
5Độ 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ân
Tì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.
Python3
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
00Tuple with 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
130Tuple with 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
21Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
133Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
135Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
137Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
139__1833Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
149Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
152Creating 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]]
80Tuple with 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
155Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04List containing 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
289Tuple with 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
158Creating 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]]
80Tuple with 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
161List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Tuple with 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
164Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04List containing 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
277Tuple with 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
20Creating 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]]
80Tuple with 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
170List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Tuple with 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
173Tuple with 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
21List containing 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
277Tuple with 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
20Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04[[ 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]]
80List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Tuple with 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
087Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
183Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
0Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
2Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9List containing 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
40Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9List containing 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
53Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9List containing 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
335Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
7Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
45Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6List containing 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
553Tuple with 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
103Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6[[ 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]]
97Tuple with 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
106Tuple with 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
107Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
109Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
111Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
21List containing 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
277Tuple with 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
20Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
120Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Đầ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
6Độ 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ân
Tì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: s
00Tuple with 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
130Lưu đồ của loại lựa chọn: & nbsp;
Python3
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
60Tuple with 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
227Tuple with 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
228Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
7Tuple with 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
231Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
61Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
57Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
95____39Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
91____47Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal 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]]
97Tuple with 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
2247Tuple with 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
21Tuple with 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
249Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating 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']
45Is
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
265Creating 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 4
249Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
269Tuple with 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
21Tuple with 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
271Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
273Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
276Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal 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]]
97Tuple with 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
2247Tuple with 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
21Tuple with 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
249Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating 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']
45Is
Tuple with 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
7Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
265 O[n2] as there are two nested loops.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 4
249Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
269 O[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 4
21Tuple with 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
271Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
273Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
276Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
288Tuple with 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
217Tuple with 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
290Python3
Đầ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: s
00Tuple with 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
292Tuple with 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
350Tuple with 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
21Tuple with 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
103Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6[[ 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]]
97Tuple with 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
106Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Tuple with 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
303Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
16List containing 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
478Tuple with 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
18Creating 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']
28Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9__92311111118Is
Tuple with 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
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
265O[n2]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 4
249Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
269Tuple with 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
21Tuple with 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
271Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
273Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
276Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
288Tuple with 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
217Tuple with 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
290- Đầu ra
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: s
00Tuple with 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
292Tuple with 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
21Tuple with 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
103Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6[[ 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]]
97Tuple with 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
106Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Tuple with 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
303Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
16List containing 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
478Tuple with 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
18Creating 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']
28Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9__92311111118Tuple with 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
429Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Tuple with 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
303Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
16List containing 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
478Tuple with 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
18Creating 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']
28Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9__92311111118Creating 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}
38Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
319List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Tuple with 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
322 O[n2]]Các
Tuple with 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
087Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
7Tuple with 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
231Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Tuple with 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
338Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
61Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
57____39Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
95Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
91Tuple with 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
9Python3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
353Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal 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]]
97Tuple with 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
361Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
288Tuple with 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
217Tuple with 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
367Độ 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: s
04Tuple with 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
468Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
470Để 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: s
00Tuple with 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
369Creating 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}
38List containing 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
277Tuple with 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
20Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9__7979Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
381Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
383Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04List containing 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
478Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating 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']
45List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
36Tuple with 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
392Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []
2Tuple with 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
395Tuple with 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
396Creating 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']
34Tuple with 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
398List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
79Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
403Creating 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 4
17List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating 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 4
476List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
36Tuple with 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
485[[ 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]]
97Tuple with 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
487Creating 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 4
492Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
506Creating 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}
38List containing 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
478List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating 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 4
476List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
36Tuple with 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
485[[ 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]]
97Tuple with 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
487Creating 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 4
492Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
506Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Tuple with 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
567Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
25Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Tuple with 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
28Creating 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}
38List containing 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
478List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
00Tuple with 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
556Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
599Tuple with 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
600Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
602Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
21Tuple with 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
605Tuple with 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
21Tuple with 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
607Tuple with 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
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
611Tuple with 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
600Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
602Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
21Tuple with 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
605Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal 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]]
97Tuple with 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
361Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
0Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Creating 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']
71Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
61Tuple with 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
20 O[n[logn]]Các
Đầu ra
Độ 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]
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
1Chọ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 True
1Python3
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.
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 hoán đổ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: s
00Tuple with 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
619Tuple with 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
21Tuple with 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
621Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
623Tuple with 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
21Tuple with 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
625Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
627Tuple with 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
21Creating 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}
36Tuple with 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
630Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
36Tuple with 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
633[[ 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: s
04Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
655Creating 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 4
641List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating 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}
36Tuple with 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
647Creating 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 4
649List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating 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 4
657Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
659Tuple with 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
21Tuple with 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
661Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
663Tuple with 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
21[[ 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]]
80Tuple with 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
666Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
00Tuple with 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
668Tuple with 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
21Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Tuple with 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
655Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
673Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
675Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
6777____108Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Tuple with 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
680Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Tuple with 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
710Tuple with 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
711Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with 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
21Tuple with 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
16Tuple with 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
17Tuple with 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
18Creating 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']
28Normal 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]]
97Tuple with 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
361Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
3Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
57Creating 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']
71Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
61Tuple with 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
20O[n[logn]]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}
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 4
17List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating 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}
38List containing 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
478List containing 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
833Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Thuậ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 hoán đổ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: s
00Tuple with 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
619Tuple with 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
21Tuple with 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
621Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Tuple with 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
623Creating 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']
34Tuple with 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
476List containing 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
08Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
8Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Tuple with 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
716Tuple with 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
144Tuple with 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
1444____36Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
0Tuple with 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
794Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
7Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
57Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Tuple with 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
338Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Tuple with 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
801Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
0Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
9Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
2Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
809Tuple with 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
810Tuple with 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
811Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with 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
814Tuple with 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
810Đầ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
4Độ 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 dữ liệu này và thuật toán thông qua khóa học về Python, 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ó.list, set, tuples, and dictionary. Each of the data structures is unique in its own way.Có bao nhiêu cấu trúc dữ liệu và thuật toán trong Python?
Có bốn loại cấu trúc dữ liệu tích hợp trong Python: List, Tuple, Set và Dictionary.Một danh sách được xác định bằng dấu ngoặc vuông và giữ dữ liệu được phân tách bằng dấu phẩy.Danh sách là có thể thay đổi và đặt hàng.Nó có thể chứa một hỗn hợp của các loại dữ liệu khác nhau.four types of built-in data structures in Python: list, tuple, set, and dictionary. A list is defined using square brackets and holds data that is separated by commas. The list is mutable and ordered. It can contain a mix of different data types.Mất bao lâu để học DSA trong Python?
Mất bao lâu để học DSA?DSA đòi hỏi một khoản đầu tư đáng kể về thời gian và công sức.Nó có thể đưa bạn bất cứ nơi nào từ 4-8 tháng để thực sự làm chủ nó.4-8 months to truly master it.