Dydaktyka
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Ćwiczenia 2, grupa śr. 14-16, 6 marca 2024 ###### tags: `SYK24` `ćwiczenia` `pwit` ## Deklaracje Gotowość rozwiązania zadania należy wyrazić poprzez postawienie X w odpowiedniej kolumnie! Jeśli pożądasz zreferować dane zadanie (co najwyżej jedno!) w trakcie dyskusji oznacz je znakiem ==X== na żółtym tle. **UWAGA: Tabelkę wolno edytować tylko wtedy, gdy jest na zielonym tle!** :::danger | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | | ----------------------:| -----| --- | --- | --- | --- | --- | --- | --- | --- | Krzysztof Chorzempa | | | | | | | | | | Maciej Ciepiela | X | | X | | X | | X | | X | Szymon Fica | X | | X | | X | | | | X | Agnieszka Grala | X | | X | | X | | | | X | Karolina Jędraszek | X | X | X | | ==X== | | X | | X | Katarzyna Jodłowska | X | | X | | X | | | | X | Dominik Kiełbowicz | | | | | | | | | | Michał Kolasa | | | | | | | | | | Rafał Krysa | X | X | | | X | | | | | Miłosz Krzysiek | ==X== | X | X | | X | | X | | X | Łukasz Kulczycki | | | | | | | | | | Leon Lepkowski | X | | X | | X | | | | ==X== | Hanna Makowska | X | | X | | X | | | | X | Jan Marek | X | | X | | X | X | | X | X | Cezary Miłek | X | | X | | X | | | | X | Anna Pierzchała | X | | X | | X | X | X | | X | Alan Pietrasz | X | X | X | X | X | X | X | X | X | Kacper Ponikowski | X | | X | | X | | | | X | Dominik Walecko | X | | X | | X | | X | | X | Michał Włodarczak | X | X | ==X== | X | X | | | | X | ::: :::info **Uwaga:** Po rozwiązaniu zadania należy zmienić kolor nagłówka na zielony. ::: ## Zadanie 1 :::success Autor: Miłosz Krzysiek ::: Suamtor prefiksowy działa na zasadzie wyliczenia wartości przeniesień w czasie logarytmicznym, a potem wykorzystaniem ich do szybkiego wyliczenia wyniku. Według definicji z wykładu: ![Screenshot from 2024-03-06 14-19-58](https://hackmd.io/_uploads/r10YT1Laa.png) Jesteśmy w stanie wyliczyć bit przeniesienia na podstawie funkcji popagacji i generacji. te wartości będą nam potrzebne do liczania kolejnych wartości przeniesień. Naiwne wyliczenie tego nie da nam znaczącej przewagi, ale istnieje własność która umożliwi nam wyliczenie wartości Ci szybciej: ![Screenshot from 2024-03-06 14-21-24](https://hackmd.io/_uploads/rkQJCyU66.png) Te wzory pozwalają nam na wyliczenie wszystkich wartości przeniesienia w czasie logarytmicznym (według obrazka): ![Screenshot from 2024-03-06 14-22-05](https://hackmd.io/_uploads/rJbMRJL6p.png) Po obliczeniu wartości Ci jesteśmy w stanie wyliczyć wartości bitów wyników równolegle, więc wykonujemy dodawanie w czasie logarytmicznym. **Analiza bramek** ![429440674_414353907931190_7676363564946709091_n](https://hackmd.io/_uploads/rJfwRJU66.jpg) **Analiza czasowa** ![429446870_926455185729118_8475959463675948063_n](https://hackmd.io/_uploads/SkQF01LpT.jpg) ## Zadanie 2 :::success Autor: Rafał Krysa ::: ![Screenshot 2024-03-06 at 14-22-32 SYK24 - Lista 2 - SYK24 - Lista 2.pdf](https://hackmd.io/_uploads/r1970J86T.png) ![z2l2](https://hackmd.io/_uploads/rJi4AJLTp.png) ## Zadanie 3 :::success Autor: Michał Włodarczak ::: ![Tresc zad3](https://hackmd.io/_uploads/r1n2a1Ia6.png) **1** ![Part 1 zad3](https://hackmd.io/_uploads/HkHTTyLTT.png) **2** ![Part 2 zad3](https://hackmd.io/_uploads/HkppTkUaa.png) **Połączenie 1 i 2** ![Part 3 zad3](https://hackmd.io/_uploads/HJGCak86p.png) Rozmiar: 1. n bloków "A" => n*4 (4 bramki w bloku "A") 2. ilość bloków "B" dąży do n => "B"* n*(1/2 + 1/4 + 1/8 ...) = "B"* n * 1 = n * 5 (5 bramek w bloku "B") 3. Łącznie rozmiar => 4n+5n = 9n Czas: 2*logn + 1 => O(logn) przejscie 2 razy po drzewie o wysokosci logn oraz wyliczenie sumy na koniec ## Zadanie 4 :::success Autor: Alan Pietrasz ::: ![Syk L2 Z4](https://hackmd.io/_uploads/Hk9-wgIT6.png) ## Zadanie 5 :::success Autor: Karolina Jędraszek ::: *Przedstaw strukturę układu i algorytm działania układu mnożącego dwie liczby w naturalnym kodzie binarnym (tj. liczby nieujemne, bez znaku). Zapisz ten algorytm w postaci pseudokodu (użyj zmiennych reprezentujących rejestry układu, zmiennych pomocniczych, instrukcji przypisania, dodawania, przesunięcia bitowego i pętli) Wykonaj mnożenie za pomocą tego algorytmu liczb 4-bitowych A = 9 i B = 3.* ![Screenshot 2024-03-05 at 11.00.39](https://hackmd.io/_uploads/S1v8pP4p6.png) Mnożymy A = a_(n-1) + ... + a_0 B = b_(n-1) + ... + b_0 Kroki (Appendix): 1) Jeśli najmniej znaczący bit A to jeden, to dodaj do P B w postaci b_(n-1)...b_0, wpp do P dodaj 0...0. Zapisz sumę w P. 2) Rejestry P i A są przesunięte w prawo, przy czym C_out sumy zostaje przeniesione do najbardziej znaczącego bitu w P, najmniej znaczący bit P (przed przesunięciem) do najbardziej znaczącego bitu A (po przesunieciu A). **Algorytm(A, B):** ``` wczytaj A, B; P = 0; Dla i = 0, 1, ... n-1: Jeśli najmniej znaczący bit rejestru A (a_(n-1-i)) to 1: P = P + B C_out = MSB(P) //reszta z dodawania Wpp: P = P + 0...0 C_out = 0 LSB_P = LSB(P) A = LSB_P,a_(n-1),...,a_1 P = C_out,p_(n-1),...,p_1 Zwróć A skelone z P ``` **Dla A = 9 i B = 3:** > Rejestr A: 1001 > Rejestr B: 0011 > Rejestr P: 0000 > n = 4 > > Dla i=0: > LSB(A) = 1 > P = 0011, C_out = 0, LSB( P ) = 1 > P = 0001, > A = 1100 > > > Dla i=1: > LSB(A) = 0 > P = 0001, C_out = 0, LSB( P ) = 1 > P = 0000 > A = 1110 > > Dla i=2: > LSB(A) = 0 > P = 0000, C_out = 0, LSB( P ) = 0 > P = 0000 > A = 0111 > > Dla i=3: > LSB(A) = 1 > P = 0000+0011 = 0011, C_out = 0, LSB( P ) = 1 > P = 0001 > A = 1011 wynik: (P sklejone z A) 00011011 = 27 ## Zadanie 6 :::success Autor: Jan Marek ::: ![image](https://hackmd.io/_uploads/Byx5MoNpT.png) **a)** ![image](https://hackmd.io/_uploads/SJLE37M6a.png) Zasada działania taka sama jak przy mnożeniu dwóch liczb w NKB, ale zamiast przesunięcia logicznego o 1 bit rejestrów (Carry-out, P, A) - wykonujemy przesunięcie arytmetyczne tych rejestrów. - Rejestry A, B (n-bitowe liczby A, B do wymnożenia) - Rejestr P (również n-bitowy) - wypełniony zerami - Rejestr Carry-out (1-bitowy) Rejestry Carry-out, P, A razem tworzą jeden rejestr (2n+1)-bitowy. - przesuniecie logiczne: d~2~ d~1~ d~0~ $=>$ 0 d~2~ d~1~ - przesunięcie arytmetyczne: Rozmazujemy (kopiujemy) bit znaku d~2~ d~1~ d~0~ $=>$ d~2~ d~2~ d~1~ W danym cyklu działanie jest następując: - Mnożymy a~i~ = LSB(A) (najmniej znaczący bit liczby A) przez wartość B (czyli liczymy a~i~B). - Uyskaną wartość sumujemy z aktualną wartością w rejestrze P (czyli teraz w P będzie a~i~B + P). - W rejestrze Carry-out zapamiętujemy przeniesienie z tego sumowania. - Na końcu cały rejestr (Carry-out, P, A) przesuwamy o 1 bit w prawo (przesunięcie **arytmetyczne**) Cykle powtarzamy n razy. ```java= A[0...n-1] B[0...n-1] P[0...n-1] = 0 C_out for (i = n - 1; i >= 0; i--) { P' = A[i] * B P += P' C_out = "przeniesienie z P + P'" C_out >> 1 P >> 1 A >> 1 // oczywiście traktujemy to wszystko jako 1 rejestr } return P, A // P - starsze n bitów, A - młodsze n bitów ``` --- A = 9~10~ = 1001~2~ B = -3~10~ = 1101~U2~ P = 0000~2~ 0000 1001 I cykl: 1101 1001 +P 1110 1100 >> II cykl: 1110 1100 +P (+0) 1111 0110 >> III cykl: 1111 0110 +P (+0) 1111 1011 >> IV cykl: 1100 1011 +P 1110 0101 >> Wynik -> 1110 0101~U2~ = $(-2)^7 + 2^6 + 2^5 + 2^2 + 2^0$ = $-128 + 64 + 32 + 4 + 1$ = $-27$ **b)** $$A*B = (-2^{n-1}*a_{n-1} + \Sigma^{n-2}_{i=0} 2^{i}*a_{i}) * B = (-2^{n-1}*a_{n-1}) * B + (\Sigma^{n-2}_{i=0} 2^{i}*a_{i}) * B $$ Niech $A' = \Sigma^{n-2}_{i=0} 2^{i}*a_{i}$. Wtedy $A*B = ((-2^{n-1}*a_{n-1}) * B) + A'*B$. Mnożymy $A'*B$ algorytmem z punktu a) --- liczba kroków algorytmu to $n-1$. W n-tym kroku odejmujemy od naszej sumy częśćiowej liczbę $a_{n-1}*B$. Jak przekształcić sumator w układ odejmujący? $C-D = C + (-D)$, zapis bitowy liczby $-D = \neg(D) + 1$ Czyli $C-D = C + \neg(D) + 1$. ## Zadanie 7 :::success Autor: Anna Pierzchała ::: ![image](https://hackmd.io/_uploads/rJqq0J8Tp.png) ## Zadanie 8 :::success Autor: Alan Pietrasz ::: ![Syk L2 Z8](https://hackmd.io/_uploads/HJeqRkI6a.png) ## Zadanie 9 :::success Autor: Leon Lepkowski ::: ![image](https://hackmd.io/_uploads/ryeVwQSpp.png) ![image](https://hackmd.io/_uploads/HkSQPmrpp.png) ![image](https://hackmd.io/_uploads/HkmrwXBpT.png) ### Jak działa algorytm dzielenia Mamy rejestrny A, B i P. W A trzymamy liczbę dzieloną, w B liczbę przez którą dzielimy, a w P dajemy 0. W każdym kroku (jest ich n dla n bitowych liczba): 1. Robimy shift (P, A) w lewo 2. P = P - B 3. Jeżeli P jest ujemne to najmniejszy bit A ustawiamy na 0, a w przeciwnym wypadku na 1 4. Jeżeli P jest ujemne to zapisujemy tam P + B Po wykonaniu wszystkich (n) cykli nasz wynik będzie w A, a P będzie miało resztę z dzielenia. ![image](https://hackmd.io/_uploads/rJ08Cmrp6.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully