UNIVERSITY OF JAFFNA
FACULTY OF ENGINEERING
MID SEMESTER EXAMINATION-NOV 2024 - SEMESTER VI
INN EC9570 - DIGITAL IMAGE PROCESSING
Date: 03/12/2024 Duration: 1 hour
There are 02 questions in two pages and answer all questions.
The marks for each question are given in parentheses.
II. Scientific electronic calculators are permitted.
1. Comparison-based sorting algorithms like Merge Sort, Heap Sort, and Quick Sort have an
average time complexity of 0(nlogn). While Quick Sort is often more efficient in practice due to
its in-place nature and better cache utilization, Merge Sort is preferred for stability or external
sorting. On the other hand, non-comparison-based algorithms like Counting Sort, Radix Sort,
and Bucket Sort can achieve better performance (i.e., O(n))under specific conditions, such as
when data has a limited range or is uniformly distributed. These algorithms bypass the lower
bound for comparison-based sorting, making them more efficient in specialized cases.
Examples include:
Counting Sort 0 (n + k): Assumes input consists of integers within a limited
range [0,k].
Radix Sort 0(n-k): Assumes input has a fixed number of digits k, and each digit
has a small range.
Bucket Sort O(n + k): Assumes input is uniformly distributed over a known
range [a,b).
The key is that these algorithms are not comparison-based, so they avoid the
theoretical
0(nlogn) lower bound for comparison-based sorting.
a. Explain the time complexity of Merge Sort and why does Merge Sort often
outperform Bubblge Sort for large datasets?
(b.)Why is Quick Sort more efficient than Merge Sort in practice, despite both having
0(nlogn) average-case time complexity? Under what conditions Merge might
Sort be preferred?
C. Explain why non-comparison-based sorting algorithms like Counting Sort or
Bucket Sort can achieve better performance than 0(nlogn) under specific
conditions?
d. Provide two applications where non-comparison-based sorting algorithms are
more efficient than comparison-based algorithms.
(40 Marks)
2. Streaming algorithms process large data streams in one or few passes using limited mermory.
They are ideal for real-time analytics, network monitoring, or sensor data, where storing the
entire dataset is impractical. These algorithms create summaries or approximations to efficienty
compute metrics like frequencies, medians, or distinct elements.
a. Explain the difference between Sampling and Sketching in the context of streaming
algorithms. How do these methods address thechallenges of processing large data
streams?
b. How the Count-Min Sketch algorithm approximates the frequency of elerments in a data
stream. What are the trade-offs between accuracy, memory usage, and processing
speed?
C. Given a Bloom filter with an array size of n=6 and the following hash functions:
h1() = (ASCIl value of x) mod 6
h2(r) = (ASCIlvalue of xx3) mod6
h3(*) = (ASCIlvalue of x + 7)mod6
Process the stream (a, b, C, b, C, a, c] by:
marking the indices from
1. Inserting each element into the Bloom filter by
h1(x), h2 (x), and h3 (x).
likely present in the Bloom filter.
2. Checking if the elements "a" and "g" are
the given stream and use the table to
3. Populate the Count-Min Sketch table for
estimate the frequency of the element "a"
Elements ASCIl
a 97
b 98
C 99
d 100
e 101
(60 Marks)
Table01:ASCIl values
-END OF THE PAPER