TEN SIMPLE RULES FOR MATHEMATICAL WRITING – 笔记

Ten Rules

  • Structure rules (break it into digestible pieces)
    • Organize in segments
    • Write segments linearly
    • Consider a hierarchical development
  • Consistency rules (be boring creatively)
    • Use consistent notation and nomenclature
    • State results consistently
    • Dont underexplain – dont overexplain
  • Readability rules (make it easy for the reader)
    • Tell them what youll tell them
    • Use suggestive references
    • Consider examples and counterexamples
    • Use visualization when possible

Interesting Rules

TELL THEM WHAT YOU’LL TELL THEM

  • Keep the reader informed about where you are and where you are going
  • Start each segment with a short introduction and perhaps a road map
  • Tell them what you told them

Stanford CS143 – Compilers 笔记 1

Compiler Structure

  • Lexical Analyzer
  • Parsing
  • Semantic Analysis
  • Optimization
  • Code Generation

Lexical Analyzer

Functionality

Lexical analysis is achieved by DFA/NFA derived from regular expressions that collect substrings to produce tokens.

Steps

Step 1 – Define the finite set of tokens(integer, keyword, relation, identifier, whitespaces, brackets and stuff)

Step 2 – Form an implementation to convert strings to token/lexeme pairs, discard meaningless tokens.

Implementation of a lexical analyzer

Define regular expressions to catch lexical structures, then use DFA, NFA to implement the process of regular expressions.

Procedure – partition into tokens; input the string to get the matching result.

Problems May Emerg:

  • Ambiguity 1: multiple prefixes can be matched. Solution: maximal much policy
  • Ambiguity 2: able to be interpreted as multiple types of tokens. Solution: priority list for token types
  • Error Handling: write a regex to match all errornous strings

Finite Automata

DFA vs NFA

DFA Features:

  • One move leads to one transition exactly.
  • No epsilon-moves

NFA Features:

  • Multiple transitions are allowed with epsilon-moves.

NFA can be converted to DFA with exponentially increasing size in space.(Suppose there are \(n\) states for NFA, \(2^n – 1\) states are possible for generated DFA)

DFA can be represented as a jump table, so it is structure-trivial.

算法竞赛回忆录

现在是 2022 年 7 月 28 日的凌晨,我刚刚结束 CCPC Final 2021。打铁是毫无疑问的,Final 本来也就是去图一乐,但是这一场比赛对我的算法竞赛历程极为重要吧。

它标志了我四年算法竞赛生涯的结束。回忆着几个小时前的比赛,我记得我还在和队友讨论 SG 函数、meet-in-middle、线性基和高斯消元。「到底是怎么实现的呢?这个思路又是怎么形成的呢?」即使我几周前就决定了我在这个赛季结束之后就退役,但是在退役的最后一场比赛,明知道自己以后可能再也不会想这些东西,却还是一直在思考着。现在我一个人坐在床上打字,仔细想想才明白,原来我已经在算法竞赛中太久了,这样的思考已经成为了我每一天的习惯了。

继续阅读算法竞赛回忆录