Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python - sorting algorithms
#1
Hello,
I had a test today and I lost my points on one question.

The book we are using in the class says:

O - runtime complexity

Ω - lower bound

exchange sort = O(n²), Ω(n²)

selection sort = O(n²), Ω(n²)

insertion sort = O(n²), Ω(n)

bubble sort = O(n²), Ω(n)

quick sort(Hoare) = O(n²)(in most cases - O(n log n)), Ω(n)

merge sort = O(n log n)

bucket sort = O(n)

(for some algorithms there are no Ω written in the book)


Question is: Is exchange sort algorithm the easiest of all algorithms for sorting(written in book)?

I answered NO, because bucket sort has complexity O(n) and exchange sort has O(n²).


After test I was looking through the book and I found this statement without further explanation:
"Exchange sort is the easiest of all algorithms for sorting"


My final question is: Have I answered it wrong or is this some mistake in the book?

P.S.
Firstly, sorry for my bad English. I tried my best to translate terms used in the book.
Secondly, it wouldn't be the first mistake in that book. I found some mistakes earlier.


Thanks in advance,
hrca
Reply
#2
I don't know enough about algorithms to give a proper answer, but I'm a little concerned about the word "easy". "Easy" doesn't make sense in the context big O notation or sorting speed. I think the question might be asking which algorithm is the easiest to write, and exchange is incredibly easy to write.
Reply
#3
Quote:Question is: Is exchange sort algorithm the easiest of all algorithms for sorting(written in book)?
I'm pretty sure this would be bubble sort as it is a simple swap.

However, If the book states what you show verbatim, I'd show it to the prof and If a reasonable person, will change your grade.
Reply
#4
(Nov-06-2018, 06:50 PM)nilamo Wrote: I don't know enough about algorithms to give a proper answer, but I'm a little concerned about the word "easy". "Easy" doesn't make sense in the context big O notation or sorting speed. I think the question might be asking which algorithm is the easiest to write, and exchange is incredibly easy to write.

The whole test was with the goal to test the knowledge in complexity of algorithms, so I don't think that "easy" means the complexity to write algorithm. Whole procedure of calculating complexity is based on the number of operations that computer must do.

(Nov-06-2018, 06:53 PM)Larz60+ Wrote:
Quote:Question is: Is exchange sort algorithm the easiest of all algorithms for sorting(written in book)?
I'm pretty sure this would be bubble sort as it is a simple swap. However, If the book states what you show verbatim, I'd show it to the prof and If a reasonable person, will change your grade.

I have a class tomorrow and I have to get a proof that my answer is also correct(I agree with nilamo that it is easy to write).

(btw that is why I started this thread because I am sure that here must be some experienced people that agree with my answer)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Greedy algorithms on logical problems Opensourcehacker 0 1,529 Nov-22-2020, 05:12 PM
Last Post: Opensourcehacker
  Python 2 to 3 dict sorting joshuaprocious 2 56,692 May-14-2020, 03:28 PM
Last Post: joshuaprocious
  I need help with Python code to implement this algorithms Saemmanuex 1 2,037 Jul-07-2019, 02:07 PM
Last Post: DeaD_EyE
  Sorting a copied list is also sorting the original list ? SN_YAZER 3 3,026 Apr-11-2019, 05:10 PM
Last Post: SN_YAZER
  Looking for good doc on Scraping coverage algorithms Larz60+ 0 1,898 Jan-05-2019, 03:22 PM
Last Post: Larz60+
  Conditional sorting in Python amirt 1 6,425 Jul-05-2018, 01:32 PM
Last Post: buran
  compare algorithms tygaf 1 2,820 Feb-14-2018, 07:26 PM
Last Post: buran
  Sorting values calculated in python stumunro 4 3,944 Sep-13-2017, 06:09 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020