Posts

Showing posts from September, 2026

PUTHON DSA

Image
  Data Structures Data Structures are a way of storing and organizing data in a computer. Python has built-in support for several data structures, such as lists, dictionaries, and sets. Other data structures can be implemented using Python classes and objects, such as linked lists, stacks, queues, trees, and graphs. In this tutorial we will concentrate on these Data Structures: Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs   Stacks with Python           Stacks A stack is a data structure that can hold many elements, and the last element added is the first one to be removed. Like a pile of pancakes, the pancakes are both added and removed from the top. So when removing a pancake, it will always be the last pancake you added. This way of organizing elements is called LIFO: Last In First Out. Basic operations we can do on a stack...

Linklist with all methods

 # Create nodes using dictionaries node1 = {"data": 10, "next": None} node2 = {"data": 20, "next": None} node3 = {"data": 30, "next": None} # Link the nodes node1["next"] = node2 node2["next"] = node3 head = node1 # 1. Display Linked List print("Linked List:") current = head while current is not None:     print(current["data"], end=" -> ")     current = current["next"] print("None") # 2. Insert at Beginning new_node = {"data": 5, "next": head} head = new_node print("\nAfter Insert at Beginning:") current = head while current is not None:     print(current["data"], end=" -> ")     current = current["next"] print("None") # 3. Insert at End new_node = {"data": 40, "next": None} current = head while current["next"] is not None:     current = current["ne...

Linklist Example

 # Create nodes using dictionaries node1 = {"data": 10, "next": None} node2 = {"data": 20, "next": None} node3 = {"data": 30, "next": None} node4 = {"data": 40, "next": None} # Connect the nodes node1["next"] = node2 node2["next"] = node3 node3["next"] = node4 # Start from first node current = node1 # Display linked list while current is not None:     print(current["data"], end=" -> ")     current = current["next"] print("None")

Scipy library

 python SciPy introduction with example and result  python SciPy introduction with example and result Python SciPy – Introduction with Examples and Results What is SciPy? SciPy (Scientific Python) is an open-source Python library used for scientific computing, mathematics, engineering, statistics, optimization, signal processing, and data analysis . SciPy is built on top of NumPy and provides many advanced mathematical and scientific functions. Installation pip install scipy Import SciPy import scipy print ( scipy . __version__) 1. SciPy – Integration Example SciPy can calculate definite integrals using integrate.quad() . Example Calculate: ∫ 0 2 ​ x 2 d x from scipy . integrate import quad def function ( x ): return x ** 2 result , error = quad ( function , 0 , 2 ) print ( "Integration Result:" , result ) print ( "Error:" , error ) Result Integration Result: 2.6666666666666665 Error: 2.9605947323337504e-14 2. SciPy – Optimization Example SciPy c...