XpandNotes

exploring the intersection of technology and creativity

Leetcode #21 Merge Two Sorted Lists

Description You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two l...

Leetcode #206 Reverse Linked List

Description Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Constraints: The number of nodes...

Leetcode #20 Valid Parentheses

Description Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed ...

Leetcode #102 Binary Tree Level Order Traversal

Description Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). Example 1: Input: root = [3,9,20,null,null,15,7]...

Graph Theory Homework 1

1. Prove or disprove: 9, 6, 5, 5, 3, 3, 2, 1, 1 are the vertex degrees of some graph. Each edge contributes one degree to each of its two endpoints, therefore $\Sigma_{v \in V(G)}d(v)=2e(G)$, whic...

OpenCV 圖片混合

OpenCV 圖片混合的函式為: 1 cv2.addWeighted(src1, alpha, src2, beta, gamma, dst=..., dtype=...) -> dst 必要參數 src1: 第一張圖片的 numpy array。 alpha: 第一張圖片的權重。 src2: 第二張圖片的 numpy array。 beta: 第二張圖片的權...

OpenCV 讀檔、寫檔、分離 RGB 通道

安裝 opencv-python $ pip install opencv-python OpenCV 讀檔 將圖片命名為 image.jpg 並放在與下方 python 檔案同一個目錄下。 1 2 3 4 5 # showimg.py import cv2 img = cv2.imread("image.jpg") cv2.imshow("Image", img) cv2.wai...

論文翻譯 A Dynamic Priority Assignment Technique for Streams with (m, k)-Firm Deadlines

摘要 本文將會解決 scheduling multiple streams of real-time customers。首先介紹 (m, k)-firm deadlines 的概念以表達對 real-time stream 計時的限制:任何 k 個連續 customer 中至少有 m 個必須滿足他們的 deadline,則稱此 stream 擁有 (m, k)-firm deadline...

證明 Petersen graph 的圍長為 5

Prove or disprove that Petersen graph has girth 5.

Petersen graph 的定義:https://blueskyson.github.io/2021/11/12/petersen-graph/ Petersen graph 為 simple graph,故沒有 loop 與 multiple edge,也就是沒有 1-cycle 與 2-cycle,見下圖: 形成 3-cycle 需要 3 個所有元素都不...

Petersen graph 簡介

What is Petersen graph?

Def: Petersen graph 是一種 simple graph,其頂點被標記為 5 元素集合的 2 元素子集合 (2-set),邊為不共元素的 2 元素子集合對。 光看解釋會讓人摸不著頭緒,但其實概念很簡單,首先定義一個 5 元素的集合:$\{1,2,3,4,5\}$ 接著列出所有 2 元素子集合,根據 $C^5_3=10$,總共有 10 個子集合: \[\{1,2\},\{...