Docsity

Guide Complet Python : Structures de Données et Cheatsheet, Résumés de Informatique

Toggle sidebar
bg1
Computer Science Guide
Python Data Structures & Big-O Complexity
Course: Intro to Computer Science / Data Structures
1. Overview of Core Data Structures
Data Structure Mutable Ordered Duplicates Allowed Syntax Example
List Yes Yes Yes [1, 2, 3]
Tuple No Yes Yes (1, 2, 3)
Set Yes No No {1, 2, 3}
Dictionary Yes Yes (3.7+) Keys: No, Values: Yes {"a": 1}
2. Common Operations & Code Snippets
List Operations:
# Adding & Removing Elements
my_list = [10, 20, 30]
my_list.append(40) # [10, 20, 30, 40]
my_list.pop() # Removes 40
my_list.sort(reverse=True)# [30, 20, 10]
Dictionary Operations:
# Key-Value Pair Management
student = {"name": "Alex", "gpa": 3.8}
student["major"] = "CS" # Add key
val = student.get("gpa") # Safe retrieval
3. Time Complexity (Big-O) Cheat Sheet
Data Structure Access Search Insertion Deletion
Array / List O(1) O(n) O(n) O(n)
Hash Table / Dict N/A O(1) avg O(1) avg O(1) avg
Binary Search Tree O(log n) O(log n) O(log n) O(log n)

Aperçu partiel du texte

Télécharge Guide Complet Python : Structures de Données et Cheatsheet et plus Résumés au format PDF de Informatique sur Docsity uniquement!

Computer Science Guide

Python Data Structures & Big-O Complexity

Course: Intro to Computer Science / Data Structures

1. Overview of Core Data Structures

Data Structure Mutable Ordered Duplicates Allowed Syntax Example List Yes Yes Yes [1,^ 2, 3] Tuple No Yes Yes (1,^ 2, 3) Set Yes No No {1,^ 2, 3} Dictionary Yes Yes (3.7+) Keys: No, Values: Yes {"a":^ 1}

2. Common Operations & Code Snippets

List Operations:

Adding & Removing Elements

my_list = [10, 20, 30] my_list.append(40) # [10, 20, 30, 40] my_list.pop() # Removes 40 my_list.sort(reverse=True)# [30, 20, 10]

Dictionary Operations:

Key-Value Pair Management

student = {"name": "Alex", "gpa": 3.8} student["major"] = "CS" # Add key val = student.get("gpa") # Safe retrieval

3. Time Complexity (Big-O) Cheat Sheet

Data Structure Access Search Insertion Deletion Array / List O(1) O(n) O(n) O(n) Hash Table / Dict N/A O(1) avg O(1) avg O(1) avg Binary Search Tree O(log n) O(log n) O(log n) O(log n)