This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | name: clear-gh-cache | |
| on: | |
| schedule: | |
| - cron: '0 5 * * 1' # Run at 5:00 AM every Monday | |
| workflow_dispatch: | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:alpine' | |
| args: | |
| - gcloud | |
| - --quiet | |
| - functions | |
| - deploy | |
| - $_FUNCTION_NAME | |
| - --region=$_REGION | |
| - --source=$_SRC_FOLDER | |
| - --runtime=$_RUNTIME | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | - name: 'docker.io/library/python:3.8-slim' | |
| dir: $_SRC_FOLDER | |
| entrypoint: bash | |
| args: | |
| - -c | |
| - | | |
| pip install --upgrade pip | |
| pip install keyrings.google-artifactregistry-auth | |
| pip install poetry==1.2.0a2 | |
| poetry export --without-hashes --output requirements.txt | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def post_order_traverse(tree: BST, array: List[int]) -> List[int]: | |
| if tree is not None: | |
| post_order_traverse(tree.left, array) | |
| post_order_traverse(tree.right, array) | |
| array.append(tree.value) | |
| return array | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def pre_order_traverse(tree: BST, array: List[int]) -> List[int]: | |
| if tree is not None: | |
| array.append(tree.value) | |
| pre_order_traverse(tree.left, array) | |
| pre_order_traverse(tree.right, array) | |
| return array | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def in_order_traverse(tree: BST, array: List[int]) -> List[int]: | |
| if tree is not None: | |
| in_order_traverse(tree.left, array) | |
| array.append(tree.value) | |
| in_order_traverse(tree.right, array) | |
| return array | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class BST: | |
| def __init__(self, value): | |
| self.value = value | |
| self.left = None | |
| self.right = None | |
| def remove(self, value, parent_node=None): | |
| current_node = self | |
| while current_node is not None: | |
| # value is less than the current node's value look left | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | elif parent_node.left == current_node: | |
| parent_node.left = current_node.left if current_node.left \ | |
| is not None else current_node.right | |
| elif parent_node.right == current_node: | |
| parent_node.right = current_node.left if \ | |
| current_node.left is not None else current_node.right | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | elif parent_node is None: | |
| if current_node.left is not None: | |
| current_node.value = current_node.left.value | |
| current_node.right = current_node.left.right | |
| current_node.left = current_node.left.left | |
| elif current_node.right is not None: | |
| current_node.value = current_node.right.value | |
| current_node.left = current_node.right.left | |
| current_node.right = current_node.right.right | |
| else: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | if current_node.left is not None and current_node.right is \ | |
| not None: | |
| # smallest value of right subtree | |
| current_node.value = current_node.right.get_min_value() | |
| # remove the smallest value of right subtree since it is | |
| # replacing the original node that we are removing | |
| current_node.right.remove(current_node.value, current_node) | 
NewerOlder