It's UWAweek 48

help2200

This forum is provided to promote discussion amongst students enrolled in CITS2200 Data Structures and Algorithms.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 2 articles in this topic
Showing 2 of 176 articles.
Currently 3 other people reading this forum.


 UWA week 22 (1st semester, study break) ↓
SVG not supported

Login to reply

👍x1
helpful
7:14pm Sun 2nd Jun, ANONYMOUS

Q2a. A heap can be constructed in O(n) time for n inputs. Design an algorithm for finding the k-th smallest element in an unsorted array of length n that is faster than O(n log n) asymptotically. Analyse the complexity of your algorithm assuming k as a constant. I understand where you got to the answer of O(n + klogn). I am confused about why you can't get rid of the constant k, and get: O(n + logn) And then have the dominant n subsume the other factor: O(n). You said "you can only remove a term when you are sure that the other term has asymptotically the same or higher complexity.". Then you said that we can't be sure whether klogn would be asymptotically higher complexity than n. The question states that k is a constant, therefore does it not matter how high the constant is, by the definition of O() that you gave us, are we not certain that n has a higher growth rate than klogn, and in that case, shouldn't we be able to just say it's O(n)?


 UWA week 23 (1st semester, 1st exam week) ↓
SVG not supported

Login to reply

👍?
helpful
3:03pm Mon 3rd Jun, Amitava D.

ANONYMOUS wrote:
> Q2a. A heap can be constructed in O(n) time for n inputs. Design an algorithm for finding the k-th smallest element in an unsorted array of length n that is faster than O(n log n) asymptotically. Analyse the complexity of your algorithm assuming k as a constant. > > I understand where you got to the answer of O(n + klogn). I am confused about why you can't get rid of the constant k, and get: > > O(n + logn)
K is a variable here, not a constant, so we can't do what you have written. K is a constant only for a specific instance. Suppose you have to find n smallest elements? It will be an O(n) algorithm according to your logic. That will break the O(nlog n) lower bound for sorting.
> > And then have the dominant n subsume the other factor: > > O(n). > > You said "you can only remove a term when you are sure that the other term has asymptotically the same or higher complexity.". Then you said that we can't be sure whether klogn would be asymptotically higher complexity than n. > The question states that k is a constant, therefore does it not matter how high the constant is, by the definition of O() that you gave us, are we not certain that n has a higher growth rate than klogn, and in that case, shouldn't we be able to just say it's O(n)?

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy