Bläddra i källkod

first commit

master
David 5 år sedan
incheckning
2dacdfc691
12 ändrade filer med 170 tillägg och 0 borttagningar
  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är
      Mergesort/out/production/Mergesort/Mergesort.class
  12. +47
    -0
      Mergesort/src/Mergesort.java

+ 2
- 0
.idea/.gitignore Visa fil

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

+ 9
- 0
.idea/_Programme.iml Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -0,0 +1 @@
Mergesort

+ 6
- 0
Mergesort/.idea/misc.xml Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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är
Mergesort/out/production/Mergesort/Mergesort.class Visa fil


+ 47
- 0
Mergesort/src/Mergesort.java Visa fil

@@ -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]);
}
}
}

Laddar…
Avbryt
Spara