- Type
- Final term past paper
- Course
- CS521 Web Systems and Technologies
- Size
- PDF 2.5 MB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
Preview text
Text from pages 1, 3, 4 of 14. Download the file for all 14 pages.
√2 lg 𝑛 lg 𝑛 1/ lg 𝑛
lim > 0
Small-o
lim
Big-Ω lim = 𝑐 ≥ 0
(non-negative constant)
Small-𝜔
lim = 0
Big-Θ lim = 𝑐
lg 𝑛 > (√2) > 2
Divide and Conquer – recurrences:
Break a problem into sub-problems, solve sub problems and merge solutions.
Solving Recurrences:
1. Substitution method:
Substitute 𝑇-terms in the recurrence by the assumption, using constants, and derive upper / lower bounds (or
both). Example:
𝑛
𝑏
𝑏 𝑘=1
𝑘=0
Useful math:
𝑛 𝑛
Harmonic series: ∑𝑛
1 = Θ(lg 𝑛) 𝑛+1
Sorting algorithms:
Insertion Sort:
𝑛 (𝑞 −1) 𝑞−1 when 𝑛 = ∞∶ 𝑎
Each element is pushed as far as possible to the left (sorted) part of the array.
Running time: 𝑂(𝑛2) worst-case (when sorted in reverse), Ω(𝑛) best-case (when already sorted).
Merge-sort:
Divide the sequence into two 𝑛/2 sequences, apply the algorithm recursively and merge solutions.
Quick Sort:
𝑥 – the pivot.
Preferable over merge-sort, as it sorts in-place.
For 𝛼 = 2 we get a balanced tree.
and returns the index of
Heap:
Left filled structure that satisfies partial order (node > its children, no particular relation between children).
Height is lg 𝑛: the cost of insertion, extract-max, delete.
𝑛
Remove-max: remove root and put last node of the heap in its place. Heapify it down, each level switching with the greater child of the two until satisfies heap properties.
Build-heap: for node 𝑛/2 down to 1, heapify down. Amortized analysis – each level 𝑘 but lowest will be visited at most
Heap-sort:
Build a heap and then run ~𝑛 times: Swap the max with the last element, decrease heap size by 1 and heapify the new
root down. Result: the array is sorted.
Selection problems:
The Select algorithm for finding the 𝑖th o.s.:
Find the median for each group and store in 𝐴′.
𝑛
A general recurrence (for constants other than 5):
Calculate the minimal number of elements we know for sure are greater than 𝑥, the medians’ median.
Then we take the complement of that number:
𝑛 For any constant 𝑘 (the default in the selection algorithm is 𝑘 = 5), where we divide into ] ] sets, the 𝑘
number of elements that are definitely greater than 𝑥:
𝑛 𝑛 ] ]⌉ − 2) 𝑛 𝑛 − 2) ⇒
⏟2
˛_2 𝑘
2𝑘
The recursion over the complement is:
𝑛
𝑘 𝑛 ] · ( 𝑛 2𝑘
Then show by substitution that it is bounded / not bounded from above by 𝑐 · 𝑛 (would be bounded for any 𝑘 ≥ 4). Note that we get
Binary Search Trees:
Trees that satisfy: left(x) ≤ key(x) < right(x)
- Left most leaf of 𝑥’s right subtree.
Related CS521 files
All CS521 files →- CS521 Final Term Quiz 3 by Wasi Final term PDF 520 KB
- CS521 Final Term Current Subjective by MS Team Final term PDF 768 KB
- CS521 Final Term Quiz Fall 2024 by VU Stars Final term PDF 2.2 MB
- CS521 Highlighted Slides by Alishba Highlighted PDF 8.3 MB
- CS521 Quiz 1 May 2026 Quiz PDF 35 KB
- CS521 Midterm Current Subjective by MS Team Midterm PDF 618 KB
Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.