INF4130 Algoritmer: Design og effektivitet 30th August 2018 - - PowerPoint PPT Presentation

inf4130 algoritmer design og effektivitet
SMART_READER_LITE
LIVE PREVIEW

INF4130 Algoritmer: Design og effektivitet 30th August 2018 - - PowerPoint PPT Presentation

INF4130 Algoritmer: Design og effektivitet 30th August 2018 Petter Kristiansen Praktisk info Gruppeundervisning Gruppe 1: tirsdag 12:15-14:00 Gruppe 2: torsdag 12:15-14:00, siste gang 4/10 Obliger (ca datoer, ikke fastlagt)


slide-1
SLIDE 1

INF4130 – Algoritmer: Design og effektivitet

30th August 2018 Petter Kristiansen

slide-2
SLIDE 2

Praktisk info

  • Gruppeundervisning

Gruppe 1: tirsdag 12:15-14:00 Gruppe 2: torsdag 12:15-14:00, siste gang 4/10

  • Obliger (ca datoer, ikke fastlagt)

Oblig 1: tidlig i oktober Oblig 2: sist i oktober Oblig 3: sent i november

  • Eksamen 18. desember kl. 09:00 (4 timer)
slide-3
SLIDE 3

What is This Course Really All About?

Problems Algorithms

slide-4
SLIDE 4

Problems

slide-5
SLIDE 5

Modeling

“Given a set of numbers, sort them.” Arranging elements / Sorting numbers 4, 8, 3, 13, 1, 5, 2, 3 1, 2, 3, 3, 4, 5, 8, 13 “Given a set of positive integers, sort them in ascending

  • rder.”

Given a set I of n positive integers, I = {i1, i2, … in}, sort i1, i2, … in in ascending order.

INPUT: A set I ϵ Z+of n positive integers I = {i1, i2, … in}. OUTPUT: A permutation Iꞌ of I such that iꞌj ≤ iꞌj+1, 1 ≤ j ≤ n-1. SORTING INSTANCE: A set I ϵ Z+of n positive integers I = {i1, i2, … in}. QUESTION: Is I sorted in ascending order?

slide-6
SLIDE 6

Modeling

Real world

Mathematical representation

slide-7
SLIDE 7

Modeling

Delivery routes / Hamiltonian cycles INPUT: A graph G=(V, E), with V = {v1, v2, … vn}, and E ={e1, e2, … em}, OUTPUT: A permutation Vꞌ of V such that vꞌi vꞌi+1 ϵ E for all 1 ≤ i ≤ n-1, and vꞌn vꞌ1 ϵ E. HAMILTONICITY INSTANCE: A graph G=(V, E). QUESTION: Is there a Hamiltonian cycle in G?

slide-8
SLIDE 8

Modeling

Software verification / The halting problem

HALTING INSTANCE: A computer program P, and input to the program I. QUESTION: Does program P halt when run on input I?

slide-9
SLIDE 9

Problems, Formal Languages

Computer Science Problems “Interesting”, “Natural” Problems SORTING, HAMILTONICITY, HALTING, …

graphs, numbers, logical expressions, …

Functions Sets of I/O-pairs

input

  • utput

Formal Languages Sets of YES-instances (strings)

  • utput = YES/NO
slide-10
SLIDE 10

Example, Formal Languages

SORTING

{ϵ; 1; 2; … 1,2; 1,3; 1,4; … 1,2,3; 1,2,4; 1,2,5; … …}

HAMILTONICITY

{C3; C4; … K3; K4; … …}

slide-11
SLIDE 11

Problems

Problems can be very different Problems can be modeled mathematically and represented as formal languages All formal languages are objects

  • f the same type

– A common theory and common methods become possible

Set of all Problems (Formal languages)

slide-12
SLIDE 12

Exercise: Describe Algorithms

Sorting integers INPUT: A set I ϵ Z+of n positive integers I = {i1, i2, … in}. OUTPUT: A permutation Iꞌ of I such that iꞌj ≤ iꞌj+1, 1 ≤ j ≤ n-1. INPUT: {4, 8, 3, 13, 1, 5, 2, 3}

slide-13
SLIDE 13

Exercise: Describe Algorithms

HAMILTONICITY INSTANCE: A graph G=(V, E). QUESTION: Is there a Hamiltonian cycle in G? INSTANCE1: INSTANCE2:

slide-14
SLIDE 14

Exercise: Describe Algorithms

HALTING INSTANCE: A computer program P, and input to the program I. QUESTION: Does program P halt when run on input I?

program StringMatcher (P [0:m -1], T [0:n -1]) i ← 0 j ← 0 CreateNext(P [0:m - 1], Next [n - 1]) while i < n do if P [ j ] = T [ i ] then if j = m – 1 then return(i – m + 1) endif i ← i + 1 j ← j + 1 else j ← Next [ j ] if j = 0 then if T [ i ] ≠ P [0] then i ← i + 1 endif endif endif endwhile return(-1) end StringMatcher T = Long string to search for a pattern in P = pattern program HelloWorld() start: print (“Hello World !”) goto start end HelloWorld

P1: I1: P2: I2:

slide-15
SLIDE 15

Problems and Algorithms

SORTING, HAMILTONICITY and HALTING are very different problems.

  • We found (knew?) a fast algorithm for SORTING.
  • We came up with a naive algorithm for HAMILTONICITY.
  • We really didn’t get anywhere whith HALTING.
slide-16
SLIDE 16

Problems can be divided into classes depending on how effieciently (fast, running time) they can be solved.

Problems and Algorithms

Problems

slide-17
SLIDE 17

Undecidability

1900s: Metamathematics (Mathematical studies of mathematics itself, its possibilities and limitations ) 1930s: Results on the existence and non-existence of algorithms for certain problems

– Kurt Gödel (1931): Incompleteness results. – Alan Turing (1936): «On computable numbers, with an application to the Entscheidungsproblem».

Turing’s results and techniques

slide-18
SLIDE 18

Complexity

John von Neumann (ca 1945): modern computer Jack Edmonds (1965): Paths, Trees, and Flowers Cook / Levin (1972): NP-completeness

Cook / Levin’s results and techniques

slide-19
SLIDE 19

Algorithms and Turing Machines

b 1 b b

… …

b b 1 b b

http://aturingmachine.com/

slide-20
SLIDE 20

Church’s Thesis

Algorithm ≈ Turing machine Turing machines can calculate any function that can be calculated by an algorithm, a computer program or a computer. Expressive power of programming languages A programming language (Java, C, Lisp, …) is Turing complete if it can do the same calculations as a Turing machine. If we can implement a Turing machine with our programming language, it is Turing complete. Universal computer models A computer model is Turing complete if it can do the same calculations as a Turing machine. McCulloch and Pitts have shown that neural nets can simulate Turing machines. Uncomputability If a function f can not be computed by a Turing machine, then no computer can compute f.

slide-21
SLIDE 21

Course Topics

Undecidability Complexity Problems

  • a few central ones

String Search Matching Dynamic Programming Search Strategies (A*) Game trees (Alpha – Beta, Chess) Priority Queues