Saturday, 15 August 2015

assembly - How to merge sort ordered lists in MIPS? -


So I need to correct a program in the MIPS assembly language, my instruction is as follows:

Write a "merge" program that integrates the list of two commands into a new indexed list. For example, in the form of two compliant lists (9, 6, 4,1) and (7,3,2,0) input arguments, "merge" should be prepared in a new list (9, 7, 6, 4) , 3, 2, 1 0) whose order has been ordered. To create another example (6,0, -3) and (9, 54, -2.0) 9 (9, 6, 4, 3.0, -2, -3) may be. / P>

"merge" program assumes that two input lists (in descending order) integer are stored in the field of data. It loads the integer and merges them into an order list. The resulting command list (for example, 9, 6, 54, 0, -2, -3) should be stored back in the data area.

This is your choice on the data area (i.e. lists) Organized, and whether the list of results is written on the original two lists, but be sure to label it meaningful and clearly indicate (by label or comments) where the merged list is stored. Prior to this, it should print the merge list, which should be in the decreasing order.

Note: Please do not apply any sorting algorithm! If you do this, then you should enter zero (0) A grade will be received.

* I think the instructions are not really clear here. I am not sure whether I should give lists or these lists should already exist. Also examples or advice / work The sequence will be very helpful!

An example in the desired, awesome Java:

  import java.util. *; Class merge {// data area / static linked list list 1 = new linked list (arrays.asList (9,6,4,1)); // Static Linked List 2 = New Linked List (arrays.asList (7,3,2,0)); Static Linked List 1 = New Linked List (arrays.asList (6,0, -3)); Stable linked list list 2 = new linked list (arrays.asList (9,5,4,0, -2)); Stable linked list list 3 = new linked list (); // code area public static zero main (string [] args) {ListIterator & lt; Integer & gt; List1Iterator = list1.listIterator (); ListIterator & LT; Integer & gt; List2Iterator = list2.listIterator (); Integer i1 = list1Iterator.next (); Integer i2 = list2Iterator.next (); Whereas (true) // endless, breaks when a list ends {if (i1> i2) {list3.add (i1); If (list1Iterator.hasNext ()) {i1 = list1Iterator.next (); } And // did not leave any element in the list, fill list 3 with list 3 and break {list3.add (i2); While (list2Iterator.hasNext ()) {list3.add (list2Iterator.next ()); }                 break; }} And {list3.add (i2); If (list2Iterator.hasNext ()) {i2 = list2Iterator.next (); } And // do not leave any element in list 2, fill list3 with rest list 1 and break {list3.add (i1); While (list1Iterator.hasNext ()) {list3.add (list1Iterator.next ()); }                 break; }}} System.out.println (list3); }} // class merge  

No comments:

Post a Comment