What is Tree? Tree is a data structure which has a hierarchy system. Concepts & Words Node: each element of the tree Root: The uppermost node of the tree Parent: a node that is above another node Child: a node that is under another node Leaf: Nodes have no children Edge: The line connects nodes Level: The depth from the root (The level of the root is 0) Height: Max level of the tree Features of Tree Hierarchy System: the relationship between subordinates and superiors No cycle: you can't go backward Connections: All nodes are connected from the root Distinct route: There is only one route between two random nodes Implementing the Tree Core Elements to implement 1. Node Class: Each node has the reference to its child node and data 2. Main Functions Insert: Adding a new node Search: Finding a specific value Traversal: Visiting all nodes Delete: Removing a node 3. Ways Of Traversing A Tree Preorder: Root -> Left -> Right Inorder: Left -> Root -> Right Post...
What is numpy? NumPy is an open source project that enables numerical computing with Python. Numpy is implemented in C, its performance is faster than a Python list. Document Core Features ndarray : N-dimensional Array Object, the basic data type of NumPy. Vectorization : Operations (or Calculations) performed on the entire array without explicit loops. Broadcasting : Enables operations between arrays of different shapes (or sizes) Array Operations and Attributes 1. Array Creation np.array(): Creates an array from a Python list. np.zeros(): An array filled with zeros. np.ones(): An array filled with ones. np.arange(): An array of consecutive numbers. np.linspace(): An array with evenly spaced numbers. np.random: Module for generating random arrays. 2. Array Attributes shape: The array's dimensions/axes (rows, columns). dtype: Data type. ndim: Number of dimensions. size: Total number of elements. 3. Array Indexing and Slicing Basic Indexing: arr[0], arr[1, 2] Slicing: arr[1:3]...