What’s a quick test to see if an $n \times n$ matrix is diagonal and/or proporitional to the identity matrix?

As the title indicates, I want to test whether an $ n \times n$ matrix (numeric, symbolic,..) is diagonal and/or proportional to the $ n \times n$ identity matrix. I, of course, can test whether the $ n^2-n$ individual off-diagonal entries are zero–but that’s, it would seem, is inefficient.

Analysing worst case time complexity of quick sort for various cases

I am trying to understand worst case time complexity of quick sort for various pivots. Here is what I came across:

  1. When array is already sorted in either ascending order or descending order and we select either leftmost or rightmost element as pivot, then it results in worst case $ O(n^2)$ time complexity.

  2. When array is not already sorted and we select random element as pivot, then it gives worst case “expected” time complexity as $ O(n log n)$ . But worst case time complexity is still $ O(n^2)$ . [1]

  3. When we select median of [2] first, last and middle element as pivot, then it results in worst case time complexity of $ O(n log n)$ [1]

I have following doubts

D1. Link 2 says, if all elements in array are same then both random pivot and median pivot will lead to $ O(n^2)$ time complexity. However link 1 says median pivot yields $ O(n log n)$ worst case time complexity. What is correct?

D2. How median of first, last and middle element can be median of all elements?

D3. What we do when random pivot is ith element? Do we always have to swap it with either leftmost or rightmost element before partitioning? Or is there any algorithm which does not require such swap?

Quick Clarification Question about Time Complexity in CLRS

I’m reading about the Hiring Problem in “Introduction to Algorithms” and read

Interviewing has a low cost, say $ c_i$ , whereas hiring is expensive, costing $ c_h$ . Letting $ m$ be the number of people hired, the total cost associated with this algorithm is $ O(c_in+c_hm)$ .

For clarification, this is the algorithm being referred to

HIRE-ASSISTANT(n)     best = 0 // candidate 0 is a least-qualified dummy candidate      for i = 1 to n     interview candidate i     if candidate i is better than candidate best         best = i         hire candidate i 

My question is, why does the book say the total cost is $ O(c_in+c_hm)$ and not $ \Theta(c_in+c_hm)$ ? For any input, since we must iterate over all $ n$ candidates and given that $ m$ are hired, couldn’t we also say that the asymptotic lower bound is $ \Omega(c_in+c_hm)$ therefore saying the cost for any input is $ \Theta(c_in+c_hm)$ ?

Quick Sale / Specific Niche / Perfect for Car Dealership Owners

Hey guys,

Selling my website: Reselling / selling Carfax reports.

This is best for those who own a car dealership in the US or EU and who get Carfax unlimited reports.

Or you can always find someone who sells Carfax for cheap and re-sell it.

#10 Position in Google – Keyword "Cheap Carfax"

You can also re-sell AutoCheck reports. I can give you a supplier who sells it for $ 2.

Earnings:
October 2November 2

Total: $ 198 – 33 Orders ($ 5.99)

August 30 -…

Quick Sale / Specific Niche / Perfect for Car Dealership Owners

Quick sale! High Traffic Adult Humor Website 9gag2.com

Here for sale is a popular adult humor website- 9GAG2.COM

It has an established audience built up over 4 years and receives approx. 12,000 daily unique visitors with monthly revenue average of approx. 500 USD (I can provide Exoclick data starting from 2018-01-01).

Please contact me for more info on the website, access to google analytics, advertising info, info on digital transfer, etc.

Why…

Quick sale! High Traffic Adult Humor Website 9gag2.com

Recursion from a special case of quick sort

I have the following special case for merge sort:

“John wishes to perform a quicksort on an array, where he picks the partition as the $ \left \lfloor{\frac{2n}{3}}\right \rfloor th$ least element in the array (If the array has 10 elements, it will pick the element at the 6th position in the sorted array) such that this pivot selection procedure takes $ \Theta(n)$ time.

What is the worst case running time?”

I have tried forming a recurrence, but I end up having floors/ceilings and don’t know how to deal with them. I would like to reduce the case down to the recurrence:

$ T(n) = T(2n/3) + T(n/3) + \Theta(n) $

Where I’m then able to produce a recursion tree I can easily analyse.

However, when producing an upper bound I’m getting a ceiling on the $ n/3$ and a floor on the $ 2n/3$ .

For the purpose of producing a recursion tree, can I just assume these floors/ceilings are negligible for a very large n?

Thanks

UK Content Writer | Starting from £5 Per Article | Quick Turn Around | SEO

Hello DP!

I am from the U.K and have lived here all my life. My English is 2nd to none.

At the moment, my team and I have space for a few more clients that are needing regular content created for their website. If you just need content for the one time, please still get in contact.

Our team is passionate about the following topics, but we write and research any topic that you can throw at us!

– Web Hosting (Tutorials, News, Information)
– Gaming (News, Console Exploits, Homebrew)
-…

UK Content Writer | Starting from £5 Per Article | Quick Turn Around | SEO