Docsity

Hard Problems - Algorithms and Applications in Java - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Hard Problems - Algorithms and Applications in Java - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Hard Problems

  • Some problems are hard to solve.

 No polynomial time algorithm is known.  E.g., NP-hard problems such as machine scheduling, bin packing, 0/1 knapsack.

  • Is this necessarily bad?
  • Data encryption relies on difficult to solve problems.

Cryptography

decryption algorithm

encryption message algorithm

message

Transmission Channel

encryption key

decryption key

Public Key Cryptosystem (RSA)

  • p and q are two prime numbers.
  • n = pq
  • m = (p-1)(q-1)
  • a is such that 1 < a < m and gcd(m,a) = 1.
  • b is such that (ab) mod m = 1.
  • a is computed by generating random positive integers and testing gcd(m,a) = 1 using the extended Euclid’s gcd algorithm.
  • The extended Euclid’s gcd algorithm also computes b when gcd(m,a) = 1.

RSA Encryption And Decryption

  • Message M < n.
  • Encryption key = (a,n).
  • Decryption key = (b,n).
  • Encrypt => E = Ma^ mod n.
  • Decrypt => M = Eb^ mod n.

Security Of RSA

  • Relies on the fact that prime factorization is computationally very hard.
  • Let q be the number of bits in the binary representation of n.
  • No algorithm, polynomial in q, is known to find the prime factors of n.
  • Try to find the factors of a 100 bit number.

Elliptic Curve Cryptography

(ECC)

  • Asymmetric Encryption Method
    • Encryption and decryption keys are different; one is not easily computed from the other.
  • Relies on difficulty of computing the discrete logarithm problem for the group of an elliptic curve over some finite field. - Galois field of size a power of 2. - Integers modulo a prime.
  • 1024-bit RSA ~ 200-bit ECC (cracking difficulty).
  • Faster to compute than RSA?

Satisfiability Problem

  • F = ( x 1 + x 2 + x 3 )( x 4 + x 7 + x 8 )(x 2 + x 5 )
    • F is true when x 1 , x 2 , and x 4 (for e.g.) are true.

Other Problems

  • Partition

 Partition n positive integers s 1 , s 2 , s 3 , …, s (^) n into two groups A and B such that the sum of the numbers in each group is the same.  [9, 4, 6, 3, 5, 1,8]  A = [9, 4, 5] and B = [6, 3, 1, 8]

  • NP-hard.

Traveling Salesperson Problem (TSP)

  • Let G be a weighted directed graph.
  • A tour in G is a cycle that includes every vertex of the graph.
  • TSP => Find a tour of shortest length.
  • Problem is NP-hard.

Applications Of TSP

Home city Visit city

Applications Of TSP

  • Manufacturing.
  • A robot arm is used to drill n holes in a metal sheet.

n+1 vertex TSP.

Robot Station

n-Queens Problem

A queen that is placed on an n x n chessboard, may attack any piece placed in the same column, row, or diagonal.

8x8 Chessboard Docsity.com

n-Queens Problem

8x

Difficult Problems

  • Many require you to find either a subset or permutation that satisfies some constraints and (possibly also) optimizes some objective function.
  • May be solved by organizing the solution space into a tree and systematically searching this tree for the answer.