Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
laborator [2020/09/08 18:47]
pdmatei
laborator [2020/09/10 17:57] (current)
pdmatei
Line 62: Line 62:
   * If a problem is **decided** by some TM, can its complement also be decided? ​   * If a problem is **decided** by some TM, can its complement also be decided? ​
   * Write a TM which accepts //is-odd// problem but which does not decide it.   * Write a TM which accepts //is-odd// problem but which does not decide it.
-  * Is the following a suitable pseudocode for a TM?  
-      * a) suitable example 
-      * b) unsuitable example (testing some behavioural property) 
   * Which of the following problems you **think** can be **accepted** and which can be **decided**?​ Use pseudocode instead of writing a TM.   * Which of the following problems you **think** can be **accepted** and which can be **decided**?​ Use pseudocode instead of writing a TM.
       * a) V [[https://​arxiv.org/​pdf/​1902.10188.pdf | Undecidable example 1]]       * a) V [[https://​arxiv.org/​pdf/​1902.10188.pdf | Undecidable example 1]]
Line 84: Line 81:
   * Write a TM pseudocode which accepts if **there exists** a word which is accepted by a given TM in **k steps**.   * Write a TM pseudocode which accepts if **there exists** a word which is accepted by a given TM in **k steps**.
     Discussion on the pseudocode     Discussion on the pseudocode
 +  * Which of the following is a suitable pseudocode for a TM:
 +<​code>​
 +Algoritm(M,​w){
 +   if size(w) > 10
 +     then if M halts for w in k steps
 +          accept.
 +
 +</​code>​
 +<​code>​
 +Algoritm(M1,​M2,​w){
 +   k = 0
 +   while true
 +       if M1(w) has the same behaviour as M2(w) after k steps
 +          then accept
 +       else k = k + 1
 +
 +</​code>​
 +<​code>​
 +Algorithm(M,​A) {
 +   // A is a finite set of words
 +   for each w in A
 +       if M(w) halts  //​undecidable! Pseudocode is ok, but this machine may not terminate
 +          then accept
 +}
 +</​code>​
 +<​code>​
 +Algorithm(M,​w) {
 +   build the machine M' such that M(x) accepts iff M'(x) does not accept, for all words x
 +   if M'(w) in 1000 steps
 +      accept
 +}
 +</​code>​
 +<​code>​
 +Algorithm(M1,​M2) {
 +    if M1 always halts then     //we know of no procedure, terminating or not, which can achieve this. This is not a proper TM/​algorithm.
 +       if M2 always halts then 
 +          accept
 +}
 +</​code>​
 +
 +  * Write the problem which is accepted by each of the above machines.
   * Write a TM pseudocode which accepts if a **given** word is accepted by two given TMs. Explain the dovetailing technique.   * Write a TM pseudocode which accepts if a **given** word is accepted by two given TMs. Explain the dovetailing technique.
  
Line 106: Line 144:
  
 ==== Notatii asimptotice ==== ==== Notatii asimptotice ====
-  * Implementari care sa ilustreze faptul ca constanta conteaza/​nuconteaza +  * (Homework) Implement mergesort and insertionsort ​in python. Use a large dataset (provided by usto test your implementation. Plot the execution times together with the functions $math[n^2] and $math[n\cdot \log{n}] using ''​gnuplot''​. What do you observe? Adjust the constants for the previous functions so that the rate of growth can be better observed.
-  * Implementari care sa ilustreze faptul ca log n >> n >> n2 >>>​ n3 +
-  * Grafice ​(in ?!)+
   * Exercitii clasice   * Exercitii clasice
  
 ==== Recurente ==== ==== Recurente ====
   * Cativa algoritmi si recurentele lor   * Cativa algoritmi si recurentele lor
 +    * Merge-sort,
 +    * Quick-sort (curs)
 +    * Exemplul cu sqrt(n) al lui Sebi.
   * Exercitii clasice   * Exercitii clasice
 +
 +==== Ammortised Analysis ====
 +  * Classical exercises
  
 ===== Part 3 - Algorithm complexity (4 labs) ===== ===== Part 3 - Algorithm complexity (4 labs) =====
  
 ==== NP completitudine ==== ==== NP completitudine ====
-  * Implementare care sa ilustreze exponentiala (backtracking);​ legatura cu MTN+  * Implement a SAT solver which encodes formulae as matrices and iterates over interpretations treating them as binary counters. Plot execution times
-  * Reduceri pentru ​SAT solvere +  * Implement a better ​SAT solver which uses BDDs to encode a formula. The variable ordering is known in advance. Plot execution times. 
-  * Exercitii clasice cu reduceri+  * Implement a k-Vertex-Cover solver using a reduction from SAT, and any of the above solvers. 
 +  * Exercitii clasice cu choice si reduceri
  
-===== Part 4 - Abstract Datatypes (labs) =====+===== Part 4 - Abstract Datatypes (labs) =====
  
 ==== TDA-uri ==== ==== TDA-uri ====
   * Conceptul de operator vs cel de functie (exercitiu in C, exercitiu in Haskell, pe Liste)   * Conceptul de operator vs cel de functie (exercitiu in C, exercitiu in Haskell, pe Liste)
 +  * (Homework) Implementare LinkedList si ArrayList in Python, impreuna cu operatii. Implementare Haskell a operatiilor,​ dupa o discutie la curs despre acestea.
   * Exercitii clasice   * Exercitii clasice