0% found this document useful (0 votes)
35 views2 pages

First Term Fall15

This document contains the questions for an exam on algorithms. It asks students to analyze the runtime of 3 algorithms, determine big-O relationships between expressions, solve problems using algorithms like Quickselect and Karatsuba multiplication, analyze the runtime of algorithms like 4-way Merge Sort, and solve graph problems using representations like adjacency lists and matrices. Students are asked to show their work and be concise in their answers.

Uploaded by

aizaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

First Term Fall15

This document contains the questions for an exam on algorithms. It asks students to analyze the runtime of 3 algorithms, determine big-O relationships between expressions, solve problems using algorithms like Quickselect and Karatsuba multiplication, analyze the runtime of algorithms like 4-way Merge Sort, and solve graph problems using representations like adjacency lists and matrices. Students are asked to show their work and be concise in their answers.

Uploaded by

aizaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE317 Design & and Analysis of Algorithms

First Term Examination – Fall’15


Max Marks: 50 Time Allowed: 90 minutes

Attempt all questions. Be to the point. Show your work.

1. [10 marks] Suppose you are choosing between the following three algorithms:

• Algorithm A solves problems by dividing them into four subproblems of half the size,
recursively solving each subproblem, and then combining the solution in O(n2 ) time.
• Algorithm B solves problems of size n by recursively solving one subproblem of size
n − 1 and then combining the solution in O(n) time.
• Algorithm C solves problems of size n by dividing them into five subproblems of size
n/3, recursively solving each subproblem, and then combining the solution in O(n2 )
time.

What are the running times of each of these algorithms (in big-O notation), and which
would you choose?

2. [6 marks] For each pair of expressions (A, B) below, indicate whether A is O, Ω, or Θ of


B. Your answer should be in the form of table with “yes” or “no” written in each box.

A B O Ω Θ

n n
(a) 28
n log n

(b) 9 log(n) log(n2 )

(c) n1/2 n2/3

(d) log(n!) n log n

3. (a) [3 marks] What problem does the Quickselect algorithm solve? (Describe the input
and output; do not merely name the problem.)
(b) [3 marks] Quickselect has very poor worst-case performance. What can we do about
this?

4. [6 marks] Use the divide-and-conquer integer multiplication (Karatsuba’s) algorithm to


multiply the two binary integers 10011011 and 10111010.

5. [6 marks] 4-way-Merge Sort: Suppose that instead of dividing in half at each step of Merge
Sort, you divide into four, sort each fourth, and finally combine all of them using a four-way
merge subroutine. What is the overall asymptotic running time of this algorithm? Give
a recurrence describing the running time of 4-way Merge Sort and solve it to justify your
answer. (Hint: Note that the merge step can still be implemented in O(n) time.)

6. [6 marks] You are a given a unimodal array of n distinct elements, meaning that its entries
are in decreasing order up until its minimum element, after which its elements are in in-
creasing order. Give an algorithm to compute the minimum element that runs in O(log n)
time.

Page 1 of 2
Name: First Term (Continued) CSE317 – Fall’15

7. Consider the following graph.

(a) [1 mark] What is the degree of vertex 6?


(b) [1 mark] Give all simple-paths between nodes 0 and 4.
(c) [2 marks] Give an adjacency-list representation of the above graph.
(d) [4 marks] Run DFS algorithm on the above graph (using adjacency list represenation
computed in the previous part) and give the resulting dfs-tree. Also draw the back
edges as dotted lines.
(e) [2 marks] Draw the graph with the following adjacency matrix:
 
0 1 0 0 1
 1 0 1 1 0 
 
 0 1 0 1 1 
 
 0 1 1 0 0 
1 0 1 0 0

Page 2 of 2

You might also like