Hướng dẫn programming data structures and algorithms using python - lập trình cấu trúc dữ liệu và thuật toán bằng python

Tuần 1 Giới thiệu về chương trình, thuật toán và cấu trúc dữ liệu viagcddownloading và cài đặt pythongcd trong Python: các biến, hoạt động, luồng điều khiển - Bài tập, ALS điều kiện, vòng lặp, Chức năng 2PyThon: và các giá trị bất biến Các hoạt động danh sách: SLICE ETC Tái tìm kiếm Chức năng từ chối: Sắp xếp cảm ứng bằng số và cấu trúc , Giá trị mặc định Các chức năng là các hàm thứ tự đối số trên danh sách: MAP, LTER, DANH SÁCH Hiểu trong 5Exception Công cụ đầu vào/Outputhandling FileString ProcessingingingWeek 6BackTracking ES: Stack, QueueHeapsweek 7abStract DataTypesClasses và các đối tượng trong danh sách "liên kết" Python: Tìm, Chèn, Xóa Cây tìm kiếm: Tìm, Chèn, DeleteHeight Binary Search Tree Mô hình lập trình quản lý bộ nhớ: Lập trình chức năng
Informal introduction to programmin, algorithms and data structures viagcd
Downloading and installing Python
gcd in Python: variables, operations, control flow - assignments, condition-als, loops, functions

Week 2
Python: types, expressions, strings, lists, tuples
Python memory model: names, mutable and immutable values
List operations: slices etc
Binary search
Inductive function denitions: numerical and structural induction
Elementary inductive sorting: selection and insertion sort
In-place sorting

Week 3
Basic algorithmic analysis: input size, asymptotic complexity, O[] notation
Arrays vs lists
Merge sort
Quicksort
Stable sorting

Week 4
Dictionaries
More on Python functions: optional arguments, default values
Passing functions as arguments
Higher order functions on lists: map, lter, list comprehension

Week 5
Exception handling
Basic input/output
Handling files
String processing

Week 6
Backtracking: N Queens, recording all solutions
Scope in Python: local, global, nonlocal names
Nested functions
Data structures: stack, queue
Heaps

Week 7
Abstract datatypes
Classes and objects in Python
"Linked" lists: find, insert, delete
Binary search trees: find, insert, delete
Height-balanced binary search trees

Week 8
Effcient evaluation of recursive definitions: memoization
Dynamic programming: examples
Other programming languages: C and manual memory management
Other programming paradigms: functional programming

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

Đặt triển khai:

Bộ có nhiều hoạt động trên một hashtable:

Ví dụ: Các hoạt động của bộ Python

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

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

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

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

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

First character of String is: 
W

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

First character of String is: 
W

Last character of String is: 
s
1

Đầu ra

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

Elements of set: 
1 2 4 6 For Geeks 
True

Bộ đông lạnh

Các 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'}]

Bộ đông lạnh

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 As strings are immutable, modifying a string will result in creating a new copy.

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

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

Bộ đông lạnh

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

Sợi dây

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}

Bộ đông lạnh

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

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

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.

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

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.

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

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'}]
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]]

Bộ đông lạnh

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

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

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

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

Danh sách liên kết

Danh sách được liên kết là một cấu trúc dữ liệu tuyến tính, trong đó các phần tử không được lưu trữ tại các vị trí bộ nhớ liên tục. Các yếu tố trong danh sách được liên kết được liên kết bằng cách sử dụng các con trỏ như trong hình ảnh dưới đây:

Một danh sách được liên kết được biểu thị bằng một con trỏ đến nút đầu tiên của danh sách được liên kết. Nút đầu tiên được gọi là đầu. Nếu danh sách được liên kết trống, thì giá trị của đầu là null. Mỗi nút trong danh sách bao gồm ít nhất hai phần:

  • 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

Đầu ra

Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]

Thêm các bài viết về ngăn xếp

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

>>> Thêm

Xếp hàng

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

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

  • Enqueue: Thêm một mục vào hàng đợi. Nếu hàng đợi đầy, thì nó được cho là một điều kiện tràn - Độ phức tạp về thời gian: O [1] 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

Đống

Mô -đun HEAPQ trong Python cung cấp cấu trúc dữ liệu HEAP chủ yếu được sử dụng để thể hiện hàng đợi ưu tiên. Thuộc tính của cấu trúc dữ liệu này là nó luôn cung cấp cho phần tử nhỏ nhất [heap tối thiểu] bất cứ khi nào phần tử được bật ra. Bất cứ khi nào các yếu tố được đẩy hoặc bật lên, cấu trúc heap được duy trì. Phần tử Heap [0] cũng trả về phần tử nhỏ nhất mỗi lần. Nó hỗ trợ trích xuất và chèn phần tử nhỏ nhất trong lần O [log n].

Nói chung, đống có thể có hai loại:

  • MAX-HEAP: Trong một khóa tối đa hiện tại ở nút gốc phải là lớn nhất trong số các chìa khóa có mặt tại tất cả trẻ em của nó. Cùng một thuộc tính phải được đệ quy đúng với tất cả các cây con trong cây nhị phân đó. 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.
  • Min-heap: Trong một min-heap, hiện tại ở nút gốc phải là tối thiểu trong số các chìa khóa có mặt tại tất cả trẻ em của nó. Cùng một thuộc tính phải được đệ quy đúng với tất cả các cây con trong cây nhị phân đó.In 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

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

Elements of set: 
1 2 4 6 For Geeks 
True
60
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
07

Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
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
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
42
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 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
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:
[]
15
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
9____4242

Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
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
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
24
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
25
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

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

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

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

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
30
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
31

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

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

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

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

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
37
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
25
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
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
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
30
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
31

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

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

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

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
37
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
25
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
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
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
47
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
25
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

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:
[]
52

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

Đầu ra

  • Thêm bài viết về Heap
  • HEAP BINary
  • Yếu tố lớn nhất k hèth trong một mảng
  • Yếu tố nhỏ nhất/lớn nhất trong mảng chưa được phân loại
  • 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

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

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 -

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ẻ

Python3

Ví dụ: Xác định lớp 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

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

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

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 -

Python3

Ví dụ: Xác định lớp 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

Tuple with the 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
5

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

  • 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]

  • 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]
  • Đơn đặt hàng trước thuật toán [cây]
  • Bưu điện [trái, phải, gốc]: 4 5 2 3 1

Python3

Ví dụ: Xác định lớp 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

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

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

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
050

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

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

Ví dụ: Thêm dữ liệu vào cây

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

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

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

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:
[]
52

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

Đầu ra

Thêm bài viết về Heap

HEAP BINary

Đối với mỗi nút, trước tiên, nút được truy cập và sau đó các nút con của nó được đặt vào hàng đợi FIFO. Dưới đây là thuật toán cho cùng -

  • Tạo một hàng đợi trống Q
  • TEMP_Node = root /*Bắt đầu từ root* /
  • Vòng lặp trong khi temp_node không phải là null
    • In Temp_Node-> Dữ liệu.
    • Enqueue Temp_Node, trẻ em [đầu tiên bên trái sau đó là trẻ em bên phải]
    • Dequeue một nút từ q

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
02
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
59

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
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
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
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
138

Tuple with the 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
[[ 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
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]]
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

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

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
02
Initial stack
['g', 'f', 'g']

Elements popped from stack:
g
f
g

Stack after elements are popped:
[]
59

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
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
138

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

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

Tuple with the 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]]
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

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

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

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

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

Đầu ra

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

List containing multiple 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
  • Xây dựng BST từ việc đặt hàng trước đã cho Traversal | Hiệp 1
  • Cây nhị phân để chuyển đổi cây tìm kiếm nhị phân
  • Tìm nút có giá trị tối thiểu trong cây tìm kiếm nhị phân
  • Một chương trình để kiểm tra xem một cây nhị phân có bst hay không

>>> Thêm

Đồ thị

Biểu đồ là cấu trúc dữ liệu phi tuyến bao gồm các nút và cạnh. Các nút đôi khi cũng được gọi là các đỉnh và các cạnh là các đường hoặc cung kết nối bất kỳ hai nút nào trong biểu đồ. Chính thức hơn, một biểu đồ có thể được định nghĩa là một biểu đồ bao gồm một tập hợp các đỉnh [hoặc nút] hữu hạn và một tập hợp các cạnh kết nối một cặp nút.

Trong biểu đồ trên, tập hợp các đỉnh v = {0,1,2,3,4} và tập hợp các cạnh e = {01, 12, 23, 34, 04, 14, 13}. Hai phần sau đây là các biểu diễn được sử dụng phổ biến nhất của biểu đồ.

  • Ma trận kề
  • Danh sách kề

Ma trận kề

Danh sách kề

Python3

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;

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

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

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

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

Tuple with the 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
Tuple with the 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']
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 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 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

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

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

Các

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ị

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

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
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
List containing multiple 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
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 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 Dictionary: 
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing 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

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

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

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

Độ phức tạp về thời gian: O [V+E] trong đó V là số lượng các đỉnh trong biểu đồ và E là số lượng các cạnh trong biểu đồ.

Độ sâu tìm kiếm đầu tiên hoặc DFS

Độ sâu đầu tiên cho một biểu đồ tương tự như độ sâu đầu tiên của cây. Việc đánh bắt duy nhất ở đây là, không giống như cây, đồ thị có thể chứa các chu kỳ, một nút có thể được truy cập hai lần. Để tránh xử lý một nút nhiều lần, hãy sử dụng mảng đã truy cập Boolean.

Algorithm:

  • Tạo một hàm đệ quy lấy chỉ mục của nút và một mảng đã truy cập.
  • Đánh dấu nút hiện tại như đã truy cập và in nút.
  • Traverse tất cả các nút liền kề và không được đánh dấu và gọi hàm đệ quy với chỉ số của nút liền kề.

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.

Tabulation vs Ghi nhớ

Có hai cách khác nhau để lưu trữ các giá trị để các giá trị của một vấn đề phụ có thể được sử dụng lại. Ở đây, sẽ thảo luận về hai mẫu giải quyết vấn đề lập trình động [DP]: & nbsp;

  • Tabulation: từ dưới lên Bottom Up
  • Ghi nhớ: Từ trên xuống Top Down

Lập bảng

Như chính cái tên gợi ý bắt đầu từ phía dưới và tích lũy câu trả lời lên đầu. Hãy để thảo luận về sự chuyển đổi của nhà nước.

Hãy để mô tả một trạng thái cho vấn đề DP của chúng tôi là DP [x] với DP [0] là trạng thái cơ sở và DP [n] là trạng thái đích của chúng tôi. Vì vậy, & nbsp; chúng ta cần tìm giá trị của trạng thái đích i.e dp [n].

Nếu chúng tôi bắt đầu chuyển đổi từ trạng thái cơ sở của chúng tôi, tức là DP [0] và tuân theo mối quan hệ chuyển đổi trạng thái của chúng tôi để đạt đến trạng thái đích của chúng tôi trạng thái cơ sở dưới cùng và đạt đến trạng thái mong muốn cao nhất.

Bây giờ, tại sao chúng ta gọi nó là phương thức lập bảng?

Để biết điều này, trước tiên, hãy viết một số mã để tính toán giai thừa của một số bằng cách sử dụng phương pháp từ dưới lên. Một lần, một lần nữa là thủ tục chung của chúng tôi để giải quyết DP trước tiên chúng tôi xác định trạng thái. Trong trường hợp này, chúng tôi định nghĩa một trạng thái là dp [x], trong đó dp [x] là tìm giai đoạn của x.

Bây giờ, rõ ràng là dp [x+1] = dp [x] * [x+1]

Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
3

Ghi nhớ

Một lần nữa, một lần nữa, hãy để mô tả nó về mặt chuyển đổi nhà nước. Nếu chúng ta cần tìm giá trị cho một số trạng thái nói dp [n] và thay vì bắt đầu từ trạng thái cơ sở mà tức là dp [0] chúng ta hỏi câu trả lời của chúng ta từ các trạng thái có thể đến trạng thái đích DP [n] sau khi chuyển đổi trạng thái Mối quan hệ, sau đó nó là thời trang từ trên xuống của DP.

Tại đây, chúng tôi bắt đầu hành trình từ trạng thái đích nhất hàng đầu và tính toán câu trả lời của nó bằng cách đếm các giá trị của các trạng thái có thể đạt đến trạng thái đích, cho đến khi chúng tôi đạt đến trạng thái cơ sở dưới cùng.

Một lần nữa, hãy để viết mã cho vấn đề giai thừa theo kiểu từ trên xuống

Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
4

Nhiều bài viết về lập trình động

  • Tài sản cấu trúc tối ưu
  • Tài sản phụ chồng chéo
  • Số Fibonacci
  • Tập hợp con với tổng chia hết cho m
  • Tổng hợp tăng tối đa
  • Chất nền chung dài nhất

>>> Thêm

Thuật toán tìm kiếm

Tìm kiếm tuyến tính

  • Bắt đầu từ phần tử ngoài cùng bên trái của 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 [log [n]]. & Nbsp;

Để biết thêm thông tin, hãy tham khảo tìm kiếm nhị phân.

Sắp xếp thuật toán

Lựa chọn sắp xếp

Thuật toán sắp xếp lựa chọn sắp xếp một mảng bằng cách liên tục tìm phần tử tối thiểu [xem xét thứ tự tăng dần] từ phần chưa được phân loại và đặt nó ở đầu. Trong mỗi lần lặp của loại lựa chọn, phần tử tối thiểu [xem xét thứ tự tăng dần] từ Subarray chưa được phân loại được chọn và chuyển sang Subarray được sắp xếp. & NBSP;

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

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

Is O[n2] as there are two nested loops.

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[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
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

 

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

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

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

  • 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

Illustration:

 

Python3

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

Sắp xếp chèn

Để sắp xếp một mảng kích thước N theo thứ tự tăng dần bằng 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

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

Tuple with the 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:

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
481
[[ 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
483
Tuple with the 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
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 ____2487

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
490

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
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
494

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
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
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 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
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 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
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
481
[[ 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
521

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
494

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
481
[[ 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
521

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
494

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
481
[[ 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
521

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
494

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

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

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

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 Dictionary: 
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing 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
O[n[logn]]

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

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

  • Các
  • Đầu ra
  • Độ phức tạp về thời gian: O [n [logn]]

Sắp xếp nhanh chóng

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

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

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.

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

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.

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

Tuple with the 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 Dictionary: 
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing 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

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

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

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 Dictionary: 
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing 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
O[n[logn]]

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

Python3

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

Các

Đầu ra

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

Sắp xếp nhanh chóng

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
740

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
743

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
745
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
747

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

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
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 Dictionary: 
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing 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
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
Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
725
List containing multiple 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
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']
34
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
772
List containing multiple 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
Tuple with the use of String: 
['Geeks', 'For']

Tuple using List: 
First element of tuple
1

Last element of tuple
6

Third last element of tuple
4
774

Các

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 và thuật toán dữ liệu này thông qua khóa học sâu, các chương trình Python được sử dụng để thực hiện các khái niệm khác nhau, nhưng bạn có thể dễ dàng mã hóa chúng bằng bất kỳ ngôn ngữ lập trình nào khác như C ++, Java hoặc C#.Python programs are used for implementing various concepts, but you can easily code them in any other programming language like C++, Java or C#.

Ngôn ngữ nào là tốt nhất cho DSA?

Ngôn ngữ nào là tốt nhất cho DS và Algo?Hầu hết các lập trình viên cạnh tranh sử dụng C ++ vì hiệu quả của nó đối với DSA.Điều đó đang được nói, ngôn ngữ chỉ là một phương tiện và bất kỳ ngôn ngữ nào mà bạn rất giàu có đều phù hợp để bạn thực hiện DSA.C++ because of its efficiency for DSA. That being said, the language is just a medium and any language that you are affluent with is appropriate for you to implement DSA.

Python có được sử dụng cho các thuật toán không?

Là một mục đích chung, dễ học và hiểu ngôn ngữ, Python có thể được sử dụng cho một loạt các nhiệm vụ phát triển.Nó có khả năng thực hiện một số nhiệm vụ học máy, đó là lý do tại sao hầu hết các thuật toán được viết bằng Python.most algorithms are written in Python.

Thuật toán lập trình Python là gì?

Thuật toán là một thủ tục từng bước, trong đó xác định một tập hợp các hướng dẫn được thực thi theo một thứ tự nhất định để có được đầu ra mong muốn.Các thuật toán thường được tạo ra độc lập với các ngôn ngữ cơ bản, tức là một thuật toán có thể được thực hiện bằng nhiều ngôn ngữ lập trình.a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.

Bài Viết Liên Quan

Chủ Đề