2016년 12월 29일 목요일

2. Models of Computation, Document Distance





Models of Computation, Document Distance


Goals

  1. What’s an algorithm and time?
  2. RAM & Pointer Machine
  3. Document Distance


What’s an algorithm?


- Mathematical abstraction of computer program
- Computational procedure to solve a problem


Model of Computation

Def) set of allowable operations used in computation and their respective costs.(https://en.wikipedia.org/wiki/Model_of_computation)
- cost (time, space, … ) of each operation
- cost of algorithm = sum of operations costs

RAM & Pointer Machine


Random Access Machine (RAM)
- modelled by a big array
- ϴ(1) registers (each 1 word
- In ϴ(1) time, can load word / compute / store …
- word : w >=lg(mem.size) bits
- realistic & powerful -> implement abstraction

Pointer Machine
- dynamically allocated objects
- object has O(1) fields
- field = word or pointer to object / NULL

Python

  • “List” is actually array (RAM)
    • L[i] = L[i] + 5 -> ϴ(1) time
  • object with O(1) attributes (Pinter machine)
    • x = x.next -> ϴ(1)
  • List
    • L.append(x) -> ϴ(1)
    • L = L1 + L2  -> ϴ(1+|L1|+|L2|)
    • L1.extend(L2) -> ϴ(1 + |L1|)
    • L2 = L1[i:j] : O(L)
    • b = x in L / L.index(x) / L.find(x) : O(|L|)
    • len(L) -> ϴ(1)
    • L.sort() -> ϴ(|L|lg(|L|))
      • via comparison sort
  • dict
    • D[key] = val -> ϴ(1) time with high probability
  • set / heap(lec4) / long(lec11)


Document Distance


[MIT 6.006 Introduction to Algorithms, Fall 2011, http://ocw.mit.edu/6-006F11]

2016년 12월 27일 화요일

1. Algorithmic Thinking, Peak Finding

Algorithmic Thinking, Peak Finding

Course Overview

Algorithm : procedures for solving large scale problem


Contents

  1. Algorithmic thinking
  2. Sort & Trees
  3. Hashing
  4. Numerics
  5. Graphs
  6. Shortest Paths
  7. Dynamic Programming


Divide & Conquer

T(n) = T(n/2) + ϴ(1)
= ϴ(1) + ϴ(1) + ··· + ϴ(1) → [ # of ϴ(1) is lg(n)]
= ϴ(lg(n))✓ lg(n) means log2(n)

2015년 12월 6일 일요일

블로그

요즘 여러 프로젝트를 진행하면서 생활한다.
프로젝트를 하면서 인터넷에 있는 블로그들의 도움을 참 많이 받는다.

내 프로젝트들도 누군가에게 도움이 됐으면 하는 바람에 블로그를 시작한다.

홈