Quick question on Shell sort complexity

Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Reply

Join Date: Apr 2008
Posts: 61
Reputation: chunalt787 is an unknown quantity at this point 
Solved Threads: 1
chunalt787 chunalt787 is offline Offline
Junior Poster in Training

Quick question on Shell sort complexity

 
0
  #1
Sep 19th, 2008
I am trying to figure out the time complexity for a best case scenario shell sort. I know worst case is O(n^2) and I think best case should be O(n^2) as well because even thought its already sorted it still has to break the array down into gaps and check those subsets until the gap=1 but I am somewhat wary of my answer. A Google search returned no confirmation. Can anyone confirm this for me?

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 1
Reputation: nibauAntunes is an unknown quantity at this point 
Solved Threads: 0
nibauAntunes nibauAntunes is offline Offline
Newbie Poster

Re: Quick question on Shell sort complexity

 
0
  #2
Mar 22nd, 2009
hi there.
maybe you're right but just in the case that you are only considering the comparisons, not the changes too.
its trivial, that if you want to sort an ordered vector, there wont be any changes, just comparisons.
cya
Last edited by nibauAntunes; Mar 22nd, 2009 at 9:44 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 13
Reputation: xkey is an unknown quantity at this point 
Solved Threads: 0
xkey xkey is offline Offline
Newbie Poster

Re: Quick question on Shell sort complexity

 
0
  #3
Mar 26th, 2009
Originally Posted by chunalt787 View Post
I am trying to figure out the time complexity for a best case scenario shell sort. I know worst case is O(n^2) and I think best case should be O(n^2) as well because even thought its already sorted it still has to break the array down into gaps and check those subsets until the gap=1 but I am somewhat wary of my answer. A Google search returned no confirmation. Can anyone confirm this for me?

Thanks in advance

best case complexity is O(n)

R Sedgewick has some freely available material here : Analysis of Shellsort and ...
Last edited by xkey; Mar 26th, 2009 at 12:57 am.
"There is only one corner of the universe you can be certain of improving, and that's your own self.”
-- Aldous Huxley
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Computer Science Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC