- Type
- Final term past paper
- Course
- CS521 Web Systems and Technologies
- Size
- PDF 774 KB
- 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, 2, 3 of 14. Download the file for all 14 pages.
Big-O
Small-o
Big-
(non-negative constant) Small-
Big-
(some constant)
Notes:
Some hierarchies: ( is “o”, is “ ”)
Divide and Conquer – recurrences:
Break a problem into sub-problems, solve sub problems and merge solutions. Hanoi-tower: ( ) ( ) ( )
Solving Recurrences:
1. Substitution method:
Have a guess for ( ) Assume correctness for all Substitute -terms in the recurrence by the assumption, using constants, and derive upper / lower bounds (or both). Example:
To get an upper bound: ( ) ( ) – develop and derive an expression that is exactly .
2. Recursion tree:
Build a tree from the levels in the substitution: Level 0: ( ) Level 1: elements, each costs ( )
Level : elements, each costs ( ) Last level: elements , each costs ( )
3. The Master Theorem:
For , ( ) function over non-negative integers and ( ) the recurrence:
- ( ) ( ) ( ) ( )
- ( ) ( ) ( ) ( )
- ( ) ( ) and ( ) ( ) ( ) ( ( ))
Notes for MT: The addition/subtraction denotes polynomial difference in running time between ( ) and . Cases (1) and (2) derive for some relation between . Simplified Master Theorem: For ( ) ( ) ( ) :
- ( ) ( )
- ( ) ( )
- ( ) ( )
Some recurrences:
Binary search: ( ) ( ) ( ) Linear search: ( ) ( ) ( ) ( ) ( ) ( ) (MT case 1) ( ) ( ) ( ) (tree) ( ) ( ) √ ( ) (MT case 3) ( ) ( ) ( ) (bounds) ( ) ( ) ( ) (tree) ( ) ( ) ( ) ( ) ( ) (bounds) ( ) ( ) ( ) (substitution) ( ) ( ) ( ) (bounds) ( ) ( ) ( ) (bounds) ( ) √ (√ ) ( ) ( ) (tree)
Useful math:
Harmonic series: ∑ when
Sorting algorithms:
Insertion Sort:
Each element is pushed as far as possible to the left (sorted) part of the array. Running time: ( ) worst-case (when sorted in reverse), ( ) best-case (when already sorted). Sorts in-place, space complexity: ( ).
Merge-sort:
Divide the sequence into two sequences, apply the algorithm recursively and merge solutions.
Quick Sort:
Partition( ): linear procedure that partitions in-place around , - s.t.: | | and returns the index of
- the pivot.
Preferable over merge-sort, as it sorts in-place. General recurrence: ( ) ( ) ( ) ( ) Worst-case: array already sorted, partition at the beginning: ( ) ( ) ( ) ( ) For any -proportional division we get ( ):
For we get a balanced tree. Expected running time: , ( )- ∑ , - ( | ) Heap: Left filled structure that satisfies partial order (node its children, no particular relation between children). For node : left child at , right at , parent ⌊ ⌋ Height is : the cost of insertion, extract-max, delete. Every level of height has ⌈ ⌉ nodes.
Insert: put node at the end and heapify up (switch with parent( ) until parent( ) or is root. 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 down to , heapify down. Amortized analysis – each level but lowest will be visited at most ( ) . Total: ( ) ∑ . The sum part is ( ) total: ( ).
Related CS521 files
All CS521 files →- CS521 Final Term Quiz by Virtual University Alerts Final term PDF 2.4 MB
- CS521 Final Term Quiz Fall 2024 by VU Stars Final term PDF 2.2 MB
- CS521 Final Term Current Subjective by MS Team Final term PDF 768 KB
- CS521 Highlighted Slides by Alishba Highlighted PDF 8.3 MB
- CS521 Quiz Explanation Quiz PDF 159 KB
- CS521 Midterm Preparation by ZB Midterm PDF 691 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.