Hướng dẫn data structures and algorithms python - cấu trúc dữ liệu và thuật toán python

Hướng dẫn này là một hướng dẫn thân thiện với người mới bắt đầu để học các cấu trúc dữ liệu và thuật toán sử dụng Python. Trong bài viết này, chúng tôi sẽ thảo luận về các cấu trúc dữ liệu được xây dựng như danh sách, bộ dữ liệu, từ điển, v.v. và một số cấu trúc dữ liệu do người dùng xác định Với sự giúp đỡ của các ví dụ tốt và được giải thích tốt và các câu hỏi thực hành.

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 
True
5
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

Đầ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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
7
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
7
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9__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: 
s
1

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 
True
5
Creating 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}
9
Set 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]]
2
Set 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

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: 
s
1

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: 
s
1

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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
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
Geeks
02
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
List containing 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
08
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
List containing 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
08
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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
7
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
7
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9__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
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
5
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1
To 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}
9
Set 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]]
2
Set 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
Geeks
27
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
18
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
48
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
56
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
18
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
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
Geeks
66
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
18
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
List containing 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
08
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
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
Geeks
77
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
18
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
List containing 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
08
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 
True
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
7
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
5
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
7
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9__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
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
5
Creating 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}
9
Set 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]]
2
Set 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
4
06
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
86
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
14
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
21
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
4
23
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
25
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
28

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
4
35
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
88
List containing 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
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
39
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
41
Tuple with 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
424243
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
4
47
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
50

Tuple with 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
51
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
53
List containing 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
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
55
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
57
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
9
Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
59
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
4
63
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
66

Đầ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
4
67
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
69

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
4
72
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
75

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
4
78
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
81
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
4
86
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
81
List containing 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
08
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
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 
True
12
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
93
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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 
True
20
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
4
93
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
Tuple with 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
96
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
4
67
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
69

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
4
93
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

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

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

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 
True
59

Đầ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
4
67
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
69

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: 
s
1

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 
True
8
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: 
s
1

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
4
93
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
95
Tuple with 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
96
Tuple with 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
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]]
2
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

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

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

Elements of set: 
1 2 4 6 For Geeks 
True
8____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: 
s
1

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: 
s
1

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 
True
8
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
4
67
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
69

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: 
s
1

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: 
s
1

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: 
s
1

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
06
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
08

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
025____511
Creating 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
14

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: 
s
16

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0224524____36
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
06
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
08

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
025____511
Creating 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
14

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: 
s
16

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0224524____36
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

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: 
s
57
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
58
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
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
61
Tuple with 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

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
64
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
66

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
68
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
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
74
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
70
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: 
s
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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
80
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
70
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: 
s
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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
86
Creating 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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
91
Creating 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
94

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
06
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
08

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
025____511
Creating 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
14

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: 
s
16

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0224524____36
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

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: 
s
57
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
58
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
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
61
Tuple with 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

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
64
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
66

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
68
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
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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: 
s
57
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
58
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
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
61
Tuple with 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

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
64
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
66

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
68
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
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
74
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
70
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: 
s
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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
80
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
70
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: 
s
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
21
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
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
86
Creating 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
    21
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    91
    Creating 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
    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
    21
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    00
    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}
    27
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    0221
  • Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    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 
    True
    6
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    022
  • Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    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
    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}
    37
  • 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
    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}
    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}
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 
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}
444
Creating 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: 
s
1

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: 
s
1

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: 
s
1

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: 
s
1

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: 
s
1

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}
    86
    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 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 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}
    93
    Creating 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}
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 
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}
444
Creating 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 
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}
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: 
s
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]]
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: 
s
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]]
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: 
s
1

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: 
s
1

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: 
s
1

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 
True
37

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 
True
37

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 
True
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]]
56
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
0

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: 
s
21

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0225771
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 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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
[[ 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: 
s
0221

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
[[ 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: 
s
0221

Creating 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]]
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: 
s
02.

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
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: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
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: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
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
4
20

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 
True
6
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
4
16
Tuple with 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
17
Tuple with 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
18
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: 
s
022

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: 
s
57
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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: 
s
02
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 
True
6
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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: 
s
02
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: 
s
04
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
4
28

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: 
s
57
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 
True
6
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
61
Tuple with 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

Tuple with 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
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
4
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']
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: 
s
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
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']
81
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
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']
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: 
s
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
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']
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: 
s
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
21
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
4
21
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: 
s
04
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
Geeks
1

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: 
s
21

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

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
Geeks
40
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0225771
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 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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0225771
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 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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
[[ 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: 
s
0221

Đầ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
2

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
Geeks
3

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
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
Geeks
4

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
0022____36
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
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
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
Geeks
007
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
70
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
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
Geeks
012
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
70
List containing 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
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
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
Geeks
5

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
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: 
s
04
List containing 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
045

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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
050

List containing 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
0022____36
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
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
Geeks
006

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: 
s
04
List containing 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
057

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
059

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
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
Geeks
048

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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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: 
s
04
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
Geeks
048

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
072

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
074

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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
0022____36
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
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
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
Geeks
007
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
70
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
Geeks
006

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
Geeks
102
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
104

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
Geeks
107
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
109

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
Geeks
112
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
114

List containing 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
012
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
70
List containing 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
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
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
Geeks
6

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
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: 
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]]
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
4
21
List containing 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
152

Tuple with 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
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
Geeks
157
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: 
s
21

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
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
Geeks
162
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
Geeks
164

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
166
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
168
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: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
List containing 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
173
List containing 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
142
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: 
s
14
Tuple with 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

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
Geeks
179

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
List containing 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
182
List containing 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
142
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: 
s
14
Tuple with 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

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
Geeks
188

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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
70
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
080
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
70
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: 
s
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
085
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
70
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: 
s
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
012
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
70
List containing 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
40
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
095
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
70
List containing 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
42
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
216
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
218

Đầ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
7

Độ 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: 
s
00
List containing 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
220

Is

Creating 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]]
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
Geeks
233

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
List containing 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
236

Creating 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]]
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
Geeks
239

Tuple with 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]]
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
Geeks
242

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: 
s
00
List containing 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
220

Is

Creating 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]]
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
Geeks
233

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
List containing 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
236

Creating 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]]
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
Geeks
239

Tuple with 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]]
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
Geeks
242

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
4
21
List containing 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
277
Tuple with 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

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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
277
Tuple with 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

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
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 
True
6
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: 
s
00
List containing 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
266

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
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
Geeks
142
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14
Tuple with 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

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
311

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
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
Geeks
314

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
316

Creating 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]]
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
Geeks
275

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
List containing 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
227
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
230

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
Geeks
233

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
289
List containing 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
236

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
Geeks
085
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
294

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
Geeks
080
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
301

Tuple with 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]]
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
Geeks
233

List containing 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
352

Đầ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
8

Độ 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
Geeks
354

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02.

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022377736
List containing 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
379

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221382
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
384

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
387
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
7
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 
True
41
List containing 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
379

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
396
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022 ____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
Geeks
399
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
21

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
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
Geeks
404
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
406
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
022401409

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: 
s
02214122

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: 
s
0221419
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
399

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
424
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
426
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
431
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
02
List containing 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
434

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
436
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
02
List containing 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
439

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221442
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
444

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221447
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
444

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
452
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating 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]]
80
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
461
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
465
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 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: 
s
04
Tuple with 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
16
Tuple with 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
17
Tuple with 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
18
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: 
s
022

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
4
16
List containing 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
478
Tuple with 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
18
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: 
s
022

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: 
s
57
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: 
s
022 ____1488
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
08
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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']
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
Geeks
494
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
496
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
498
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
500

Creating 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]]
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
Geeks
465

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
506
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating 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]]
80
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221512

List containing 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
513
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
515
List containing 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
44
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
518
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
4
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
Geeks
521
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
518
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
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
4
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
Geeks
526
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
518
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
4
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
Geeks
531
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
518
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
4
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
Geeks
536
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
518
List containing 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
40
Tuple with 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
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
Geeks
541
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
518
List containing 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
42
Tuple with 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
42
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: 
s
1

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
Geeks
548
List containing 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
521
Tuple with 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
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
Geeks
531
Tuple with 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
42
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
87
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
548
List containing 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
531
Tuple with 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
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
Geeks
526
Tuple with 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
42
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: 
s
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
548
List containing 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
526
Tuple with 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
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
Geeks
541
Tuple with 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
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
Geeks
335
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
548
List containing 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
541
Tuple with 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
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
Geeks
536
Tuple with 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
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
Geeks
320
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
548
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
4
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
Geeks
541
Tuple with 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
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
Geeks
345
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
592
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
595

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
Geeks
598
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
601

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
Geeks
604
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

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
Geeks
607

Đầ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
Geeks
609

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221617
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
619

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
025____511
Creating 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
14

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
Geeks
354

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022____1635
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
637

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022 ____1640
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
7
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
14
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 
True
41
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022
List containing 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
647

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
650
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
166
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
656

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
658
Creating 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
02
List containing 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
662

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022____1665
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
667

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
166
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
671

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
658
Creating 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
02
List containing 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
677

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221680
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
667

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
685
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Tuple with 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
16
Tuple with 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
17
Tuple with 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
18
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: 
s
022

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
Geeks
699
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
11
List containing 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
701
List containing 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
702
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
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 
True
6
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
709

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
Geeks
712

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
Geeks
716
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
11
List containing 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
701
List containing 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
719
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
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 
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}
444
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
12

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
Geeks
730
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
57
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 
True
6
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
736
Tuple with 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

Tuple with 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
List containing 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
739
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
42

Tuple with 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
List containing 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
743
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
745

Tuple with 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
List containing 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
747
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 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
List containing 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
747
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 
True
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
Geeks
40
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
List containing 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
747
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

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

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
List containing 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
747
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

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

Frozen Set
frozenset[{'f', 'g', 'e'}]
2
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
List containing 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
747
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
List containing 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
40
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
List containing 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
747
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
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
21
List containing 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
747
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
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
Geeks
40
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
21
List containing 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
789

Đầ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
9

Đồ 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
Geeks
790
List containing 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
791
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
60
List containing 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

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
Geeks
354

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04______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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
810
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
815

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
818
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
8222 ____36
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
7
List containing 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
825
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 
True
41
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: 
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]]
20
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 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: 
s
04
List containing 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
841

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
843
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
845

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
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
Geeks
848

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
Geeks
850
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
168
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
Geeks
857
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
Tuple with 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
25
Creating 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}
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
4
16
Tuple with 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
17
Tuple with 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
18
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

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: 
s
57
List containing 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
869
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
825
Tuple with 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

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
Geeks
875

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
Geeks
869
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
845

List containing 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
880
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
882

List containing 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
883
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 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
883
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 
True
9
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: 
s
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
883
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

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

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
883
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
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
883
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
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
883
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
1

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
Geeks
915

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
Geeks
917
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
919
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: 
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
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
Geeks
9

Đồ 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
    790
    List containing 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
    791
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    60
    List containing 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
Geeks
790
List containing 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
791
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
60
List containing 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

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
Geeks
354

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
01
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
0221

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04______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
4
21
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
810
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
815

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
950
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
954

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
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
Geeks
957
Set 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]]
81
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
1

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Tuple with 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
16
List containing 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
963
Tuple with 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
18
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

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: 
s
57
List containing 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
963
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
4
18
List containing 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
972

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: 
s
02
List containing 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
975

Tuple with 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
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
00
List containing 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
978
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
022

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
List containing 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
8222
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
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
4
28

Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
04
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
02
List containing 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
988

List containing 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
880
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
6
List containing 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
882

List containing 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
883
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 
True
9
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

Elements of set: 
1 2 4 6 For Geeks 
True
8
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
883
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 
True
9
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: 
s
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
883
Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}

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

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

Frozen Set
frozenset[{'f', 'g', 'e'}]
0
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
883
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
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
883
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
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
883
Normal Set
{'a', 'b', 'c'}

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

Elements of set: 
1 2 4 6 For Geeks 
True
9
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: 
s
1

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
4
024
Creating String: 
Welcome to GeeksForGeeks

First character of String is: 
W

Last character of String is: 
s
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
026
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: 
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
1

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
4
2

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
    00
    Tuple with 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
    065

    Tuple with 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
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    076
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    079

    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    38
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    80
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    45

    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    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]]
    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
    Geeks
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    4
    087
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    7
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    0
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    2
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    Geeks
    40
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    Geeks
    53
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    Geeks
    335
    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 
    True
    45
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    List containing 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
    553

    Tuple with 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
    103
    Set 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]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    106

    Tuple with 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
    107
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    109

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    111
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    List containing 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
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    21

    Tuple with 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
    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
    4
    120
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    277
    Tuple with 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

    Tuple with 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
    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
    4
    127
    Tuple with 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
    00
    Tuple with 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
    130

    Tuple with 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
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    133
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    135

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    137
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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__1833

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    149
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    152

    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    38
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    80
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    155

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    List containing 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
    289
    Tuple with 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
    158

    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    38
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    80
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    161
    List containing 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
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    4
    164

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    List containing 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
    277
    Tuple with 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

    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    38
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    80
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    170
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    4
    173

    Tuple with 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
    List containing 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
    277
    Tuple with 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

    Creating 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]]
    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
    Geeks
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    4
    087
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    183
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    0
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    2
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    Geeks
    40
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    Geeks
    53
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    Geeks
    335
    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 
    True
    45
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    List containing 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
    553

    Tuple with 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
    103
    Set 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]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    106

    Tuple with 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
    107
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    109

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    111
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    List containing 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
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    21

    List containing 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
    277
    Tuple with 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

    Tuple with 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
    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
    4
    120
    Creating 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
    00
    Tuple with 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
    130

    Lư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
    60
    Tuple with 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
    227

    Tuple with 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
    228
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    7
    Tuple with 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
    231
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    61
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    57
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    95____39
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    91____47

    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    2247

    Tuple with 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
    Tuple with 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
    249
    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 Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    45

    Is

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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

    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
    4
    249
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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

    Tuple with 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
    Tuple with 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
    271
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    273

    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
    4
    276
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    2247

    Tuple with 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
    Tuple with 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
    249
    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 Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    45

    Is

    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    7

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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}
    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
    4
    249
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    21
    Tuple with 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
    271
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    273

    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
    4
    276
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    21
    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
    4
    288
    Tuple with 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
    217
    Tuple with 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

     

    Python3

    Đầu ra

    Độ phức tạp về thời gian: O [N2] vì có hai vòng lồng nhau.

    Không gian phụ trợ: O [1] & NBSP;

    Sắp xếp bong bóng

    Sắp xếp bong bóng là thuật toán sắp xếp đơn giản nhất hoạt động bằng cách liên tục hoán đổi các phần tử liền kề nếu chúng theo thứ tự sai.

    Minh họa: & nbsp;

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    00
    Tuple with 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
    292

    Tuple with 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
    350

    Tuple with 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
    Tuple with 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
    103
    Set 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]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    106

    Tuple with 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
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    303

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    16
    List containing 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
    478
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9__92311111118

    Is

    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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]

    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
    4
    249
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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

    Tuple with 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
    Tuple with 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
    271
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    273

    • 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
      4
      276
      Creating String: 
      Welcome to GeeksForGeeks
      
      First character of String is: 
      W
      
      Last character of String is: 
      s
      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
      21
      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
      4
      288
      Tuple with 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
      217
      Tuple with 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
    00
    Tuple with 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
    292

    Tuple with 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
    Tuple with 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
    103
    Set 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]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    106

    Tuple with 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
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    303

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    16
    List containing 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
    478
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9__92311111118

    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    429

    Tuple with 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
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    303

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    16
    List containing 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
    478
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9__92311111118

    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: 
    s
    57
    Tuple with 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
    319
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    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
    087
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    7
    Tuple with 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
    231
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    338
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    61
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    57____39
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    95
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    91

    Tuple with 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
    9

     

    Python3

    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
    4
    353
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    361

    Tuple with 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
    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
    4
    288
    Tuple with 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
    217
    Tuple with 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
    04
    Tuple with 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
    468

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    00
    Tuple with 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
    369

    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
    Geeks
    277
    Tuple with 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

    Tuple with 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
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9__7979

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    381
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    383

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    List containing 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
    478
    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 Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    45
    List containing multiple values: 
    ['Geeks', 'For', 'Geeks']
    
    Multi-Dimensional List: 
    [['Geeks', 'For'], ['Geeks']]
    Accessing element from the list
    Geeks
    Geeks
    Accessing element using negative indexing
    Geeks
    Geeks
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    36
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    392
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    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
    4
    395
    Tuple with 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
    396

    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    34
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    398
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    79
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    403

    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
    4
    17
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    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
    4
    476
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    36
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    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]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    487

    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
    4
    492
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    506

    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
    Geeks
    478
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    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
    4
    476
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    36
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    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]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    487

    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
    4
    492
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    506

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    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
    4
    567
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    25
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    21
    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
    4
    28

    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
    Geeks
    478
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    00
    Tuple with 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
    556

    Tuple with 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
    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
    4
    599
    Tuple with 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
    600
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    602
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    21
    Tuple with 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
    605

    Tuple with 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
    Tuple with 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
    607

    Tuple with 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
    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
    4
    611
    Tuple with 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
    600
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    602
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    21
    Tuple with 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
    605

    Tuple with 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
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    361

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

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    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 
    True
    6
    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
    61
    Tuple with 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
    1

    Chọn một yếu tố ngẫu nhiên làm trục.

    Chọn trung bình làm trục.

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

    Python3

    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
    00
    Tuple with 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
    619

    Tuple with 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
    Tuple with 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
    621
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    623

    Tuple with 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
    Tuple with 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
    625
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    627

    Tuple with 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
    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    36
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    630

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    36
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    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
    04
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    655

    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
    4
    641
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    36
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    647

    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
    4
    649
    List containing 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
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    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
    4
    657
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    659

    Tuple with 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
    Tuple with 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
    661
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    663

    Tuple with 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]]
    80
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    666

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    00
    Tuple with 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
    668

    Tuple with 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
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    Tuple with 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
    655

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    673
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    675

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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____108
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    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
    4
    680

    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
    4
    710
    Tuple with 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
    711
    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    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
    21
    Tuple with 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
    16
    Tuple with 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
    17
    Tuple with 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
    18
    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    28
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]]
    
    Accessing Elements
    [ 4 55  1  2]
    8
    
    Adding Element
    [[ 1  2  3  4]
     [ 4 55  1  2]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    
    Deleting Element
    [[ 1  2  3  4]
     [ 8  3 20 19]
     [11  2 22 21]
     [ 1 15 13 11]]
    97
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    361

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

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    57
    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 
    True
    6
    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
    61
    Tuple with 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

    Python3

    Độ phức tạp về thời gian: O [n [logn]]

    Sắp xếp nhanh chóng

    Giống như Merge sắp xếp, Quicksort là một thuật toán phân chia và chinh phục. Nó chọn một phần tử làm trục và phân vùng mảng đã cho xung quanh trục được chọn. Có nhiều phiên bản khác nhau của Quicksort chọn trục theo những cách khác nhau.

    Luôn chọn phần tử đầu tiên làm trục.

    Luôn chọn phần tử cuối cùng làm trục [được triển khai bên dưới]

    Chọn một yếu tố ngẫu nhiên làm trục.

    Chọn trung bình làm trục.

    Quá trình chính trong QuickSort là phân vùng []. Mục tiêu của các phân vùng là, được đưa ra một mảng và phần tử x của mảng làm trục, đặt x ở vị trí chính xác của nó trong mảng được sắp xếp và đặt tất cả các phần tử nhỏ hơn [nhỏ hơn x] trước X và đặt tất cả các phần tử lớn hơn [lớn hơn x] sau x. Tất cả điều này nên được thực hiện trong thời gian tuyến tính.

    Creating Dictionary: 
    {'Name': 'Geeks', 1: [1, 2, 3, 4]}
    Accessing a element using key:
    Geeks
    Accessing a element using get:
    [1, 2, 3, 4]
    {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
    38
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    17
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    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
    Geeks
    478
    List containing 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
    833
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    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
    00
    Tuple with 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
    619

    Tuple with 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
    Tuple with 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
    621
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Tuple with 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
    623

    Creating Bytearray:
    bytearray[b'\x0c\x08\x19\x02']
    
    Accessing Elements: 8
    
    After Modifying:
    bytearray[b'\x0c\x03\x19\x02']
    
    After Adding Elements:
    bytearray[b'\x0c\x03\x19\x02\x1e']
    34
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    476
    List containing 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
    08
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    8

    Creating String: 
    Welcome to GeeksForGeeks
    
    First character of String is: 
    W
    
    Last character of String is: 
    s
    04
    Tuple with 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
    716
    Tuple with 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
    144
    Tuple with 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____36
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    0

    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    794
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    6
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    7
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    57
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    338
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    801
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    0
    Set with the use of Mixed Values
    {1, 2, 4, 6, 'For', 'Geeks'}
    
    Elements of set: 
    1 2 4 6 For Geeks 
    True
    9
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    2

    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    8
    Normal Set
    {'a', 'b', 'c'}
    
    Frozen Set
    frozenset[{'f', 'g', 'e'}]
    9
    Tuple with the use of String: 
    ['Geeks', 'For']
    
    Tuple using List: 
    First element of tuple
    1
    
    Last element of tuple
    6
    
    Third last element of tuple
    4
    809
    Tuple with 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

    Tuple with 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
    811

    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
    4
    814
    Tuple with 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.

Bài Viết Liên Quan

Chủ Đề