academic integrity - university of virginia
TRANSCRIPT
![Page 1: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/1.jpg)
Academic Integrity
β’ Collaboration Encouraged!
β Groups of up to 5 per assignment (you + 4)
β List your collaborators (by UVA computing ID)
β’ Write-ups/code written independently
β DO NOT share written notes / pictures / code
β DO NOT share documents (ex: Overleaf)
β’ Be able to explain any solution you submit!
β’ DO NOT seek published solutions online
![Page 2: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/2.jpg)
Late Policy
β’ By default, late submissions not accepted
β’ If something comes up that prevents you from submitting quality work on time, let me know whatβs going on
![Page 3: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/3.jpg)
Exams
β’ No exams
![Page 4: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/4.jpg)
Regrades
β’ Conducted using the submission system:
β Submit within 5 days of receiving your grade
β Request a regrade if the rubric was misapplied
![Page 5: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/5.jpg)
Course webpage
β’ www.cs.virginia.edu/~njb2b/cs4102/su20
![Page 6: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/6.jpg)
Extra βcreditβ
β’ Given for extraordinary acts of engagement β Good questions/comments
β Quality discussions
β Analysis of current events
β References to arts and music
β Extra credit projects
β Slide corrections
β Etc. Just ask!
β’ Submit to me via email
β’ Will be used for qualitative grade adjustments
![Page 7: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/7.jpg)
Warm up
Can you cover an 8 Γ 8 grid with 1 square missing using βtrominoes?β
Can you cover this?
With these?
CS4102 Algorithms Fall 2020
![Page 8: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/8.jpg)
Where does it end?
β’ I have a pile of string
β’ I have one end of the string in my hand
β’ I need to find the other end
β’ How can I do this efficiently?
![Page 9: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/9.jpg)
Rope End Finding
1. Set aside the already obtained end
2. Separate the pile of rope into 2 piles, note which connects to the known end (call it pile A, the other pile B)
3. Count the number of strands crossing the piles
4. If the count is even, pile A contains the end, else pile B does
Repeat on pile with end
![Page 10: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/10.jpg)
How efficient is it?
β’ π π = πππ’ππ‘(π) + ππ
2
β’ π π = 5 + ππ
2
β’ Base case: π 1 = 1
![Page 11: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/11.jpg)
Letβs solve the recurrence!
π π = 5 + π(π 2 )
π 1 = 1
5 + π(π 4 )
5 + π(π 8 )
1
log2 π
π π = 5
log2π
π=0
+ 1 = 5 log2 π + 1
![Page 12: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/12.jpg)
Algorithm Running Times
β’ We canβt just measure running time with a number
β’ Why shouldnβt we say: βThe running time of this algorithm is 8.β?
β’ Units: 8 what? Seconds?
β’ What if the input is large?
β’ Algorithm running times are functions β Domain: βsizesβ of the algorithmβs input
β Co-Domain: βcountsβ of operations
β’ We want to be able to say βalgorithm 1 is faster than algorithm 2β
β’ How can we compare functions?
![Page 13: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/13.jpg)
Asymptotic Notation*
β’ π(π π ) β At most within constant of π for large π β {functions π|β constants π, π0 > 0 s.t. βπ > π0, π π β€ π β π(π)}
β’ Ξ©(π π ) β At least within constant of π for large π β {functions π|β constants π, π0 > 0s.t. βπ > π0, π π β₯ π β π(π)}
β’ Ξ π π β βTightlyβ within constant of π for large π
β Ξ© π π β© π(π π )
*CLRS Chapter 3
![Page 14: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/14.jpg)
π(π) = π(π π )
π(π) = Ξ(π π )
π(π) = Ξ©(π π )
![Page 15: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/15.jpg)
Asymptotic Notation
β’ π(π π ) β Below any constant of π for large π β {functions π|β constants π, βπ0 s.t. βπ > π0, π π < π β π(π)}
β’ π(π π ) β Above any constant of π for large π β {functions π|β constants π, βπ0 s.t. βπ > π0, π π > π β π(π)}
β’ π π π ?
β π(π π ) β© π(π π ) = β
![Page 16: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/16.jpg)
Asymptotic Notation Example
β’ Show: π log π β π π2
![Page 17: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/17.jpg)
Asymptotic Notation Example
β’ To Show: π log π β π π2
β Technique: Find π, π0 > 0 s.t. βπ > π0, π log π β€ π β π2
β Proof: Let π = 1, π0 = 1. Then, π0 log π0 = 1 log 1 = 0, π π0
2 = 1 β 12 = 1, 0 β€ 1. βπ β₯ 1, log π < π β π log π β€ π2 β‘
Direct Proof!
![Page 18: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/18.jpg)
Asymptotic Notation Example
β’ Show: π2 β π π
![Page 19: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/19.jpg)
Asymptotic Notation Example
β’ To Show: π2 β π π
β Technique: Contradiction
β Proof: Assume π2 β π π . Then βπ, π0 > 0 s. t. βπ > π0, π2 β€ ππ
Let us derive constant π. For all π > π0 > 0, we know: ππ β₯ π2, π β₯ π. Since π is lower bounded by π, it is not a constant. Contradiction. Therefore π2 β π π . β‘
Proof by Contradiction!
![Page 20: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/20.jpg)
Asymptotic Notation Example
β’ π π π = {functions π βΆ β constants π > 0, βπ0 s.t. βπ > π0, π π < π β π(π)}
β’ Show: π log π β π π2
β given any π find a π0 > 0 s.t. βπ > π0, π log π < π β π2
β Find a value of π in terms of π: β’ π log π < π β π2
β’ log π < π β π
β’log π
π< π
β For a given π, select any value of π0 such that log π
π< π
![Page 21: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/21.jpg)
Trominoes Puzzle Solution
What about larger boards?
2π
2π
![Page 22: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/22.jpg)
Trominoes Puzzle Solution
Divide the board into quadrants
![Page 23: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/23.jpg)
Trominoes Puzzle Solution
Place a tromino to occupy the three quadrants without the missing piece
![Page 24: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/24.jpg)
Trominoes Puzzle Solution
Each quadrant is now a smaller subproblem
![Page 25: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/25.jpg)
Trominoes Puzzle Solution
Solve Recursively
![Page 26: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/26.jpg)
Divide and Conquer
Our first algorithmic technique!
![Page 27: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/27.jpg)
Trominoes Puzzle Solution
![Page 28: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/28.jpg)
Divide and Conquer*
β’ Divide: β Break the problem into multiple subproblems, each smaller instances of
the original
β’ Conquer: β If the suproblems are βlargeβ:
β’ Solve each subproblem recursively
β If the subproblems are βsmallβ: β’ Solve them directly (base case)
β’ Combine: β Merge together solutions to subproblems
*CLRS Chapter 4
When is this a good strategy?
![Page 29: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/29.jpg)
Analyzing Divide and Conquer
1. Break into smaller subproblems
2. Use recurrence relation to express recursive running time
3. Use asymptotic notation to simplify
β’ Divide: π·(π) time,
β’ Conquer: recurse on small problems, size π
β’ Combine: C(π) time
β’ Recurrence: β π π = π· π + π(π ) + πΆ(π)
![Page 30: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/30.jpg)
Recurrence Solving Techniques
Tree
Guess/Check
βCookbookβ
30
?
![Page 31: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/31.jpg)
Merge Sort
β’ Divide: β Break π-element list into two lists of π 2 elements
β’ Conquer: β If π > 1:
β’ Sort each sublist recursively
β If π = 1: β’ List is already sorted (base case)
β’ Combine: β Merge together sorted sublists into one sorted list
31
![Page 32: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/32.jpg)
Merge β’ Combine: Merge sorted sublists into one sorted list β’ We have:
β 2 sorted lists (πΏ1, πΏ2) β 1 output list (πΏππ’π‘)
While (πΏ1 and πΏ2 not empty): If πΏ1 0 β€ πΏ2[0]: πΏππ’π‘.append(πΏ1.pop()) Else: πΏππ’π‘.append(πΏ2.pop()) πΏππ’π‘.append(πΏ1) πΏππ’π‘.append(πΏ2)
32
π(π)
![Page 33: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/33.jpg)
Analyzing Merge Sort
1. Break into smaller subproblems 2. Use recurrence relation to express recursive running time 3. Use asymptotic notation to simplify
β’ Divide: 0 comparisons
β’ Conquer: recurse on 2 small subproblems, size π
2
β’ Combine: π comparisons β’ Recurrence:
β π π = 2 ππ
2+ π
33
![Page 34: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/34.jpg)
Recurrence Solving Techniques
Tree
Guess/Check
βCookbookβ
34
?
![Page 35: Academic Integrity - University of Virginia](https://reader033.vdocuments.us/reader033/viewer/2022042120/6257ed6b3d13f334324dffc7/html5/thumbnails/35.jpg)
Tree method
35
π total / level
log2 π levels of recursion
π
π π = 2π(π
2 ) + π
π π = π
log2 π
π=1
= π log2 π
π 2 π 2
π 4 π 4 π 4 π 4
β¦
β¦
β¦
β¦
1 1 1 β¦ 1 1 1
π
π
2
π
2
π
4
π
4
π
4
π
4
1 1 1 1 1 1