Click here to load reader

Recursive decomposition

Embed Size (px)

Citation preview

  • 1. Prepared By: Nik Fatinah Binti N. Mohd Farid (2012790807) Hanis Salwan Bt Mobidin(2012144449) Assignment 2 Merge Sort Using Recursive Decomposition Technique

2. Problem Find a sorted list of element in non- decreasing order. Elements can be in positive or negative integers. 3. The Decomposition Technique and Mapping Technique Used Recursive decomposition technique was implemented to solve this problem. Merge sort apply a divide and conquer algorithm. Merge sort work by dividing the unsorted list into n sublists, each having 1 element. Repeatedly ,merge sublists to produce a new sublists until there is only 1 sublist remaining. Mapping Technique: Since this is a serial program, no mapping technique used. 4. The Program Structurejava import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; public class MergeSort { public static int[] mergeSort(int [] list) { if (list.length