python代码应该执行SJF算法,但事实并非如此

时间:2014-04-18 13:33:17

标签: python algorithm sorting

考虑下面的代码,它接受进程的输入(Burst&到达)时间并根据sjf算法对它们进行排序,但是输出是错误的,他在其他算法中命令进程让我们先命名它的进程用户输入的任何帮助?

Processes = input("   Enter the  processes times & arrival times separated by a comma: ")


   BurstTimes = Processes[::2]
    ArrivalTimes = Processes[1::2]
    print '   Burst Times:', BurstTimes, '\n', '   Arrival Times', ArrivalTimes,'\n',
    list1, list2 =  BurstTimes, ArrivalTimes

    indices1 = range(len(list1))
    indices1.sort(key=lambda x: list1[x])
    list1 = map(lambda i: list1[i], indices1)
    labelled = zip(list1, ascii_uppercase)
    sorted_data = sorted(labelled, key=itemgetter(0)) 
    labels = [pair[1] for pair in sorted_data]

0 个答案:

没有答案