Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Midterm paper DSA for 100 marks, Exams of Algorithms and Programming

Midterm paper DSA for 100 marks

Typology: Exams

2018/2019

Uploaded on 03/21/2019

ashanipratik
ashanipratik 🇮🇳

4.5

(2)

2 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ITCS6114 Midterm Review (Chapter 1- 8, 10, 12)
1. Time complexity analysis
Learning objectives & assessment examples:
Given an algorithm, no matter whether the algorithm is recursive or not, we are able to define its
growth rate function. [Measure frequency or number of iterations associated with input instances]
Compare the asymptotic behaviors of functions or describe the relative merits of worst-, average-,
and best-case analysis
Given two functions of input instance size N, we are able to specify their asymptotic order.
The asymptotic behavior of a function f(N) refers to the growth of f(N) as N gets large. We are
interested in how slow the program will be on large inputs. A good rule of thumb is: the slower
the asymptotic growth rate, the better the algorithm.
Given a recurrence, we are able to analyze its time complexity through different methods:
Master method
Substitution and proof
Recursive tree
Example:
1. For each pair of functions f and g, circle the statements that are true. No justification is
needed.
f(n) = 5 log n, g(n) = log(n 2 ).
Circle all that apply:
(a) f(n) is O(g(n)) (b) f(n) is (g(n))
Solution: (a) and (b) are true.
Recall that log(n 2 ) = 2 log n.
2. For each pair of functions f and g, circle the statements that are true. No justification is
needed.
f(n) = 5 log n, g(n) = (log n) 2 .
Circle all that apply:
(a) f(n) is O(g(n)) (b) f(n) is (g(n))
Solution: Only (a) is true.
pf3
pf4

Partial preview of the text

Download Midterm paper DSA for 100 marks and more Exams Algorithms and Programming in PDF only on Docsity!

ITCS6114 Midterm Review (Chapter 1- 8, 10, 12)

1. Time complexity analysis Learning objectives & assessment examples : - Given an algorithm, no matter whether the algorithm is recursive or not, we are able to define its growth rate function. [Measure frequency or number of iterations associated with input instances] - Compare the asymptotic behaviors of functions or describe the relative merits of worst-, average-, and best-case analysis Given two functions of input instance size N, we are able to specify their asymptotic order. The asymptotic behavior of a function f(N) refers to the growth of f(N) as N gets large. We are interested in how slow the program will be on large inputs. A good rule of thumb is: the slower the asymptotic growth rate, the better the algorithm. - Given a recurrence, we are able to analyze its time complexity through different methods: - Master method - Substitution and proof - Recursive tree

Example:

  1. For each pair of functions f and g, circle the statements that are true. No justification is needed. f(n) = 5 log n, g(n) = log(n 2 ). Circle all that apply: (a) f(n) is O(g(n)) (b) f(n) is Ω(g(n)) Solution: (a) and (b) are true. Recall that log(n 2 ) = 2 log n.
    1. For each pair of functions f and g, circle the statements that are true. No justification is needed. f(n) = 5 log n, g(n) = (log n) 2. Circle all that apply: (a) f(n) is O(g(n)) (b) f(n) is Ω(g(n)) Solution: Only (a) is true.
  1. Give the solution (in big Θ form) for T(n) = 3T(n − 1) + 1 2. Sorting and search algorithms We already covered the following algorithms :
  • Insertion sort
  • Merge sort
  • Selection sort
  • Heap sort
  • Quick sort
  • Binary search (versus linear search)

Learning objectives :

  • Given any above-mentioned algorithm, we are able to describe its algorithmic solution, analyze its time complexity, and explain its merits and constraints in algorithmic design.
  • Given an above-mentioned algorithm and an input instance, we are able to describe first k-th steps
  • Given a problem, we are able to analyze and reduce to a proper sorting or search problem if effective. Example, You play on a local game show where you will complete n different challenges and try to make as much money as possible. The i-th challenge takes ti minutes to complete, and starts with a value of vi dollars, but its value decreases by one dollar per minute. In other words, if you complete challenge i at time f(i), you earn vi − f(i) dollars, where f(i) represents the time for completing the i-th challenge plus the time of waiting other challenges to finish. Every challenge has starting value v (^) i ≥ ∑ (^) i=1 n^ ti , so you will make some money from each challenge. You goal is to order the challenges to earn as much as possible. Suppose v 1 = 10, v 2 = 15, v 3 = 20 and t 1 = 3, t 2 = 2, t 3 = 4. What is the optimal ordering? 3. Advanced data structures We already covered the following data structures :
  • Complete binary tree
  • Heap, priority queue
  • Given an above-mentioned algorithm and an input instance, we are able to describe first k-th steps
  • Given a problem, we would be able to synthesize divide-and-conquer algorithms and analyze time complexity