On Thursday, May 10, 2018 at 2:43:33 PM UTC+8, Rajat Tanwar wrote:
> I used FastReader because its faster than Scanner. I read and copied it from 
> here https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/

Ok, I guess that's fine.

> I am changing my code to use Arrays.sort() instead of own defined QuickSort 
> algorithm.

I bet it will work then :)

> I will also search for other QuickSort implementations which will make it 
> faster so if you guys have an article on that please share. Thanks :).

I don't have an article, but you can check what wikipedia says about it (and 
related pages). You can also look into introsort and Timsort.
Generally if you want to implement your own quicksort, I would suggest:
- random pivot
- "Dutch national flag" style partitioning
- switch to insertion sort for small arrays (you can also leave small 
partitions unsorted and do a single insertion sort pass on the whole array at 
the end)
- test and benchmark it!

Spoiler alert: Arrays.sort will probably be faster

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/fa6ead9f-d913-43ff-b6bc-fe03ad7a6847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to