Skip to content

Conversation

@s-sanyal
Copy link
Contributor

@s-sanyal s-sanyal commented Oct 1, 2018

Made the code more efficient in terms of Time Complexity as using Quick Sort in Worst Case will take O(n^2), so I have made use of the inbuilt Merge Sort method of Python sorted() to sort the array in ascending order. The worst case complexity of Merge Sort in O(n*log(n)) which is better the Quick Sort

@OmkarPathak
Copy link
Owner

@s-sanyal thanks for contributing. The sieve of erathostenes program in not Python3 compatible. Please make the necessary changes and modify the PR 😄

@s-sanyal
Copy link
Contributor Author

s-sanyal commented Oct 3, 2018

ofcourse...will be doing it just now

Copy link
Owner

@OmkarPathak OmkarPathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @s-sanyal please also change the function name. Remember that in Python, you use Camel Case for defining class names. You can use sieve_of_eratosthenes() as function name 😄

# driver program
if __name__=='__main__':
n = 30
print "Following are the prime numbers smaller",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, use print() for Python3 compatibility

# Python program to print all primes smaller than or equal to
# n using Sieve of Eratosthenes

def SieveOfEratosthenes(n):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see that your code is PEP compatible. You don't generally use Camel Case for function names

@OmkarPathak OmkarPathak merged commit eb580e0 into OmkarPathak:master Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants