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 True5
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Đầu ra
[1, 2, 3, 'GFG', 2.3]
Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là [nếu n phần tử có] N-1.
Ví dụ: Hoạt động danh sách Python
Python3
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s7
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__55555547
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}3
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]1
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]4
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]5
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]2
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]7
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks02
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Đầu ra
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks
Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là [nếu n phần tử có] N-1.
Ví dụ: Hoạt động danh sách Python
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s7
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__55555547
Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
8Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
9Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
5Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
1To create a tuple of one element there must be a trailing comma. For example, [8,] will create a tuple containing 8 as the element.
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
9Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 [[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]]
Accessing Elements
[ 4 55 1 2]
8
Adding Element
[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
Deleting Element
[[ 1 2 3 4]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
1[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]]
Accessing Elements
[ 4 55 1 2]
8
Adding Element
[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
Deleting Element
[[ 1 2 3 4]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
2Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
9[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]]
Accessing Elements
[ 4 55 1 2]
8
Adding Element
[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
Deleting Element
[[ 1 2 3 4]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
4[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]]
Accessing Elements
[ 4 55 1 2]
8
Adding Element
[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
Deleting Element
[[ 1 2 3 4]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
5[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]]
Accessing Elements
[ 4 55 1 2]
8
Adding Element
[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
Deleting Element
[[ 1 2 3 4]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
2[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]]
Accessing Elements
[ 4 55 1 2]
8
Adding Element
[[ 1 2 3 4]
[ 4 55 1 2]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
Deleting Element
[[ 1 2 3 4]
[ 8 3 20 19]
[11 2 22 21]
[ 1 15 13 11]]
7
Python3
Tuple
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks27
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Các bộ dữ liệu python tương tự như danh sách nhưng các bộ dữ liệu có tính chất bất biến, tức là một khi được tạo ra, nó không thể được sửa đổi. Giống như một danh sách, một tuple cũng có thể chứa các yếu tố của nhiều loại khác nhau.
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks48
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Trong Python, các bộ dữ liệu được tạo ra bằng cách đặt một chuỗi các giá trị được phân tách bằng ‘dấu phẩy có hoặc không sử dụng dấu ngoặc đơn để nhóm chuỗi dữ liệu. & NBSP;
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks56
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks66
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks77
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks18
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Đầu ra
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
Các yếu tố danh sách có thể được truy cập bởi chỉ mục được chỉ định. Trong chỉ số bắt đầu Python của danh sách, một chuỗi là 0 và chỉ số kết thúc là [nếu n phần tử có] N-1.
Ví dụ: Hoạt động danh sách Python
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s5
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s7
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__55555547
Đặ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 Geeks86
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__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 406
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks86
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 414
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks86
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 423
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428
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: s5
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks86
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Đầ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 435
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 439
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 441
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4424243
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 447
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 450
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 451
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 453
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 455
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 457
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 459
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 463
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 466
Đầu ra
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
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
35Set 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
88List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
89Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
39Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
9Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
41Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
424243Initial 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 451
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 453
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 455
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 457
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 459
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 472
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 475
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 478
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 481
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 486
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 481
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Đầu ra
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
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 435
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 439
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 441
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4424243
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True12
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True20
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 496
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 451
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 453
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 455
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 457
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 459
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 493
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True35
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37
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 True59
Đầu ra
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
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 435
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 439
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 441
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4424243
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 451
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 453
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 455
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 457
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 459
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
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: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]13
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]13
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]19
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
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: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]07
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: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]07
Đầu ra
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]
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 435
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 439
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 441
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4424243
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]67
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]73
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]74
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []3
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 True8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]79
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
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: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]88
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]89
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]93
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]70
Đầu ra
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']
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 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s08
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s16
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0224524____36
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút.
Python3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]98
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s08
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s16
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0224524____36
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút.
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]98
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s58
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s64
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s66
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s68
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s74
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s80
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
21Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
86Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12 Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s91
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s94
Python3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]98
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s08
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s16
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0224524____36
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút.
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]98
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s58
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s64
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s66
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s68
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Hãy để chúng tôi tạo một danh sách liên kết đơn giản với 3 nút.
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]98
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s58
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s64
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s66
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s68
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s74
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s80
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}85
Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
21Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
86Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12 Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
89
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
21Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
91Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
12Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
94- Danh sách liên kết Traversal & NBSP;
- Trong chương trình trước, chúng tôi đã tạo một danh sách liên kết đơn giản với ba nút. Hãy để chúng tôi đi qua danh sách được tạo và in dữ liệu của từng nút. Đối với Traversal, chúng ta hãy viết một danh sách in chức năng đa năng [] in bất kỳ danh sách nào.
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
21Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
00Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
27Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
0221Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
31Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True
6Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
022Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
04Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
36Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
37Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
40
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
31Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
444Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
12
Thêm các bài viết trong danh sách được liên kết
Liên kết danh sách chèn
Xóa danh sách được liên kết [xóa một khóa đã cho]
- Xóa danh sách được liên kết [xóa khóa ở vị trí đã cho] Returns whether the stack is empty – Time Complexity: O[1]
- Tìm độ dài của một danh sách được liên kết [lặp và đệ quy] Returns the size of the stack – Time Complexity: O[1]
- Tìm kiếm một phần tử trong danh sách được liên kết [lặp và đệ quy] Returns a reference to the topmost element of the stack – Time Complexity: O[1]
- Nút thứ n từ cuối danh sách được liên kết Inserts the element ‘a’ at the top of the stack – Time Complexity: O[1]
- Đảo ngược một danh sách được liên kết Deletes the topmost element of the stack – Time Complexity: O[1]
Python3
>>> Thêm
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}89
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Cây rơm
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}89
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]03
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]06
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]09
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]09
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]09
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]16
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]03
Đầ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 True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]23
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]23
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}93
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]23
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}90
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]34
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]37
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]43
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]43
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]43
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True37
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]56
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]37
Đầu ra
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks0
Thêm các bài viết về hàng đợi
- Thực hiện hàng đợi bằng cách sử dụng ngăn xếp
- Thực hiện ngăn xếp bằng hàng đợi
- Thực hiện một ngăn xếp bằng cách sử dụng hàng đợi đơn lẻ
Hàng đợi ưu tiên
Hàng đợi ưu tiên là các cấu trúc dữ liệu trừu tượng trong đó mỗi dữ liệu/giá trị trong hàng đợi có mức độ ưu tiên nhất định. Ví dụ, trong các hãng hàng không, hành lý với tiêu đề kinh doanh, hoặc hạng nhất của nhóm đến sớm hơn phần còn lại. Hàng đợi ưu tiên là một phần mở rộng của hàng đợi với các thuộc tính sau.
- Một yếu tố có mức độ ưu tiên cao được khử trùng trước một phần tử có mức độ ưu tiên thấp.
- Nếu hai yếu tố có cùng mức độ ưu tiên, chúng được phục vụ theo đơn đặt hàng của chúng trong hàng đợi.
Python3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]61
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]62
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0225771
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]76
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Is
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]92
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02.
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']06
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']11
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']18
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']37
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']39
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']21
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']41
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']42
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']21
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']45
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']47
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']39
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']21
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]7
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']54
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']39
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']21
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]7
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']61
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']63
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']64
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']69
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']71
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']777____36
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']79
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']81
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]57
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']81
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']81
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']90
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']81
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']94
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']98
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []02
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []05
Đầu ra
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks1
Đố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 True60
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 True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Creating Bytearray: bytearray[b'\x0c\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 True9
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 True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9____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 True6
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 Geeks40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
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 True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 47
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 True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 47
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 True6
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 Geeks2
Đầ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 Geeks3
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 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks4
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 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74
Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới -
Ví dụ: Thêm dữ liệu vào cây
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
0022____36 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
70Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
0List containing multiple 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 Geeks007
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks5
List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
012Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
70List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
40List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
006
- 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 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74
Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới -
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks045
Ví dụ: Thêm dữ liệu vào cây
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks050
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới -
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks057
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks059
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks048
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: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks048
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks072
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks074
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []72
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []74
Bây giờ, hãy để tạo ra một cây có 4 nút trong Python. Hãy giả sử cấu trúc cây trông giống như bên dưới -
Ví dụ: Thêm dữ liệu vào cây
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks0022____36
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks006
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks102
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks104
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks107
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks109
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks112
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks114
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 Geeks6
Đầ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 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
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: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s06
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
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: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks138
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks152
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks157
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks162
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks164
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks168
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks173
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks179
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks182
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks188
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks080
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks085
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks012
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks095
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks216
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks218
Đầu ra
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks7
Độ phức tạp về thời gian: O [n] & nbsp;
Thêm bài viết về cây nhị phân
- Chèn vào cây nhị phân
- Xóa trong một cây nhị phân
- Thứ thứ tự truyền tải cây mà không có đệ quy
- Cây thứ tự truyền tải không có đệ quy và không có ngăn xếp!
- In Traversal PostorDeral từ đã đưa ra trước và đặt hàng trước các lần đi qua
- Tìm bưu điện của BST từ Traversal trước khi đặt hàng
>>> Thêm
Cây tìm kiếm nhị phân
Cây tìm kiếm nhị phân là một cấu trúc dữ liệu cây nhị phân dựa trên nút có các thuộc tính sau:
- Subtree bên trái của một nút chỉ chứa các nút có các phím nhỏ hơn phím nút.
- Subtree bên phải của một nút chỉ chứa các nút có các phím lớn hơn phím nút.
- Cây con bên trái và bên phải cũng phải là một cây tìm kiếm nhị phân.
Các thuộc tính trên của cây tìm kiếm nhị phân cung cấp một đơn đặt hàng giữa các khóa để các hoạt động như tìm kiếm, tối thiểu và tối đa có thể được thực hiện nhanh chóng. Nếu không có thứ tự, thì chúng ta có thể phải so sánh mọi khóa để tìm kiếm một khóa nhất định.
Yếu tố tìm kiếm
- Bắt đầu từ gốc.
- So sánh phần tử tìm kiếm với gốc, nếu ít hơn root, sau đó recurse cho bên trái, khác phục hồi cho bên phải.
- Nếu phần tử để tìm kiếm được tìm thấy ở bất cứ đâu, hãy trả về đúng, nếu không trả về sai.
Python3
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks220
Is
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks233
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks236
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks239
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks242
Chèn một khóa & nbsp;
- Bắt đầu từ gốc.
- So sánh phần tử tìm kiếm với gốc, nếu ít hơn root, sau đó recurse cho bên trái, khác phục hồi cho bên phải.
- Nếu phần tử để tìm kiếm được tìm thấy ở bất cứ đâu, hãy trả về đúng, nếu không trả về sai.
Python3
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]98
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
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: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []62
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []67
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks138
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]20
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks162
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks164
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks168
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks173
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks182
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks142
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []97
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks080
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks085
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks012
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks311
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks314
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks316
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks095
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s70
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks216
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Đầ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 Geeks352
Đầu ra
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks8
Độ phức tạp về thời gian: O [n] & nbsp;
- Thêm bài viết về cây nhị phân
- 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 Geeks354
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02.
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022377736
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks379
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks387
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]7
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True41
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks379
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221382
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks384
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks396
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1398
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks399
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks404
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks406
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022401409
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02214122
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221419
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks399
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks424
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks426
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks431
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks434
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks436
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks439
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221442
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks444
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221447
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks444
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks452
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks465
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}88
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks461
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']42
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks494
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks496
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks498
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks500
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1488
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks465
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks506
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks513
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks515
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks44
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks521
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks526
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks531
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks536
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks518
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}93
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221512
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks521
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks531
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True87
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks531
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks526
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]89
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks526
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks335
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks536
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks320
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks548
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}93
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks541
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 442
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks345
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks592
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks595
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks598
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks601
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks604
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Các
Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
8List containing multiple 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 Geeks609
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221617
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks619
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s025____511
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022____1635
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks637
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1640
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]79
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True41
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks647
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks650
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks656
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks658
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks662
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022____1665
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks667
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks671
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks658
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks677
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221680
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks667
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks685
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks699
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s11
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks701
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks702
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []27
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}31
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks709
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks712
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks716
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s11
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks701
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks719
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []27
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}31
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}444
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks730
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']71
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks736
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks739
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks42
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks743
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks745
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks747
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks789
Đầu ra
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks9
Đồ thị truyền tải
Tìm kiếm đầu tiên hoặc BFS
Đường ngang đầu tiên cho một biểu đồ tương tự như đường truyền đầu tiên của cây. Việc bắt duy nhất ở đây là, không giống như các biểu đồ, đồ thị có thể chứa các chu kỳ, vì vậy chúng ta có thể đến cùng một nút. Để tránh xử lý một nút nhiều lần, chúng tôi sử dụng một mảng đã truy cập Boolean. Để đơn giản, người ta cho rằng tất cả các đỉnh có thể tiếp cận được từ đỉnh bắt đầu.
Ví dụ, trong biểu đồ sau, chúng ta bắt đầu truyền từ Vertex 2. Khi chúng ta đến Vertex 0, chúng ta tìm kiếm tất cả các đỉnh liền kề của nó. 2 cũng là một đỉnh liền kề là 0. Nếu chúng ta không đánh dấu các đỉnh đã truy cập, thì 2 sẽ được xử lý lại và nó sẽ trở thành một quá trình không kết thúc. Một đường ngang đầu tiên của biểu đồ sau là 2, 0, 3, 1.
Python3
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks790
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks791
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True60
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks793
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022____1635
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks637
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022 ____1640
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s14
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]79
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True41
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks647
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks815
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks650
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks656
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks658
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks662
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks841
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022____1665
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks667
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks166
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks671
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks658
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks677
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221680
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks667
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks685
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']42
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks875
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}31
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks709
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks712
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}31
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}444
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s12
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks915
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks917
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks919
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Đầu ra
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 40
Độ 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 Geeks790
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks791
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True60
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks793
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]97
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks354
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s01
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s0221
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04______5022
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks810
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks815
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks950
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks954
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks957
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]81
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks963
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks963
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []01
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks972
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks975
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks978
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s022
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks8222
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks88
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s02
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks988
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks880
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks882
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Initial stack ['g', 'f', 'g'] Elements popped from stack: g f g Stack after elements are popped: []2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks883
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4024
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4026
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Đầu ra
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 41
Thêm các bài viết về đồ thị
- Biểu đồ biểu đồ bằng cách sử dụng tập hợp và băm
- Tìm mẹ đỉnh trong đồ thị
- Độ sâu tìm kiếm đầu tiên
- Đếm số lượng nút ở mức nhất định trong cây bằng cách sử dụng BFS
- Đếm tất cả các đường dẫn có thể giữa hai đỉnh
>>> Thêm
Đệ quy
Quá trình trong đó một hàm tự gọi trực tiếp hoặc gián tiếp được gọi là đệ quy và hàm tương ứng được gọi là hàm đệ quy. Sử dụng các thuật toán đệ quy, một số vấn đề có thể được giải quyết khá dễ dàng. Ví dụ về các vấn đề như vậy là các tòa tháp của Hà Nội [TOH], các lần đi qua cây trước/đặt hàng/bưu điện, DF của đồ thị, v.v.
Điều kiện cơ bản trong đệ quy là gì?
Trong chương trình đệ quy, giải pháp cho trường hợp cơ sở được cung cấp và giải pháp cho vấn đề lớn hơn được thể hiện dưới dạng các vấn đề nhỏ hơn. & NBSP;
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 42
Trong ví dụ trên, trường hợp cơ sở cho n > Thêm
Đệ quy
Quá trình trong đó một hàm tự gọi trực tiếp hoặc gián tiếp được gọi là đệ quy và hàm tương ứng được gọi là hàm đệ quy. Sử dụng các thuật toán đệ quy, một số vấn đề có thể được giải quyết khá dễ dàng. Ví dụ về các vấn đề như vậy là các tòa tháp của Hà Nội [TOH], các lần đi qua cây trước/đặt hàng/bưu điện, DF của đồ thị, v.v.
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 43
Ghi nhớ
Một lần nữa, một lần nữa, hãy để mô tả nó về mặt chuyển đổi nhà nước. Nếu chúng ta cần tìm giá trị cho một số trạng thái nói dp [n] và thay vì bắt đầu từ trạng thái cơ sở mà tức là dp [0] chúng ta hỏi câu trả lời của chúng ta từ các trạng thái có thể đến trạng thái đích DP [n] sau khi chuyển đổi trạng thái Mối quan hệ, sau đó nó là thời trang từ trên xuống của DP.
Tại đây, chúng tôi bắt đầu hành trình từ trạng thái đích nhất hàng đầu và tính toán câu trả lời của nó bằng cách đếm các giá trị của các trạng thái có thể đạt đến trạng thái đích, cho đến khi chúng tôi đạt đến trạng thái cơ sở dưới cùng.
Một lần nữa, hãy để viết mã cho vấn đề giai thừa theo kiểu từ trên xuống
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 44
Nhiều bài viết về lập trình động
- 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: s00
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4065
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4076
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4079
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']45
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4087
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks53
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks335
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]7
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True45
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks553
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4107
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4109
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4111
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4120
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4127
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4128
Đầu ra
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 45
Độ phức tạp thời gian của thuật toán trên là o [n]. & Nbsp;
Để biết thêm thông tin, hãy tham khảo tìm kiếm tuyến tính.
Tìm kiếm nhị phâ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: s00
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4130
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4133
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4135
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4137
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4139__1833
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4149
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4152
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4155
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks289
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4158
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4161
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4164
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4170
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4173
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4087
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4183
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks40
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks53
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks335
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]7
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True45
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks553
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4107
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4109
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4111
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s21
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4120
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Đầu ra
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 46
Độ phức tạp thời gian của thuật toán trên là o [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 True60
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4227
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4228
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]61
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]57
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True95____39
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True91____47
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 42247
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']45
Is
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4265
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4269
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4271
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4273
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4276
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 42247
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4249
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']45
Đầ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 47
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
04Creating 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}
38Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
249Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
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 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4271
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4273
Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
8 Normal Set
{'a', 'b', 'c'}
Frozen Set
frozenset[{'f', 'g', 'e'}]
9Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
276Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
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 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4288
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4217
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4290
Độ phức tạp về thời gian: O [N2] vì có hai vòng lồng nhau.
Không gian phụ trợ: O [1] & NBSP;
Sắp xếp bong bóng
Sắp xếp bong bóng là thuật toán sắp xếp đơn giản nhất hoạt động bằng cách liên tục hoán đổi các phần tử liền kề nếu chúng theo thứ tự sai.
Minh họa: & nbsp;
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4292
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4350
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4103
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4106
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4303
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9__92311111118
Đầ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 48
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38Creating 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
319List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
833Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
8Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
322O[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 4087
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4338
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]61
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]57____39
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True95
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True91
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
353Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s
1Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
16Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
17Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
18Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']
28Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]
97Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
361Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
21Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
8Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]
9Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
288Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
217Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4
367
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: s00
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4369
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9__7979
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4381
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4383
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4429
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4303
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9__92311111118
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38Creating String:
Welcome to GeeksForGeeks
First character of String is:
W
Last character of String is:
s
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
319List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
833Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
8Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
322 O[n2]]
Các
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4087
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4231
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4338
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]61
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]57____39
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True95
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True91
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 49
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 4353
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4361
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4288
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4217
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4367
Độ phức tạp về thời gian: O [N2]
Sắp xếp chèn
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4468
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4470
Để sắp xếp một mảng kích thước N theo thứ tự tăng dần bằng cách sử dụng sắp xếp chèn:
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4481
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 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 4483
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4395
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4485
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97 ____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: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4490
Creating Bytearray: bytearray[b'\x0c\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 4492
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4494
Creating Bytearray: bytearray[b'\x0c\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 417
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks277
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating Bytearray: bytearray[b'\x0c\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 4492
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4506
Creating Bytearray: bytearray[b'\x0c\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 Geeks478
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4481
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 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 4521
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4492
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4494
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4481
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 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 4521
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4492
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4494
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4481
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 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 4521
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4492
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4494
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4567
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 425
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 428
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4485
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4487
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4599
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4600
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4602
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4605
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4607
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4611
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4600
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4602
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4605
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
492Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
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 True0
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
478List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
833Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
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 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4361
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']71
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
- 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 True1
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 True1
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: s00
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4619
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4621
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4623
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4655
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4625
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4627
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4630
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4633
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97__
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4641
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4647
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4649
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4657
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4659
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4661
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4663
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 421
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]80
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4666
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s00
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4668
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4710
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4711
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s1
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38Tuple with the use of String:
['Geeks', 'For']
Tuple using List:
First element of tuple
1
Last element of tuple
6
Third last element of tuple
4
492Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
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 True3
Creating Dictionary:
{'Name': 'Geeks', 1: [1, 2, 3, 4]}
Accessing a element using key:
Geeks
Accessing a element using get:
[1, 2, 3, 4]
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
38List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
478List containing multiple values:
['Geeks', 'For', 'Geeks']
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
833Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
6 Set with the use of Mixed Values
{1, 2, 4, 6, 'For', 'Geeks'}
Elements of set:
1 2 4 6 For Geeks
True
8O[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 421
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 416
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 418
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']28
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4361
Python3
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']71
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s61
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
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: s04
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}36
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4485
[[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21]] Accessing Elements [ 4 55 1 2] 8 Adding Element [[ 1 2 3 4] [ 4 55 1 2] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]] Deleting Element [[ 1 2 3 4] [ 8 3 20 19] [11 2 22 21] [ 1 15 13 11]]97
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4740
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4743
Creating Bytearray: bytearray[b'\x0c\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 4745
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4747
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 417
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks478
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks833
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4476
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']45
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing a element using key: Geeks Accessing a element using get: [1, 2, 3, 4] {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}38
Creating Dictionary: {'Name': 'Geeks', 1: [1, 2, 3, 4]} Accessing 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 4476
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4725
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 420
Creating Bytearray: bytearray[b'\x0c\x08\x19\x02'] Accessing Elements: 8 After Modifying: bytearray[b'\x0c\x03\x19\x02'] After Adding Elements: bytearray[b'\x0c\x03\x19\x02\x1e']34
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s57
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4772
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4774
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 4476
List containing multiple values: ['Geeks', 'For', 'Geeks'] Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']] Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks08
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True8
Creating String: Welcome to GeeksForGeeks First character of String is: W Last character of String is: s04
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4716
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4144
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 41444____36
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4794
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True6
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True7
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]57
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4338
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4801
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]0
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True9
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]2
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4809
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4810
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4811
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]8
Normal Set {'a', 'b', 'c'} Frozen Set frozenset[{'f', 'g', 'e'}]9
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4814
Tuple with the use of String: ['Geeks', 'For'] Tuple using List: First element of tuple 1 Last element of tuple 6 Third last element of tuple 4810
Đầu ra
Set with the use of Mixed Values {1, 2, 4, 6, 'For', 'Geeks'} Elements of set: 1 2 4 6 For Geeks True4
Độ phức tạp về thời gian: & nbsp; O [n2]. & Nbsp; O[n2].