Presentation is loading. Please wait.

Presentation is loading. Please wait.

Number Theory.

Similar presentations


Presentation on theme: "Number Theory."— Presentation transcript:

1 Number Theory

2 Prime Numbers Is x a prime? factorization How many are there?
if it is even number, .. else keep dividing factorization base of security Given N = P*Q P,Q are unique How many are there?

3 GCD & LCM

4 Modular Arithmetic (Congruences)
division? Linear Congruence e.g.) 5x = 12 mod 19 means 5x = t how to find (x, t) pairs?

5 Backtracking

6 N-Queen Problem 4-Queens Problem

7 Solution for N-Queen no solution for n < 4 n=4 case
list all case systematically test each case if it is a solution 16C4 cases – n2Cn cases better way?

8 Backtracking Solution set a vector a = (a1, a2, …, an)
let a = (a1, …, ak) add a possible solution ak+1 check validity if it is a solution, do something else check if ak+1 can generate more possible solutions if yes, add them to the solution vector else remove ak+1 4 queens: total 16 positions a1 – a16 (a11 – a44) for the first queen, a = (a11, a12, .... a44) a11 generates three positions for the second queen - a12 and a21 a22 – all fail a12 generates .....

9

10 Backtracking Efficiency
It is usually correct The issue is efficiency solution space of the n-queens problem there are n2 cells each cell either has a queen (TRUE) or not (FALSE) total combinations 2n 8-queens problem ~ 1.84 * 1019 another solution the 1st queen = 64 cases the 2nd queen = 64 cases the 8th queen = 64 cases TOTAL 648 = 2.81 * 1014 cases

11 Prunning 648 = 2.81 * 1014 is still a huge number
remove invalid case as early as possible no two queens sit on the same cell once a queen is placed, the second will be at a higher numbered cell 64C8 = * 109 can you do it more? 1st queen at the 1st row 2nd queen at the 2nd row 8th queen at the 8th row TOTAL 88 = *107 cases how about the column regulation?

12 Prunning for 4-Queens Problem

13 15-Puzzle

14 Tug of War


Download ppt "Number Theory."

Similar presentations


Ads by Google