🚀 Today's Learning:
🌟 DSA
- Insert a node in DLL
- Delete a node in DLL
🌟 Dev
- FastAPI
🔍 Some Key Highlights:
DSA
To insert a node in a Doubly Linked List (DLL), you typically start by creating a new node with the provided data. Then, if the DLL is empty, you make the new node both the head and tail of the list. Otherwise, you update the pointers of the new node to point to the current head as its next node and NULL as its previous node. You then update the previous pointer of the current head to point to the new node. Finally, you set the new node as the new head of the list. This way, the new node is inserted at the beginning of the DLL, maintaining its connectivity.
Deleting a node from a Doubly Linked List (DLL) involves several steps. First, you locate the node to be deleted by traversing the list until you find it. Once found, you adjust the pointers of the neighboring nodes to bypass the node to be deleted. Specifically, you make the previous node point to the next node of the node to be deleted, and you make the next node point to the previous node of the node to be deleted. Additionally, if the node to be deleted is the head or tail of the DLL, you update the head or tail pointers accordingly. Finally, you free the memory allocated to the node to be deleted. This process ensures the integrity of the DLL structure after the deletion operation.
DEV
FastAPI is a web framework for building APIs with Python, designed for speed, simplicity, and type safety. It leverages Python's type hints for automatic data validation and documentation generation. When using FastAPI, you typically define API endpoints by creating functions decorated with specific route decorators, such as @app.get()
for GET requests or @app.post()
for POST requests. These functions typically receive parameters representing data from the request, process it as needed, and return data to be sent as the response. FastAPI automatically handles serialization and deserialization of data to and from JSON, making it straightforward to work with JSON-based APIs. Additionally, FastAPI provides built-in support for features like dependency injection, middleware, and automatic generation of interactive API documentation using Swagger UI or ReDoc. Overall, FastAPI simplifies the process of building high-performance APIs in Python while ensuring type safety and robust documentation.
#100daysofcode #1percentplusplus #coding #dsa
Top comments (0)