Algorithm Analysis: P and NP

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Hvað er átt við með ákvörðunarverkefni í samhengi við reiknirit?

  • Verkefni þar sem útkoman er rauntala.
  • Verkefni þar sem útkoman er annaðhvort já eða nei. (correct)
  • Verkefni þar þarf að finna stysta veg milli tveggja punkta.
  • Verkefni þar sem útkoman er listi af tölum.

Hvernig er tímaflækja reiknirits oftast mæld?

  • Með því að mæla meðaltíma yfir mörg keyrslutilfelli.
  • Með því að mæla versta tilfellis tíma. (correct)
  • Með því að mæla minnsta mögulega minnisnotkun.
  • Með því að mæla hraðasta tíma sem reikniritið getur keyrt.

Hvað táknar $T(n)$ í samhengi við reiknirit?

  • Besti tími sem reikniritið getur keyrt.
  • Meðaltími sem reikniritið keyrir yfir öll möguleg inntök.
  • Minnsta mögulega minnisnotkun reikniritsins.
  • Versti tími sem reikniritið getur keyrt miðað við inntaksstærð $n$. (correct)

Hvað er átt við með 'margliðutíma' í flækjugreiningu reiknirita?

<p>Tíminn sem það tekur reiknirit að leysa verkefni vex í margliðufalli með stærð inntaksins. (B)</p> Signup and view all the answers

Hvað þýðir það ef verkefni er í flokknum P ('polynomial time')?

<p>Til er reiknirit sem leysir verkefnið í margliðutíma. (A)</p> Signup and view all the answers

Hver er munurinn á Euler hring og Hamilton hring í grafi?

<p>Euler hringur fer í gegnum allar brúnir nákvæmlega einu sinni, en Hamilton hringur fer í gegnum alla hnúta nákvæmlega einu sinni. (C)</p> Signup and view all the answers

Hvers vegna er 'brute force' aðferðin ekki talin hagkvæm leið til að finna Hamilton hring í stóru grafi?

<p>Vegna þess að fjöldi mögulegra hringa vex mjög hratt með stærð grafsins. (B)</p> Signup and view all the answers

Hver er munurinn á því að ákvarða hvort tiltekið graf inniheldur Euler hring á móti Hamilton hring?

<p>Að finna Euler hring er í flokknum P, en að finna Hamilton hring er í flokknum NP. (A)</p> Signup and view all the answers

Gefin tala $N$, hver er tímaflækjan við að athuga hvort $N$ sé frumtala með því að deila í hana með öllum tölum frá 2 upp í $\sqrt{N}$?

<p>$O(\sqrt{N})$ (C)</p> Signup and view all the answers

Hvað er átt við með 'stærð inntaks' þegar tala $N$ er gefin sem inntak í reiknirit?

<p>Fjöldi bita sem þarf til að tákna $N$ í tvíundakerfi. (C)</p> Signup and view all the answers

Hver er áætluð stærð í bitum fyrir tölu $N$?

<p>$\log_2(N)$ (A)</p> Signup and view all the answers

Ef reiknirit hefur tímaflækju $O(\sqrt{N})$, og stærð inntaks er $n = \log_2(N)$, hver er þá tímaflækjan í tilliti til $n$?

<p>$O(2^{n/2})$ (A)</p> Signup and view all the answers

Hvað þýðir það að verkefni sé í flokknum NP?

<p>Ef svarið er já, þá er til sönnun sem hægt er að staðfesta í margliðutíma. (B)</p> Signup and view all the answers

Ef Hamilton-leið er í NP, hvað þýðir það?

<p>Ef tiltekin leið er Hamilton-leið, þá er hægt að staðfesta það í margliðutíma. (B)</p> Signup and view all the answers

Hvað einkennir co-NP flokkinn?

<p>Ef svarið er nei, þá er til sönnun sem hægt er að staðfesta í margliðutíma. (D)</p> Signup and view all the answers

Ef tala $N$ er ekki frumtala, hvað felur sönnun þess í sér?

<p>Að finna tvær tölur $a$ og $b$, stærri en 2, þannig að $N = a * b$. (B)</p> Signup and view all the answers

Hvað er átt við með því að frumtölur séu í bæði NP og co-NP?

<p>Það er bæði auðvelt að sanna að tala sé frumtala og að tala sé ekki frumtala í margliðutíma. (D)</p> Signup and view all the answers

Hvað felur í sér að öll verkefni í P eru einnig í NP?

<p>Að öll verkefni sem hægt er að leysa í margliðutíma, geta haft sönnun sem hægt er að staðfesta í margliðutíma. (B)</p> Signup and view all the answers

Ef verkefni A er í P, hvað þýðir það fyrir sönnun á tilviki af A?

<p>Það er engin þörf á sönnun, þar sem hægt er að reikna svarið í margliðutíma. (D)</p> Signup and view all the answers

Hvað er CircuitSAT verkefnið?

<p>Að finna inntak fyrir gefna rafrás sem gefur útkomuna 1. (A)</p> Signup and view all the answers

Ef CircuitSAT er í NP, hvað þýðir það?

<p>Ef tiltekin inntaksgildi gefa útkomuna 1, þá er hægt að staðfesta það í margliðutíma. (B)</p> Signup and view all the answers

Hver er munurinn á P og NP vandamálum?

<p>P vandamál er hægt að leysa í margliðutíma, en fyrir NP vandamál er hægt að sannreyna lausn í margliðutíma ef hún er gefin. (C)</p> Signup and view all the answers

Hver er skilgreiningin á NP-fullkomnum (NP-complete) vandamálum?

<p>Vandamál sem er bæði í NP og hægt er að umbreyta öllum öðrum NP vandamálum í það í margliðutíma. (B)</p> Signup and view all the answers

Hvað myndi það þýða ef sýnt væri fram á að P = NP?

<p>Öll vandamál sem hægt er að sannreyna lausn fyrir í margliðutíma, væri einnig hægt að leysa í margliðutíma. (D)</p> Signup and view all the answers

Hver er helsti munurinn á ákvörðunarvandamáli (decision problem) og hagræðingarvandamáli (optimization problem)?

<p>Ákvörðunarvandamál spyrja já/nei spurningar en hagræðingarvandamál leita að bestu lausn. (A)</p> Signup and view all the answers

Hvaða fullyrðing er sönn um samband P, NP og NP-fullkominna vandamála?

<p>Öll P vandamál eru í NP. (C)</p> Signup and view all the answers

Hvað er 'reducible' í samhengi við flækjustig NP vandamála?

<p>Að vandamáli A er hægt að breyta í vandamál B þannig að ef B er leyst, þá er A einnig leyst. (A)</p> Signup and view all the answers

Hver er munurinn á flækjustiginu $O(n)$ og $O(2^n)$?

<p>$O(2^n)$ vex hraðar með inntaksstærð en $O(n)$. (D)</p> Signup and view all the answers

Hver af eftirfarandi fullyrðingum er sönn um samband NP og co-NP?

<p>Ef P = NP, þá er NP = co-NP. (C)</p> Signup and view all the answers

Hvað er átt við með heildsölu reikniriti (heuristic algorithm)?

<p>Reiknirit sem finnur hugsanlega góða lausn, en ekki er víst að hún sé sú besta. (A)</p> Signup and view all the answers

Af hverju er dulkóðun mikilvæg í nútíma tölvunarfræði?

<p>Til að tryggja að gögn séu ólæsileg fyrir óviðkomandi. (B)</p> Signup and view all the answers

Hver er helsta áskorunin við að takast á við NP-fullkomin vandamál í raunveruleikanum?

<p>Þau taka of langan tíma að leysa fyrir stór inntök. (A)</p> Signup and view all the answers

Hvað er átt við með 'approximationsreiknirit' (approximation algorithm)?

<p>Reiknirit sem finnur lausn sem er innan ákveðins vikmarka frá bestu lausn. (D)</p> Signup and view all the answers

Ef þú ert með NP-fullkomið vandamál, hvaða aðferðir gætir þú notað til að takast á við það?

<p>Leita að approximationsreiknirit eða heildsölu reikniriti. (A)</p> Signup and view all the answers

Flashcards

Problem Solving

For every problem, we can often find an algorithm that solves it.

Decision Problem

A problem where the answer is either yes or no.

Worst-Case Time

Measuring an algorithm's efficiency by considering the worst-case scenario time complexity.

P (Polynomial Time)

All problems for which there exists an algorithm with a time complexity of O(n^c) for some constant c > 0.

Signup and view all the flashcards

Hamilton Cycle

There is a cycle in the network that visits all nodes exactly once.

Signup and view all the flashcards

AKS Primality Test (2002)

Primes is in P, meaning primality testing can be done in polynomial time.

Signup and view all the flashcards

NP (Nondeterministic Polynomial Time)

Problems where, if the answer is yes, there is a proof that can be verified in polynomial time.

Signup and view all the flashcards

Hamiltonian Path in NP

If the answer is yes, there is a proof that can be verified in polynomial time. Hamiltonian Path is NP.

Signup and view all the flashcards

co-NP

Problems where, for the 'no' answer, there exists a proof that can be verified in polynomial time.

Signup and view all the flashcards

N is not prime

Every number that isn't prime has 2 numbers higher than 2 that it can be divided by.

Signup and view all the flashcards

CircuitSAT

CircuitSAT is in NP

Signup and view all the flashcards

P and NP

All problems in P are also in NP

Signup and view all the flashcards

Study Notes

Greining Reiknirita: P og NP

  • The text discusses the analysis of algorithms, focusing on the complexity classes P and NP
  • It's attributed to Páll Melsted in 2025.

P

  • For every problem, there is often an algorithm that solves the problem.
  • It introduces the concept of decision problems, problems for which the answer is either yes or no.

Defining "P"

  • P is a complexity class
  • If an algorithm for a problem exists, the worst-case time measures how long the algorithm takes to complete.
  • T(u) = max {time spent to read A}, where A is a case at size n.
  • n is typically the number of nodes in a network or the number of bits needed to represent G.

P (Polynomial Time)

  • P includes all problems for which there is an algorithm with T(n) = O(n^c), where c is a constant greater than 0
  • This means the running time is polynomial
  • All the problems are in P

Euler vs Hamilton

  • A graph G = (V, E) is given with n nodes and O(n²) edges.
  • The task is to find if there's a circuit/ring in the network that goes through all the nodes (Hamilton) or every edge (Euler) exactly once.
  • Euler has a "simple" algorithm that decides on a polynomial time O(|V| + |E|).
  • Hamilton, why not a brute force approach?
    • Testing all combinations results in (n-1)!
  • n! >= 2^n, so that isn't possible.

Frumtölur (Prime Numbers)

  • The prime numbers problem: Given a number N, is it a prime number?
  • For i = 2 to √N, if N % i == 0, return False. - Return True.
  • The time complexity is √N
  • n = log₂(N) bits are the size of N
    • √N = N^(1/2) = (2^(log₂(N)))^(1/2) = (2^n)^(1/2) = 2^(n/2)
  • Primes is in P ((AKS 2002))

NP

  • NP includes all problems where, if the answer is yes, there is proof that can be verified in polynomial time.
  • The Hamilton path problem is in NP
    • Given a graph G = (V, E), is there a path through v₁,..., vₙ, where vᵢ ≠ vⱼ for i ≠ j, and (vᵢ, vᵢ₊₁) ∈ E?
    • n is the number of nodes; verify all nodes for different solutions.
  • co-NP is the same, except that the "no" answers have a proof.

Primes and NP

  • Primes are in co-NP: If N is not prime, then there exist a, b >= 2 such that N = a * b
  • The proof (witness, Kvittun) is a, b, which, when multiplied, result in N
    • a and b each have n bits to calculate the result
    • O(n²) time makes verification possible
  • Therefore, primes are in both NP and co-NP.

Relationship Between P and NP

  • All problems in P are also in NP.
  • If the decision A is in P, then there is an algorithm R that calculates in polynomial time that solves A.
  • If an instance of A is yes, the witness is Ø (empty set), which verifies using R.
  • P ⊆ NP, P ⊆ co-NP

CircuitSAT

  • The input is a circuit K that takes in bit inputs x₁, ..., xₙ.
  • Task is: Are there values for the bits x₁ = a₁, ..., xₙ = aₙ that give the answer 1?
  • This is in NP.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Leiningen Versus the Ants Flashcards
13 questions
Algorithms: P and NP
38 questions

Algorithms: P and NP

AuthenticConnotation9159 avatar
AuthenticConnotation9159
Computational Complexity Theory
36 questions
Marketing versus Verkoop: de 4 P's
25 questions

Marketing versus Verkoop: de 4 P's

ThumbUpEvergreenForest8211 avatar
ThumbUpEvergreenForest8211
Use Quizgecko on...
Browser
Browser