mergesort

Merge two sorted arrays using for loop is missing the last item

Merge two sorted arrays using for loop is missing the last item Question: I m new to dealing with algorithms and my challenge was to merge two sorted lists into one using for loop not while loop. I got stuck at determining the end of the list: list1=[1,2,4] list2=[1,3,4,6] def mergeTwoLists(list1: list, list2:list) -> list: …

Total answers: 3

Eventually the ids also need to be sorted

Eventually the ids also need to be sorted Question: I have to design an algorithm to sort a list of orders by selection time (t selection, finding the good in the warehouse and bringing it to the surface) plus shipping time (t shipping, constant). The customer orders can be retrieved (in the same order as …

Total answers: 2

sorting orders with mergesort incorrect output

sorting orders with mergesort incorrect output Question: I have to design an algorithm to sort a list of orders by selection time (t selection, finding the good in the warehouse and bringing it to the surface) plus shipping time (t shipping, constant). The customer orders can be retrieved (in the same order as placed) from …

Total answers: 1

How can I convert psuedocode to mergesort algorithm?

How can I convert pseudocode to mergesort algorithm? Question: I need to convert pseudocode into a merge sort algorithm that mirrors that pseudocode. I am new to pseudocode so I’m having trouble with this. Can anyone tell me what is wrong with my algorithm? Please note that the arrays in the pseudocode are 1-indexed. PSEUDOCODE: …

Total answers: 2

How to find the recurrence relation, and calculate Master Theorem of a Merge Sort Code?

How to find the recurrence relation, and calculate Master Theorem of a Merge Sort Code? Question: I’m trying to find the Master Theorem of this Merge Sort Code, but first I need to find its recurrence relation, but I’m struggling to do and understand both. I already saw some similar questions here, but couldn’t understand …

Total answers: 1

Mergesort with Python

Mergesort with Python Question: I couldn’t find any working Python 3.3 mergesort algorithm codes, so I made one myself. Is there any way to speed it up? It sorts 20,000 numbers in about 0.3-0.5 seconds def msort(x): result = [] if len(x) < 2: return x mid = int(len(x)/2) y = msort(x[:mid]) z = msort(x[mid:]) …

Total answers: 32