Browse Source

first commit

master
David 5 years ago
commit
2dacdfc691
12 changed files with 170 additions and 0 deletions
  1. +2
    -0
      .idea/.gitignore
  2. +9
    -0
      .idea/_Programme.iml
  3. +6
    -0
      .idea/misc.xml
  4. +8
    -0
      .idea/modules.xml
  5. +6
    -0
      .idea/vcs.xml
  6. +1
    -0
      Mergesort/.idea/.name
  7. +6
    -0
      Mergesort/.idea/misc.xml
  8. +8
    -0
      Mergesort/.idea/modules.xml
  9. +66
    -0
      Mergesort/.idea/workspace.xml
  10. +11
    -0
      Mergesort/Mergesort.iml
  11. BIN
      Mergesort/out/production/Mergesort/Mergesort.class
  12. +47
    -0
      Mergesort/src/Mergesort.java

+ 2
- 0
.idea/.gitignore View File

@@ -0,0 +1,2 @@
# Default ignored files
/workspace.xml

+ 9
- 0
.idea/_Programme.iml View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 6
- 0
.idea/misc.xml View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

+ 8
- 0
.idea/modules.xml View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/_Programme.iml" filepath="$PROJECT_DIR$/.idea/_Programme.iml" />
</modules>
</component>
</project>

+ 6
- 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 1
- 0
Mergesort/.idea/.name View File

@@ -0,0 +1 @@
Mergesort

+ 6
- 0
Mergesort/.idea/misc.xml View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

+ 8
- 0
Mergesort/.idea/modules.xml View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Mergesort.iml" filepath="$PROJECT_DIR$/Mergesort.iml" />
</modules>
</component>
</project>

+ 66
- 0
Mergesort/.idea/workspace.xml View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c8adc784-126f-470a-a7fd-698c37d72caf" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="ProjectId" id="1QzzoweBm11mFzbea31cckI8MbE" />
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Mergesort" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Mergesort" />
<module name="Mergesort" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Mergesort" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="c8adc784-126f-470a-a7fd-698c37d72caf" name="Default Changelist" comment="" />
<created>1568788391205</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1568788391205</updated>
<workItem from="1568788394064" duration="53000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
</project>

+ 11
- 0
Mergesort/Mergesort.iml View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

BIN
Mergesort/out/production/Mergesort/Mergesort.class View File


+ 47
- 0
Mergesort/src/Mergesort.java View File

@@ -0,0 +1,47 @@
public class Mergesort {

public static int[] intArr = { 16, 23, 14, 7, 21, 20, 6, 1, 17, 13, 12, 9,
3, 19 };

public int[] sort(int l, int r) {

if (l < r) {
int q = (l + r) / 2;

sort(l, q);
sort(q + 1, r);
merge(l, q, r);
}
return intArr;
}

private void merge(int l, int q, int r) {
int[] arr = new int[intArr.length];
int i, j;
for (i = l; i <= q; i++) {
arr[i] = intArr[i];
}
for (j = q + 1; j <= r; j++) {
arr[r + q + 1 - j] = intArr[j];
}
i = l;
j = r;
for (int k = l; k <= r; k++) {
if (arr[i] <= arr[j]) {
intArr[k] = arr[i];
i++;
} else {
intArr[k] = arr[j];
j--;
}
}
}

public static void main(String[] args) {
Mergesort ms = new Mergesort();
int[] arr = ms.sort(0, intArr.length - 1);
for (int i = 0; i < arr.length; i++) {
System.out.println(i + 1 + ": " + arr[i]);
}
}
}

Loading…
Cancel
Save