»[Prison] /baltop go too slow

Discussion in 'Suggestions & Feedback' started by theerapak, Dec 24, 2015.

  1. theerapak

    theerapak Journeyman Member

    Messages:
    34
    Ratings:
    +11 / -0
    Yes, it's very disgusting to wait like a minute to see that what's my balance position

    ***THIS THREAD MAYBE VERY LONG***

    So first, I go out seeing that /baltop is in what plugin.
    I searched Google and finded that it's in plugin called "essentials"


    then, I enter Github and lookup for the baltop command in this "essentials" plugin and see which sorting technique that he used.
    link to essentials plugin on github: https://github.com/essentials/Essentials


    Then I found that this plugin used the java Object Ordering, Which used to be very slow because it use the Selection Sort sorting Technique.
    Java Object Ordering: https://docs.oracle.com/javase/tutorial/collections/interfaces/order.html

    which is used to be slower than the sorting technique that I would suggest: Merge Sort

    Q: What is the Selection Sort?
    A: https://en.wikipedia.org/wiki/Selection_sort
    this use up big O of n^2 time

    Q:What is Merge Sort?
    A: https://en.wikipedia.org/wiki/Merge_sort
    this use up big O of n ln n time

    selection sort implement in python:
    def selectionSort(alist):
    for fillslot in range(len(alist)-1,0,-1):
    positionOfMax=0
    for location in range(1,fillslot+1):
    if alist[location]>alist[positionOfMax]:
    positionOfMax = location

    temp = alist[fillslot]
    alist[fillslot] = alist[positionOfMax]
    alist[positionOfMax] = temp

    alist = raw_input().split()
    for i in range(len(alist)):
    alist = int(alist)
    selectionSort(alist)
    print(alist)
    merge sort implement in python:
    def merge_sort(li):
    if len(li)<2:return li
    m = len(li)/2
    return merge(merge_sort(li[:m]), merge_sort(li[m:]))

    def merge(l, r):
    result =[]
    i = j =0
    while i < len(l)and j < len(r):
    if l< r[j]:
    result.append(l)
    i +=1
    else:
    result.append(r[j])
    j +=1
    result += l[i:]
    result += r[j:]
    return result

    which you can see, The merge sort is program harder than the selection sort but as I said It's Much faster

    There's about 230000 value to compare on prison ,but lets see the test with 10000 value on list
    Selection Sort:
    [​IMG]
    Merge Sort:
    [​IMG]

    see? the different ABOUT 6 SECOND

    but which one use more RAM?
    I can said the Merge one

    Why? because it's have to call the merge function again and again until it go down and have only 1 list member, So it have to remember the parameter of function that calling

    so please, @Kris @aXed @ItsmeSteyn @CyrusTheVirus1 and staff I known @TheMauriKids @ItsAmethyst maybe considered and you can fork the repository from essential plugin and modified it
    root : (Essentials/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java)

    I'm trying to modified it here https://github.com/Theerapak/Essentials
    the code that I implement is not java! it's python so dont copy and place it . The java and python have very different syntax!

    thank for reading!
    my IGN:TheerapakGomolma


    I forget

    Python : www.python.org
    and
    Python coding program called VIDLE for VPython : http://www.vpython.org/vidle/index.html

    I used python 2.7 and vidle 2.x cause my Teacher at school (Gifted Computer : A lesson for who talent at computer) teaching Python 2.7
     
    Last edited by a moderator: Dec 24, 2015
    #1
  2. Tibo442

    Tibo442 Quitted Member

    Messages:
    88
    Ratings:
    +139 / -0
    Incorrect, Java uses an modified version of merge sort in it's Collections.sort.
    See the javadocs here;
     
    #2
  3. Pooperazee

    Pooperazee Faithful Poster Member

    Messages:
    556
    Ratings:
    +264 / -0
  4. theerapak

    theerapak Journeyman Member

    Messages:
    34
    Ratings:
    +11 / -0
    and also as I said the Merge sort is not good with memory there's also heap sort but it's less atability

    Or we need to clear out people data that doesn't on for like a year.
     
    Last edited: Dec 24, 2015
    #4

Share This Page