Repository: gazolla/Kotlin-Algorithm
Branch: master
Commit: 76aee604a45f
Files: 54
Total size: 102.1 KB
Directory structure:
gitextract_bjd7u91h/
├── .idea/
│ ├── Kotlin-Algorithm.iml
│ ├── compiler.xml
│ ├── copyright/
│ │ └── profiles_settings.xml
│ ├── inspectionProfiles/
│ │ ├── Project_Default.xml
│ │ └── profiles_settings.xml
│ ├── kotlinc.xml
│ ├── markdown-navigator/
│ │ └── profiles_settings.xml
│ ├── markdown-navigator.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── vcs.xml
│ └── workspace.xml
├── BinarySearch/
│ ├── BinarySearch.kt
│ └── README.markdown
├── Combinatorics/
│ └── Combinatorics.kt
├── Compression/
│ ├── Compresion.kt
│ ├── CompressionTest.kt
│ └── README.markdown
├── DepthFirstSearch/
│ ├── AdjacencyList.kt
│ ├── DepthFirstSearch.kt
│ ├── Edge.kt
│ ├── Graphable.kt
│ ├── README.markdown
│ └── Vertex.kt
├── Deque/
│ ├── Deque.kt
│ ├── DequeTest.kt
│ └── README.markdown
├── InsertionSort/
│ ├── InsertionSort.kt
│ └── README.markdown
├── LinearSearch/
│ ├── LinearSearch.kt
│ └── README.markdown
├── LinkedList/
│ ├── LinkedList.kt
│ └── README.markdown
├── MergeSort/
│ ├── MergeSort.kt
│ └── README.markdown
├── OrderedArray/
│ ├── OrderedArray.kt
│ └── README.markdown
├── OrderedSet/
│ ├── OrderedSet.kt
│ └── README.markdown
├── Queue/
│ ├── Queue.kt
│ └── README.markdown
├── QuickSort/
│ ├── QuickSort.kt
│ └── README.markdown
├── README.markdown
├── SelectionSort/
│ ├── README.markdown
│ └── SelectionSort.kt
├── ShellSort/
│ ├── README.markdown
│ └── ShellSort.kt
├── Shuffle/
│ ├── README.markdown
│ └── Shuffle.kt
├── Stack/
│ ├── README.markdown
│ └── Stack.kt
└── Tree/
├── README.markdown
└── Tree.kt
================================================
FILE CONTENTS
================================================
================================================
FILE: .idea/Kotlin-Algorithm.iml
================================================
<?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>
================================================
FILE: .idea/compiler.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
================================================
FILE: .idea/copyright/profiles_settings.xml
================================================
<component name="CopyrightManager">
<settings default="" />
</component>
================================================
FILE: .idea/inspectionProfiles/Project_Default.xml
================================================
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="FallthruInSwitchStatement" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="UnnecessarySemicolon" enabled="true" level="ERROR" enabled_by_default="true" />
</profile>
</component>
================================================
FILE: .idea/inspectionProfiles/profiles_settings.xml
================================================
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>
================================================
FILE: .idea/kotlinc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinCommonCompilerArguments">
<option name="languageVersion" value="1.1" />
<option name="apiVersion" value="1.1" />
</component>
</project>
================================================
FILE: .idea/markdown-navigator/profiles_settings.xml
================================================
<component name="MarkdownNavigator.ProfileManager">
<settings default="" pdf-export="" />
</component>
================================================
FILE: .idea/markdown-navigator.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownProjectSettings">
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true">
<PanelProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings>
<PegdownExtensions>
<option name="ABBREVIATIONS" value="false" />
<option name="ANCHORLINKS" value="true" />
<option name="ASIDE" value="false" />
<option name="ATXHEADERSPACE" value="true" />
<option name="AUTOLINKS" value="true" />
<option name="DEFINITIONS" value="false" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="FOOTNOTES" value="false" />
<option name="HARDWRAPS" value="false" />
<option name="INSERTED" value="false" />
<option name="QUOTES" value="false" />
<option name="RELAXEDHRULES" value="true" />
<option name="SMARTS" value="false" />
<option name="STRIKETHROUGH" value="true" />
<option name="SUBSCRIPT" value="false" />
<option name="SUPERSCRIPT" value="false" />
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
<option name="SUPPRESS_INLINE_HTML" value="false" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
<option name="TOC" value="false" />
<option name="WIKILINKS" value="true" />
</PegdownExtensions>
<ParserOptions>
<option name="COMMONMARK_LISTS" value="false" />
<option name="DUMMY" value="false" />
<option name="EMOJI_SHORTCUTS" value="true" />
<option name="FLEXMARK_FRONT_MATTER" value="false" />
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="true" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="GITBOOK_URL_ENCODING" value="false" />
<option name="GITHUB_EMOJI_URL" value="false" />
<option name="GITHUB_LISTS" value="true" />
<option name="GITHUB_WIKI_LINKS" value="true" />
<option name="JEKYLL_FRONT_MATTER" value="false" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
<GeneratorProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
</CssSettings>
<HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
</project>
================================================
FILE: .idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="true" assert-keyword="true" jdk-15="true" />
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
================================================
FILE: .idea/modules.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Kotlin-Algorithm.iml" filepath="$PROJECT_DIR$/.idea/Kotlin-Algorithm.iml" />
</modules>
</component>
</project>
================================================
FILE: .idea/vcs.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
================================================
FILE: .idea/workspace.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b2d74b27-d4f8-4339-b51c-d0fff6c0b424" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ShellSort/README.markdown" afterPath="$PROJECT_DIR$/ShellSort/README.markdown" />
</list>
<ignored path="Kotlin-Algorithm.iws" />
<ignored path=".idea/workspace.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" 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="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="Kotlin-Algorithm" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="BinarySearch.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/BinarySearch/BinarySearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="DepthFirstSearch.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/DepthFirstSearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="README.markdown" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/README.markdown">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="1" />
<folding />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ShellSort.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ShellSort/ShellSort.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="640">
<caret line="42" column="50" selection-start-line="42" selection-start-column="50" selection-end-line="42" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="README.markdown" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/ShellSort/README.markdown">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="144">
<caret line="9" column="57" selection-start-line="9" selection-start-column="57" selection-end-line="9" selection-end-column="57" />
<folding />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="AdjacencyList.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/AdjacencyList.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Graphable.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Graphable.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="7" column="1" selection-start-line="7" selection-start-column="1" selection-end-line="7" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Vertex.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Vertex.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Edge.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Edge.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="42" selection-start-line="5" selection-start-column="42" selection-end-line="5" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/DepthFirstSearch/AdjacencyList.kt" />
<option value="$PROJECT_DIR$/DepthFirstSearch/Graphable.kt" />
<option value="$PROJECT_DIR$/DepthFirstSearch/Vertex.kt" />
<option value="$PROJECT_DIR$/DepthFirstSearch/Edge.kt" />
<option value="$PROJECT_DIR$/Stack/Stack.kt" />
<option value="$PROJECT_DIR$/DepthFirstSearch/DepthFirstSearch.kt" />
<option value="$PROJECT_DIR$/DepthFirstSearch/README.markdown" />
<option value="$PROJECT_DIR$/ShellSort/ShellSort.kt" />
<option value="$PROJECT_DIR$/ShellSort/README.markdown" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1440" />
<option name="height" value="873" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="2" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="AndroidView">
<subPane />
</pane>
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="Kotlin-Algorithm" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="Kotlin-Algorithm" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="Kotlin-Algorithm" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="Kotlin-Algorithm" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="Kotlin-Algorithm" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="Stack" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="settings.editor.selected.configurable" value="android.sdk-updates" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="android.project.structure.last.selected" value="SDK Location" />
<property name="android.project.structure.proportion" value="0.15" />
<property name="android.sdk.path" value="$USER_HOME$/Library/Android/sdk" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RunManager">
<configuration default="true" type="AndroidJUnit" factoryName="Android JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="AndroidRunConfigurationType" factoryName="Android App">
<module name="" />
<option name="DEPLOY" value="true" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="PREFERRED_AVD" value="" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Hybrid>
<Java />
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Native>
<Profilers>
<option name="ENABLE_ADVANCED_PROFILING" value="true" />
<option name="SUPPORT_LIB_ENABLED" value="true" />
<option name="INSTRUMENTATION_ENABLED" value="true" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method />
</configuration>
<configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Instrumented Tests">
<module name="" />
<option name="TESTING_TYPE" value="0" />
<option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
<option name="METHOD_NAME" value="" />
<option name="CLASS_NAME" value="" />
<option name="PACKAGE_NAME" value="" />
<option name="EXTRA_OPTIONS" value="" />
<option name="PREFERRED_AVD" value="" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Hybrid>
<Java />
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Native>
<Profilers>
<option name="ENABLE_ADVANCED_PROFILING" value="true" />
<option name="SUPPORT_LIB_ENABLED" value="true" />
<option name="INSTRUMENTATION_ENABLED" value="true" />
</Profilers>
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list />
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<method />
</configuration>
<configuration default="true" type="JarApplication" factoryName="JAR Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<envs />
<method />
</configuration>
<configuration default="true" type="Java Scratch" factoryName="Java Scratch">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="SCRATCH_FILE_ID" value="0" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="Kotlin-Algorithm" />
<envs />
<method />
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType" factoryName="Kotlin script">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="filePath" />
<option name="vmParameters" />
<option name="alternativeJrePath" />
<option name="programParameters" />
<option name="passParentEnvs" value="true" />
<option name="workingDirectory" />
<option name="isAlternativeJrePathEnabled" value="false" />
<envs />
<method />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration default="true" type="TestNGTestDiscovery" factoryName="TestNG Test Discovery" changeList="All">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration name="<template>" type="Applet" default="true" selected="false">
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
</configuration>
<configuration name="<template>" type="JUnit" default="true" selected="false">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
</configuration>
<configuration name="<template>" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="b2d74b27-d4f8-4339-b51c-d0fff6c0b424" name="Default" comment="" />
<created>1492877006538</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1492877006538</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1440" height="873" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24947146" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/BinarySearch/BinarySearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/DepthFirstSearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="368">
<caret line="23" column="48" selection-start-line="23" selection-start-column="48" selection-end-line="23" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/README.markdown">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Stack/Stack.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="768">
<caret line="48" column="5" selection-start-line="48" selection-start-column="5" selection-end-line="48" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/AdjacencyList.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Graphable.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="7" column="1" selection-start-line="7" selection-start-column="1" selection-end-line="7" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Vertex.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Edge.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="42" selection-start-line="5" selection-start-column="42" selection-end-line="5" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/BinarySearch/BinarySearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/DepthFirstSearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="368">
<caret line="23" column="48" selection-start-line="23" selection-start-column="48" selection-end-line="23" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/README.markdown">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Stack/Stack.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="768">
<caret line="48" column="5" selection-start-line="48" selection-start-column="5" selection-end-line="48" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/AdjacencyList.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Graphable.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="7" column="1" selection-start-line="7" selection-start-column="1" selection-end-line="7" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Vertex.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Edge.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="42" selection-start-line="5" selection-start-column="42" selection-end-line="5" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/AdjacencyList.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Graphable.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="7" column="1" selection-start-line="7" selection-start-column="1" selection-end-line="7" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Vertex.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/Edge.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="80">
<caret line="5" column="42" selection-start-line="5" selection-start-column="42" selection-end-line="5" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/BinarySearch/BinarySearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/DepthFirstSearch.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/DepthFirstSearch/README.markdown">
<provider editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="11" column="29" selection-start-line="11" selection-start-column="29" selection-end-line="11" selection-end-column="29" />
<folding />
</state>
</provider>
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="1" />
<folding />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Stack/Stack.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="768">
<caret line="48" column="5" selection-start-line="48" selection-start-column="5" selection-end-line="48" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ShellSort/ShellSort.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="640">
<caret line="42" column="50" selection-start-line="42" selection-start-column="50" selection-end-line="42" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ShellSort/README.markdown">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="144">
<caret line="9" column="57" selection-start-line="9" selection-start-column="57" selection-end-line="9" selection-end-column="57" />
<folding />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
</component>
</project>
================================================
FILE: BinarySearch/BinarySearch.kt
================================================
import java.util.*
/**
* Created by gazollajunior on 03/04/16.
*/
fun <T: Comparable<T>> binarySearch(list: List<T>, key: T): Int? {
var rangeStart = 0
var rangeEnd = list.count()
while (rangeStart < rangeEnd) {
val midIndex = rangeStart + (rangeEnd - rangeStart)/2
if (list[midIndex] == key) {
return midIndex
} else if (list[midIndex] < key) {
rangeStart = midIndex + 1
} else {
rangeEnd = midIndex
}
}
return null
}
fun <T: Comparable<T>> binarySearchRec(list: List<T>, key: T): Optional<Int> {
require(list == list.sorted())
fun helper(start: Int, end: Int): Optional<Int> {
val mid: Int = start + (end - start) / 2
if (end < start) return Optional.empty()
if (key == list[mid]) {
return Optional.of(mid)
} else if (key < list[mid]) {
return helper(start, mid - 1)
} else {
return helper(mid + 1, end)
}
}
return helper(0, list.count())
}
fun main(args: Array<String>) {
println("\nOrdered list:")
val ordered = listOf("Adam", "Clark", "John", "Tim", "Zack")
println(ordered)
val name = "John"
println("\n$name is in the position ${binarySearch(ordered, name)} in the ordered List.")
println("\n$name is in the position ${binarySearchRec(ordered, name)} in the ordered List.")
}
================================================
FILE: BinarySearch/README.markdown
================================================
# Binary Search
Binary Search is a search algorithm that finds the position of a target value, whether alone or part of a record, within a sorted array. It works by comparing the target value to the middle element of the array; if they are not equal, the lower or upper half of the array is eliminated depending on the result and the search is repeated until the position of the target value is found.
source: [Wikipedia page for Binary Search](https://en.wikipedia.org/wiki/Binary_search_algorithm)
## The code
Here is an iterative implementation of the binary search algorithm in Kotlin:
```kotlin
fun <T: Comparable<T>> binarySearch(list: List<T>, key: T): Int? {
var rangeStart = 0
var rangeEnd = list.count()
while (rangeStart < rangeEnd) {
val midIndex = rangeStart + (rangeEnd - rangeStart)/2
if (list[midIndex] == key) {
return midIndex
} else if (list[midIndex] < key) {
rangeStart = midIndex + 1
} else {
rangeEnd = midIndex
}
}
return null
}
```
================================================
FILE: Combinatorics/Combinatorics.kt
================================================
/**
* Created by gazollajunior on 06/04/16.
*/
fun factorial(number:Long):Long{
if (number <= 1) return 1 else return factorial(number - 1) * number
}
fun permutations(n:Long, k:Long):Long{
return factorial(n)/factorial(n-k)
}
fun combinations(n:Long, k:Long):Long{
return permutations(n,k)/factorial(k)
}
fun main(args: Array<String>) {
println("0 factorial is ${factorial(0)}")
println("1 factorial is ${factorial(1)}")
println("2 factorial is ${factorial(2)}")
println("3 factorial is ${factorial(3)}")
println("4 factorial is ${factorial(4)}")
println("5 factorial is ${factorial(5)}\n")
println("permutations(9,4) ${permutations(9,4)}")
println("permutations(10,8) ${permutations(10,8)}")
println("permutations(20,6) ${permutations(20,6)}")
println("permutations(22,6) ${permutations(22,6)}\n")
println("combinations(9,4) ${combinations(9,4)}")
println("combinations(10,8) ${combinations(10,8)}")
println("combinations(20,6) ${combinations(20,6)}")
println("combinations(22,6) ${combinations(22,6)}\n")
}
================================================
FILE: Compression/Compresion.kt
================================================
package compression
/**
* Calculation of Run Length Encoding using Tail Recursion
* Created by Andy on 05/05/2016.
*/
tailrec fun runLengthEncoding(text:String,prev:String=""):String {
if (text.length == 0){
return prev
}
val initialChar = text.get(0)
val count = text.takeWhile{ it==initialChar }.count()
return runLengthEncoding(text.substring(count),prev + "$count$initialChar" )
}
================================================
FILE: Compression/CompressionTest.kt
================================================
import compression.runLengthEncoding
import org.jetbrains.spek.api.Spek
import org.junit.Assert.*
/**
* Spek BDD test for Run Length Encoding
*/
class RunLengthEncodingTest: Spek({
given("Empty String"){
it("Returns Empty String"){
assertEquals("",runLengthEncoding(""))
}
}
given("Single character"){
it("Returns 1A"){
assertEquals("1B",runLengthEncoding("B"))
}
}
given("All same Character"){
it("It returns 5A"){
assertEquals("5A",runLengthEncoding("AAAAA"))
}
}
given("A mix of characters then "){
it("It returns expected encoding"){
assertEquals("5A3B4C2A",runLengthEncoding("AAAAABBBCCCCAA"))
}
}
given("A longer string then "){
it("It returns expected encoding without overflow"){
assertEquals("5A3B4C7A3B4C7A3B4C7A3B4C7A3B4C7A3B4C7A3B4C7A3B4C7A3B4C2A",
runLengthEncoding("AAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAAAAAAABBBCCCCAA"))
}
}
})
================================================
FILE: Compression/README.markdown
================================================
# Run-length encoding
Run-length encoding (RLE) is a very simple form of lossless data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run. This is most useful on data that contains many such runs. Consider, for example, simple graphic images such as icons, line drawings, and animations. It is not useful with files that don't have many runs as it could greatly increase the file size.
RLE may also be used to refer to an early graphics file format supported by CompuServe for compressing black and white images, but was widely supplanted by their later Graphics Interchange Format. RLE also refers to a little-used image format in Windows 3.x, with the extension rle, which is a Run Length Encoded Bitmap, used to compress the Windows 3.x startup screen.
source:Wikipedia
## The code
```kotlin
tailrec fun runLengthEncoding(text:String,prev:String=""):String {
if (text.length == 0){
return prev
}
val initialChar = text.get(0)
val count = text.takeWhile{ it==initialChar }.count()
return runLengthEncoding(text.substring(count),prev + "$count$initialChar" )
}
```
Code by: - [Andy Bowes](https://github.com/AndyBowes)
================================================
FILE: DepthFirstSearch/AdjacencyList.kt
================================================
class AdjacencyList<T: Comparable<T>>: Graphable<T> {
var adjacencyMap: MutableMap<Vertex<T>, MutableList<Edge<T>>> = mutableMapOf()
private fun addDirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
val edge = Edge(source, destination, weight)
adjacencyMap[source]?.add(edge)
}
private fun addUndirectedEdge(vertices: Pair<Vertex<T>, Vertex<T>>, weight: Double?) {
val (source, destination) = vertices
addDirectedEdge(source, destination, weight)
addDirectedEdge(destination, source, weight)
}
override fun createVertex(data: T): Vertex<T> {
val vertex = Vertex(data)
adjacencyMap[vertex] ?: run {
adjacencyMap[vertex] = mutableListOf()
}
return vertex
}
override fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double?) = when(type) {
is Directed -> {
addDirectedEdge(source, destination, weight)
}
is Undirected -> {
addUndirectedEdge(Pair(source, destination), weight)
}
}
override fun weight(source: Vertex<T>, destination: Vertex<T>): Double? {
val edges = adjacencyMap[source]
edges?.let {
it.forEach { edge ->
if (edge.destination == destination) return edge.weight
}
}
return null
}
override fun edges(source: Vertex<T>): MutableList<Edge<T>>? = adjacencyMap[source]
override fun toString(): String {
var result = ""
for ((vertex, edges) in adjacencyMap) {
var edgeString = ""
for ((index, edge) in edges.withIndex()) {
if (index != edges.count() - 1) {
edgeString += "${edge.destination}, "
} else {
edgeString += "${edge.destination}"
}
}
result += "$vertex ---> [ $edgeString ] \n"
}
return result
}
}
================================================
FILE: DepthFirstSearch/DepthFirstSearch.kt
================================================
fun main(args: Array<String>) {
val adjacencyList = AdjacencyList<String>()
val s = adjacencyList.createVertex("S")
val a = adjacencyList.createVertex("A")
val b = adjacencyList.createVertex("B")
val c = adjacencyList.createVertex("C")
val d = adjacencyList.createVertex("D")
val f = adjacencyList.createVertex("F")
val g = adjacencyList.createVertex("G")
val e = adjacencyList.createVertex("E")
adjacencyList.add(Undirected(), s, a)
adjacencyList.add(Undirected(), a, b)
adjacencyList.add(Undirected(), a, d)
adjacencyList.add(Undirected(), a, c)
adjacencyList.add(Undirected(), b, d)
adjacencyList.add(Undirected(), d, g)
adjacencyList.add(Undirected(), d, f)
adjacencyList.add(Undirected(), f, e)
print(adjacencyList)
print(depthFirstSearch(s, e, adjacencyList))
}
fun depthFirstSearch(start: VertexString, end: VertexString, graph: AdjacencyList<String>): Stack<VertexString> {
val visited: MutableSet<VertexString> = mutableSetOf()
val stack = Stack<VertexString>()
stack.push(start)
visited.add(start)
var vertex = stack.peek()
loop@while (vertex != null && vertex != end) {
val neighbors = graph.edges(vertex)
if (neighbors != null && neighbors.count() > 0) {
for (edge in neighbors) {
if (!visited.contains(edge.destination)) {
visited.add(edge.destination)
stack.push(edge.destination)
print("$stack")
vertex = stack.peek()
continue@loop
}
}
} else {
print("backtrack from $vertex")
stack.pop()
vertex = stack.peek()
continue
}
print("backtrack from $vertex")
stack.pop()
vertex = stack.peek()
}
return stack
}
================================================
FILE: DepthFirstSearch/Edge.kt
================================================
sealed class EdgeType
class Directed() : EdgeType()
class Undirected(): EdgeType()
data class Edge<T:Comparable<T>>(var source: Vertex<T>, var destination: Vertex<T>, val weight: Double?)
================================================
FILE: DepthFirstSearch/Graphable.kt
================================================
interface Graphable<T:Comparable<T>> {
fun createVertex(data: T): Vertex<T>
fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double? = 0.0)
fun weight(source: Vertex<T>, destination: Vertex<T>): Double?
fun edges(source: Vertex<T>): MutableList<Edge<T>>?
}
================================================
FILE: DepthFirstSearch/README.markdown
================================================
# Depth-First Search
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root (selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking.
A version of depth-first search was investigated in the 19th century by French mathematician Charles Pierre Trémaux as a strategy for solving mazes.
Algorithms that use depth-first search as a building block include:
* Finding connected components.
* Topological sorting.
* Finding 2-(edge or vertex)-connected components.
* Finding 3-(edge or vertex)-connected components.
* Finding the bridges of a graph.
* Generating words in order to plot the Limit Set of a Group.
* Finding strongly connected components.
* Planarity testing[7][8]
* Solving puzzles with only one solution, such as mazes. (DFS can be adapted to find all solutions to a maze by only including nodes on the current path in the visited set.)
* Maze generation may use a randomized depth-first search.
* Finding biconnectivity in graphs.
source:Wikipedia
================================================
FILE: DepthFirstSearch/Vertex.kt
================================================
data class Vertex<T:Comparable<T>>(val data: T) {
override fun toString(): String {
return "$data"
}
}
================================================
FILE: Deque/Deque.kt
================================================
package deque
/**
* Implementation of the Deque functionality which provides a double ended queue.
*
* This implementation of Deque is backed by a MutableList
*
* Created by Andy Bowes on 05/05/2016.
*/
class Deque<T>(){
var backingList : MutableList<T> = arrayListOf()
fun addFirst(element:T){
backingList.add(0,element)
}
fun getFirst():T?{
if (backingList.isEmpty()){
return null
}
val value = backingList.first()
removeFirst()
return value
}
fun removeFirst(){
if (backingList.isNotEmpty()) backingList.removeAt(0)
}
fun peekFirst(): T?{
return if (backingList.isNotEmpty()) backingList.first() else null
}
fun addLast(element:T){
backingList.add(element)
}
fun getLast():T?{
if (backingList.isEmpty()){
return null
}
val value = backingList.last()
removeLast()
return value
}
fun removeLast(){
if (backingList.isNotEmpty()) backingList.removeAt(backingList.size - 1)
}
fun peekLast():T?{
return if (backingList.isNotEmpty()) backingList.last() else null
}
}
================================================
FILE: Deque/DequeTest.kt
================================================
package deque
import org.jetbrains.spek.api.Spek
import org.junit.Assert.*
/**
* Spek BDD Test for Deque Class
*/
class DequeSpecs: Spek(spekBody = {
given("Given an Empty Queue") {
val deque: Deque<Int> = Deque()
on("Peeking first value") {
val value = deque.getFirst()
it("should result in null value") {
assertNull(value)
}
}
on("Peeking last value"){
val value = deque.getLast()
it("should result in a null value"){
assertNull(value)
}
}
}
given("Given a Queue with 1 value") {
val deque: Deque<Int> = Deque()
deque.addFirst(1)
on("Fetching first value") {
val value = deque.getFirst()
it("1. should not result in null value") {
assertNotNull(value)
assertEquals(1, value)
}
it("2. should have removed the final value"){
assertNull(deque.peekFirst())
}
}
}
given("Given a Queue with 1 value") {
val deque: Deque<Int> = Deque()
deque.addFirst(1)
on("Fetching last value") {
val value = deque.getLast()
it("1. should not result in null value") {
assertNotNull(value)
assertEquals(1, value)
}
it("2. should have removed the final value"){
assertNull(deque.peekFirst())
}
}
}
given("Given a Queue with 2 values") {
val deque: Deque<Int> = Deque()
deque.addFirst(2)
deque.addFirst(1)
on("Fetching first value") {
val value = deque.peekFirst()
it("should not result in null value") {
assertNotNull(value)
assertEquals(1, value)
}
}
on("Fetching last value") {
val value = deque.peekLast()
it("should not result in null value") {
assertNotNull(value)
assertEquals(2, value)
}
}
on("Removing last value") {
deque.removeLast()
it("There should be 1 value left on the queue") {
val value = deque.peekFirst()
assertNotNull(value)
assertEquals(1, value)
}
}
}
})
================================================
FILE: Deque/README.markdown
================================================
# Dequeue
In computer science, a double-ended queue (dequeue, often abbreviated to deque, pronounced deck) is an abstract data type that generalizes a queue, for which elements can be added to or removed from either the front (head) or back (tail).[1] It is also often called a head-tail linked list, though properly this refers to a specific data structure implementation
source:Wikipedia
## The code
```kotlin
class Deque<T>(){
var backingList : MutableList<T> = arrayListOf()
fun addFirst(element:T){
backingList.add(0,element)
}
fun getFirst():T?{
if (backingList.isEmpty()){
return null
}
val value = backingList.first()
removeFirst()
return value
}
fun removeFirst(){
if (backingList.isNotEmpty()) backingList.removeAt(0)
}
fun peekFirst(): T?{
return if (backingList.isNotEmpty()) backingList.first() else null
}
fun addLast(element:T){
backingList.add(element)
}
fun getLast():T?{
if (backingList.isEmpty()){
return null
}
val value = backingList.last()
removeLast()
return value
}
fun removeLast(){
if (backingList.isNotEmpty()) backingList.removeAt(backingList.size - 1)
}
fun peekLast():T?{
return if (backingList.isNotEmpty()) backingList.last() else null
}
}
```
Code by: - [Andy Bowes](https://github.com/AndyBowes)
================================================
FILE: InsertionSort/InsertionSort.kt
================================================
/**
* Created by gazollajunior on 09/04/16.
*/
fun <T:Comparable<T>> insertionsort(items:MutableList<T>):List<T>{
if (items.isEmpty()){
return items
}
for (count in 1..items.count() - 1){
val item = items[count]
var i = count
while (i>0 && item < items[i - 1]){
items[i] = items[i - 1]
i -= 1
}
items[i] = item
}
return items
}
fun main(args: Array<String>) {
val names = mutableListOf("John", "Tim", "Zack", "Daniel", "Adam")
println(names)
var ordered = insertionsort(names)
println(ordered)
}
================================================
FILE: InsertionSort/README.markdown
================================================
# Insertion sort
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.
source:Wikipedia
## The code
```kotlin
fun <T:Comparable<T>> insertionsort(items:MutableList<T>):List<T>{
if (items.isEmpty()){
return items
}
for (count in 1..items.count() - 1){
val item = items[count]
var i = count
while (i>0 && item < items[i - 1]){
items[i] = items[i - 1]
i -= 1
}
items[i] = item
}
return items
}
```
================================================
FILE: LinearSearch/LinearSearch.kt
================================================
/**
* Created by gazollajunior on 05/04/16.
*/
fun <T:Comparable<T>>linearSearch(list:List<T>, key:T):Int?{
for ((index, value) in list.withIndex()) {
if (value == key) return index
}
return null
}
fun main(args: Array<String>) {
println("\nOrdered list:")
val ordered = listOf<String>("Adam", "Clark", "John", "Tim", "Zack")
println(ordered)
val name = "John"
val position = linearSearch(ordered, name)
println("\n${name} is in the position ${position} in the ordered List.")
}
================================================
FILE: LinearSearch/README.markdown
================================================
# Linear Search
Linear search is the simplest search algorithm; it is a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list. Its expected cost is also proportional to the number of elements if all elements are searched equally. If the list has more than a few elements and is searched often, then more complicated search methods such as binary search or hashing may be appropriate. Those methods have faster search times but require additional resources to attain that speed.
source:Wikipedia
## The code
```kotlin
fun <T:Comparable<T>>linearSearch(list:List<T>, key:T):Int?{
for ((index, value) in list.withIndex()) {
if (value == key) return index
}
return null
}
```
================================================
FILE: LinkedList/LinkedList.kt
================================================
/**
* Created by gazollajunior on 07/04/16.
*/
class Node<T>(value: T){
var value:T = value
var next: Node<T>? = null
var previous:Node<T>? = null
}
class LinkedList<T> {
private var head:Node<T>? = null
var isEmpty:Boolean = head == null
fun first():Node<T>? = head
fun last(): Node<T>? {
var node = head
if (node != null){
while (node?.next != null) {
node = node?.next
}
return node
} else {
return null
}
}
fun count():Int {
var node = head
if (node != null){
var counter = 1
while (node?.next != null){
node = node?.next
counter += 1
}
return counter
} else {
return 0
}
}
fun nodeAtIndex(index: Int) : Node<T>? {
if (index >= 0) {
var node = head
var i = index
while (node != null) {
if (i == 0) return node
i -= 1
node = node.next
}
}
return null
}
fun append(value: T) {
var newNode = Node(value)
var lastNode = this.last()
if (lastNode != null) {
newNode.previous = lastNode
lastNode.next = newNode
} else {
head = newNode
}
}
fun removeAll() {
head = null
}
fun removeNode(node: Node<T>):T {
val prev = node.previous
val next = node.next
if (prev != null) {
prev.next = next
} else {
head = next
}
next?.previous = prev
node.previous = null
node.next = null
return node.value
}
fun removeLast() : T? {
val last = this.last()
if (last != null) {
return removeNode(last)
} else {
return null
}
}
fun removeAtIndex(index: Int):T? {
val node = nodeAtIndex(index)
if (node != null) {
return removeNode(node)
} else {
return null
}
}
override fun toString(): String {
var s = "["
var node = head
while (node != null) {
s += "${node.value}"
node = node.next
if (node != null) { s += ", " }
}
return s + "]"
}
}
fun main(args: Array<String>) {
var ll = LinkedList<String>()
ll.append("John")
println(ll)
ll.append("Carl")
println(ll)
ll.append("Zack")
println(ll)
ll.append("Tim")
println(ll)
ll.append("Steve")
println(ll)
ll.append("Peter")
println(ll)
print("\n\n")
println("first item: ${ll.first()?.value}")
println("last item: ${ll.last()?.value}")
println("second item: ${ll.first()?.next?.value}")
println("penultimate item: ${ll.last()?.previous?.value}")
println("\n4th item: ${ll.nodeAtIndex(3)?.value}")
println("\nthe list has ${ll.count()} items")
}
================================================
FILE: LinkedList/README.markdown
================================================
# Linked List
A linked list is a linear collection of data elements, called nodes pointing to the next node by means of a pointer. It is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of data and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.
source:Wikipedia
## The Node
```kotlin
class Node<T>(value: T){
var value:T = value
var next: Node<T>? = null
var previous:Node<T>? = null
}
```
## The Linked List
```kotlin
class LinkedList<T> {
private var head:Node<T>? = null
var isEmpty:Boolean = head == null
fun first():Node<T>? = head
fun last(): Node<T>? {
var node = head
if (node != null){
while (node?.next != null) {
node = node?.next
}
return node
} else {
return null
}
}
fun count():Int {
var node = head
if (node != null){
var counter = 1
while (node?.next != null){
node = node?.next
counter += 1
}
return counter
} else {
return 0
}
}
fun nodeAtIndex(index: Int) : Node<T>? {
if (index >= 0) {
var node = head
var i = index
while (node != null) {
if (i == 0) return node
i -= 1
node = node.next
}
}
return null
}
fun append(value: T) {
var newNode = Node(value)
var lastNode = this.last()
if (lastNode != null) {
newNode.previous = lastNode
lastNode.next = newNode
} else {
head = newNode
}
}
fun removeAll() {
head = null
}
fun removeNode(node: Node<T>):T {
val prev = node.previous
val next = node.next
if (prev != null) {
prev.next = next
} else {
head = next
}
next?.previous = prev
node.previous = null
node.next = null
return node.value
}
fun removeLast() : T? {
val last = this.last()
if (last != null) {
return removeNode(last)
} else {
return null
}
}
fun removeAtIndex(index: Int):T? {
val node = nodeAtIndex(index)
if (node != null) {
return removeNode(node)
} else {
return null
}
}
override fun toString(): String {
var s = "["
var node = head
while (node != null) {
s += "${node.value}"
node = node.next
if (node != null) { s += ", " }
}
return s + "]"
}
}
```
================================================
FILE: MergeSort/MergeSort.kt
================================================
/**
* Created by gazollajunior on 09/04/16.
*/
fun <T:Comparable<T>>mergesort(items:MutableList<T>):MutableList<T>{
if (items.isEmpty()){
return items
}
fun merge(left:MutableList<T>, right:MutableList<T>):MutableList<T>{
var merged: MutableList<T> = arrayListOf<T>()
while(!left.isEmpty() && !right.isEmpty()){
val temp:T
if (left.first() < right.first()) {
temp = left.removeAt(0)
} else {
temp = right.removeAt(0)
}
merged.add(temp)
}
if (!left.isEmpty()) merged.addAll(left)
if (!right.isEmpty()) merged.addAll(right)
return merged
}
val pivot = items.count()/2
var left = mergesort(items.subList(0, pivot))
var right = mergesort(items.subList(pivot, items.count()-1))
return merge(left, right)
}
fun main(args: Array<String>) {
val names = mutableListOf("John", "Tim", "Zack", "Daniel", "Adam")
println(names)
var ordered = mergesort(names)
println(ordered)
}
================================================
FILE: MergeSort/README.markdown
================================================
# MergeSort
Merge Sort is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945.
source:Wikipedia
## The code
```kotlin
fun <T:Comparable<T>>mergesort(items:MutableList<T>):MutableList<T>{
if (items.isEmpty()){
return items
}
fun merge(left:MutableList<T>, right:MutableList<T>):MutableList<T>{
var merged: MutableList<T> = arrayListOf<T>()
while(!left.isEmpty() && !right.isEmpty()){
val temp:T
if (left.first() < right.first()) {
temp = left.removeAt(0)
} else {
temp = right.removeAt(0)
}
merged.add(temp)
}
if (!left.isEmpty()) merged.addAll(left)
if (!right.isEmpty()) merged.addAll(right)
return merged
}
val pivot = items.count()/2
var left = mergesort(items.subList(0, pivot))
var right = mergesort(items.subList(pivot, items.count()-1))
return merge(left, right)
}
```
================================================
FILE: OrderedArray/OrderedArray.kt
================================================
/**
* Created by gazollajunior on 02/04/16.
*/
class OrderedArray<T:Comparable<T>>(list:MutableList<T>){
var items: MutableList<T> = this.quicksort(list) as MutableList<T>
/**
* Use quicksort algorithm to order elements in array
*/
fun quicksort(its:List<T>):List<T>{
if (its.count() < 1) return its
val pivot = its[its.count()/2]
val equal = its.filter { it == pivot }
val less = its.filter { it < pivot }
val greater = its.filter { it > pivot }
return quicksort(less) + equal + quicksort(greater)
}
fun insert(element:T){
val position = findElementPosition(element)
this.items.add(position, element)
}
/**
* Use binarySearch algorithm to find the position for the new element in array
*/
fun findElementPosition(element:T):Int{
var rangeStart = 0
var rangeEnd = this.items.count()
while (rangeStart < rangeEnd) {
val midIndex = rangeStart + (rangeEnd - rangeStart)/2
if (this.items[midIndex] == element) {
return midIndex
} else if (this.items[midIndex] < element){
rangeStart = midIndex + 1
} else {
rangeEnd = midIndex
}
}
return rangeStart
}
override fun toString():String = this.items.toString()
}
fun main(args: Array<String>) {
println("\nOriginal list:")
val names = listOf<String>("Tim", "Steve", "Zack", "Adam", "John", "Peter", "Clark") as MutableList<String>
println(names)
println("\nOrdered list:")
val ordered = OrderedArray<String>(names)
println(ordered)
val n1 = "Paul"
println("\nAdding ${n1} to the list:")
ordered.insert(n1)
println(ordered)
val n2 = "Demetrius"
println("\nAdding ${n2} to the list:")
ordered.insert(n2)
println(ordered)
}
================================================
FILE: OrderedArray/README.markdown
================================================
# Ordered Array
A sorted array is an array data structure in which each element is sorted in numerical, alphabetical, or some other order, and placed at equally spaced addresses in computer memory.
It is typically used in computer science to implement static lookup tables to hold multiple values which have the same data type. Sorting a stack of baby unicorns of different ages is useful in organising data in ordered form and recovering them rapidly.
The implementation is quite basic:
```kotlin
class OrderedArray<T:Comparable<T>>(list:MutableList<T>){
var items: MutableList<T> = this.quicksort(list) as MutableList<T>
/**
* Use quicksort algorithm to order elements in array
*/
fun quicksort(its:List<T>):List<T>{
if (its.count() < 1) return its
val pivot = its[its.count()/2]
val equal = its.filter { it == pivot }
val less = its.filter { it < pivot }
val greater = its.filter { it > pivot }
return quicksort(less) + equal + quicksort(greater)
}
fun insert(element:T){
val position = findElementPosition(element)
this.items.add(position, element)
}
/**
* Use binarySearch algorithm to find the position for the new element in array
*/
fun findElementPosition(element:T):Int{
var rangeStart = 0
var rangeEnd = this.items.count()
while (rangeStart < rangeEnd) {
val midIndex = rangeStart + (rangeEnd - rangeStart)/2
if (this.items[midIndex] == element) {
return midIndex
} else if (this.items[midIndex] < element){
rangeStart = midIndex + 1
} else {
rangeEnd = midIndex
}
}
return rangeStart
}
override fun toString():String = this.items.toString()
}
```
================================================
FILE: OrderedSet/OrderedSet.kt
================================================
/**
* Created by gazollajunior on 08/04/16.
*/
class OrderedSet<T:Comparable<T>>(list:MutableList<T>){
var items: MutableList<T> = list
fun insert(element:T) {
if (exists(element)) {
return
}
for (i in 0..this.items.count() - 1){
if (this.items[i] > element){
this.items.add(i, element)
return
}
}
this.items.add(element)
}
/**
* Use binarySearch algorithm to find the position for the new element in array
*/
fun findElementPosition(element:T):Int?{
var rangeStart = 0
var rangeEnd = this.items.count()
while (rangeStart < rangeEnd) {
val midIndex = rangeStart + (rangeEnd - rangeStart)/2
if (this.items[midIndex] == element) {
return midIndex
} else if (this.items[midIndex] < element){
rangeStart = midIndex + 1
} else {
rangeEnd = midIndex
}
}
return null
}
override fun toString():String = this.items.toString()
fun isEmpty():Boolean = this.items.isEmpty()
fun exists(element:T):Boolean = findElementPosition(element) != null
fun count():Int = this.items.count()
fun remove(element:T) {
val position = findElementPosition(element)
if (position != null) {
this.items.removeAt(position)
}
}
fun removeAll() = this.items.removeAll(this.items)
fun max():T? {
if (count() != 0) {
return this.items[count() - 1]
} else {
return null
}
}
fun min():T? {
if (count() != 0) {
return this.items[0]
} else {
return null
}
}
}
fun main(args: Array<String>) {
println("\nOriginal set:")
val names = mutableListOf<String>("Demetrius")
var nameSet = OrderedSet<String>(names)
println(nameSet)
val n1 = "Adam"
println("\nAdding ${n1} to the list:")
nameSet.insert(n1)
println(nameSet)
val n2 = "Tim"
println("\nAdding ${n2} to the list:")
nameSet.insert(n2)
println(nameSet)
val n3 = "Zack"
println("\nAdding ${n3} to the list:")
nameSet.insert(n3)
println(nameSet)
val n4 = "Zack"
println("\nTry Add ${n4} again to the list:")
nameSet.insert(n4)
println(nameSet)
nameSet.remove(n2)
println("\nRemoving ${n2} from the list:")
println(nameSet)
nameSet.remove(n4)
println("\nRemoving ${n4} from the list:")
println(nameSet)
nameSet.remove(n1)
println("\nRemoving ${n1} from the list:")
println(nameSet)
}
================================================
FILE: OrderedSet/README.markdown
================================================
# Ordered Set
An ordered set is a common data structure that supports O(log N) lookups, insertions and removals. Ordered set is also sometimes used as an alternative to a hash map, for example in STL’s map.
## The code
```kotlin
class OrderedSet<T:Comparable<T>>(list:MutableList<T>){
var items: MutableList<T> = list
fun insert(element:T) {
if (exists(element)) {
return
}
for (i in 0..this.items.count() - 1){
if (this.items[i] > element){
this.items.add(i, element)
return
}
}
this.items.add(element)
}
/**
* Use binarySearch algorithm to find the position for the new element in array
*/
fun findElementPosition(element:T):Int?{
var rangeStart = 0
var rangeEnd = this.items.count()
while (rangeStart < rangeEnd) {
val midIndex = rangeStart + (rangeEnd - rangeStart)/2
if (this.items[midIndex] == element) {
return midIndex
} else if (this.items[midIndex] < element){
rangeStart = midIndex + 1
} else {
rangeEnd = midIndex
}
}
return null
}
override fun toString():String = this.items.toString()
fun isEmpty():Boolean = this.items.isEmpty()
fun exists(element:T):Boolean = findElementPosition(element) != null
fun count():Int = this.items.count()
fun remove(element:T) {
val position = findElementPosition(element)
if (position != null) {
this.items.removeAt(position)
}
}
fun removeAll() = this.items.removeAll(this.items)
fun max():T? {
if (count() != 0) {
return this.items[count() - 1]
} else {
return null
}
}
fun min():T? {
if (count() != 0) {
return this.items[0]
} else {
return null
}
}
}
```
================================================
FILE: Queue/Queue.kt
================================================
/**
* Created by gazollajunior on 05/04/16.
*/
class Queue <T>(list:MutableList<T>): Iterator<T>{
var itCounter: Int = 0
var items:MutableList<T> = list
fun isEmpty():Boolean = this.items.isEmpty()
fun count():Int = this.items.count()
override fun toString() = this.items.toString()
fun enqueue(element: T){
this.items.add(element)
}
fun dequeue():T?{
if (this.isEmpty()){
return null
} else {
return this.items.removeAt(0)
}
}
fun peek():T?{
return this.items[0]
}
override fun hasNext(): Boolean {
val hasNext = itCounter < count()
// As soon as condition fails, reset the counter
if (!hasNext) itCounter = 0
return hasNext
}
override fun next(): T {
if (hasNext()) {
val topPos: Int = (count() - 1) - itCounter
itCounter++
return this.items[topPos]
} else {
throw NoSuchElementException("No such element")
}
}
}
fun main(args: Array<String>) {
var initialValue = mutableListOf<Int>(10)
var queue = Queue<Int>(initialValue)
println(queue)
queue.enqueue(22)
println(queue)
queue.enqueue(55)
println(queue)
queue.enqueue(77)
println(queue)
queue.dequeue()
println(queue)
queue.dequeue()
println(queue)
queue.dequeue()
println(queue)
// Iterating over queue
for (item in queue) println("Item in queue : " + item)
}
================================================
FILE: Queue/README.markdown
================================================
# Queue
Queue is a particular kind of abstract data type or collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position, known as enqueue, and removal of entities from the front terminal position, known as dequeue. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that once a new element is added, all elements that were added before have to be removed before the new element can be removed. Often a peek or front operation is also entered, returning the value of the front element without dequeuing it. A queue is an example of a linear data structure, or more abstractly a sequential collection.
source:Wikipedia

## The code
```kotlin
class Queue <T>(list:MutableList<T>){
var items:MutableList<T> = list
fun isEmpty():Boolean = this.items.isEmpty()
fun count():Int = this.items.count()
override fun toString() = this.items.toString()
fun enqueue(element: T){
this.items.add(element)
}
fun dequeue():T?{
if (this.isEmpty()){
return null
} else {
return this.items.removeAt(0)
}
}
fun peek():T?{
return this.items[0]
}
}
```
================================================
FILE: QuickSort/QuickSort.kt
================================================
/**
* Created by gazollajunior on 01/04/16.
*/
fun <T:Comparable<T>>quicksort(items:List<T>):List<T>{
if (items.count() < 2){
return items
}
val pivot = items[items.count()/2]
val equal = items.filter { it == pivot }
val less = items.filter { it < pivot }
val greater = items.filter { it > pivot }
return quicksort(less) + equal + quicksort(greater)
}
fun main(args: Array<String>) {
println("\nOriginal list:")
val names = listOf<String>("Tim", "Steve", "Zack", "Adam", "John", "Peter", "Clark")
println(names)
println("\nOrdered list:")
val ordered = quicksort(names)
println(ordered)
}
================================================
FILE: QuickSort/README.markdown
================================================
# Quicksort
Quicksort is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order. Developed by Tony Hoare in 1959, with his work published in 1961, it is still a commonly used algorithm for sorting. When implemented well, it can be about two or three times faster than its main competitors, merge sort and heapsort.
Here's an implementation in kotlin that should be easy to understand:
```kotlin
fun <T:Comparable<T>>quicksort(items:List<T>):List<T>{
if (items.count() < 1) return items
val pivot = items[items.count()/2]
val equal = items.filter { it == pivot }
val less = items.filter { it < pivot }
val greater = items.filter { it > pivot }
return quicksort(less) + equal + quicksort(greater)
}
```
================================================
FILE: README.markdown
================================================
# Welcome to Kotlin Algorithms
Here you'll find implementations of popular algorithms and data structures in [Kotlin programming language](https://kotlinlang.org/).
This is a work in progress. More algorithms will be added soon. :-)
**Suggestions and contributions are welcome!**
## The algorithms
### Searching
- [Linear Search](LinearSearch/)
- [Binary Search](BinarySearch/)
- [Count Occurrences]
- [Select Minimum / Maximum]
- [k-th Largest Element]
- [Selection Sampling]
- [Union-Find]
- [Depth-First Search](DepthFirstSearch/)
### String Search
- [Brute-Force String Search]
- [Boyer-Moore]
- Rabin-Karp
- [Longest Common Subsequence]
### Sorting
Basic sorts:
- [Insertion Sort](InsertionSort/)
- [Selection Sort](SelectionSort/)
- [Shell Sort](ShellSort/)
Fast sorts:
- [Quicksort](QuickSort/)
- [Merge Sort](MergeSort/)
- [Heap Sort]
Special-purpose sorts:
- Bucket Sort
- Counting Sort
- Radix Sort
- [Topological Sort]
### Compression
- [Run-Length Encoding (RLE)](Compression/)
- [Huffman Coding]
### Miscellaneous
- [Shuffle](Shuffle/) Randomly rearranges the contents of an array.
### Machine learning
- [k-Means Clustering]
- k-Nearest Neighbors
- Linear Regression
- Logistic Regression
- Neural Networks
- PageRank
## Data structures
### Variations on arrays
- [Array2D]
- [Bit Set]
- [Fixed Size Array]
- [Ordered Array](Ordered Array/)
### Queues
- [Stack](Stack/)
- [Queue](Queue/)
- [Deque](Deque/)
- [Priority Queue]
- [Bounded Priority Queue]
- [Ring Buffer]
### Lists
- [Linked List](LinkedList/)
- Skip List
### Trees
- [Tree](Tree/)
- [Binary Tree]
- [Binary Search Tree (BST)]
- [AVL Tree]
- Red-Black Tree
- Splay Tree
- Threaded Binary Tree
- [Segment Tree]
- kd-Tree
- [Heap]
- Fibonacci Heap
- Trie
- [B-Tree]
### Hashing
- [Hash Table]
- Hash Functions
### Sets
- [Bloom Filter]
- [Hash Set]
- Multiset
- [Ordered Set](OrderedSet/)
### Graphs
- [Graph]
- [Breadth-First Search (BFS)]
- [Depth-First Search (DFS)]
- [Shortest Path]
- [Minimum Spanning Tree]
- All Paths
## License
All content is licensed under the terms of the MIT open source license.
### Contributors
* [Andy Bowes](https://github.com/AndyBowes)
* [Niccolò Passolunghi](https://github.com/nicopasso)
* [Vansh Gandhi](https://github.com/vanshg)
* [Szabolcs Besenyei](https://github.com/besza)
* [Markus Kramer](https://github.com/MarkusKramer)
* [Luís Soares](https://github.com/lsoares)
### Contact
* Sebastian Gazolla Jr
* [@gazollajr](http://twitter.com/gazollajr)
* [http://gazapps.com](http://gazapps.com)
* [http://about.me/gazolla](http://about.me/gazolla)
================================================
FILE: SelectionSort/README.markdown
================================================
# Selection sort
Selection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and it has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.
source:Wikipedia
## The code
```kotlin
fun <T:Comparable<T>>selectionsort(items:MutableList<T>):MutableList<T>{
if (items.isEmpty()){
return items
}
for (idx in 0..items.count()){
val array = items.subList(0,items.count()-idx)
val minItem = array.min()
val indexOfMinItem = array.indexOf(minItem)
if (minItem != null) {
items.removeAt(indexOfMinItem)
items.add(minItem)
}
}
return items
}
```
================================================
FILE: SelectionSort/SelectionSort.kt
================================================
/**
* Created by gazollajunior on 09/04/16.
*/
fun <T:Comparable<T>>selectionsort(items:MutableList<T>):MutableList<T>{
if (items.isEmpty()){
return items
}
for (idx in 0..items.count()){
val array = items.subList(0,items.count()-idx)
val minItem = array.min()
val indexOfMinItem = array.indexOf(minItem)
if (minItem != null) {
items.removeAt(indexOfMinItem)
items.add(minItem)
}
}
return items
}
fun main(args: Array<String>) {
println("Selection Sort")
val names = mutableListOf("John", "Tim", "Zack", "Daniel", "Adam")
println(names)
var ordered = insertionsort(names)
println(ordered)
}
================================================
FILE: ShellSort/README.markdown
================================================
# Shell Sort
Shellsort, also known as Shell sort or Shell's method, is an in-place comparison sort.
It can be seen as either a generalization of sorting by exchange (bubble sort) or sorting by insertion (insertion sort).
The method starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared.
Starting with far apart elements, it can move some out-of-place elements into position faster than a simple nearest neighbor exchange.
Donald Shell published the first version of this sort in 1959.
The running time of Shellsort is heavily dependent on the gap sequence it uses.
source: [Wikipedia ShellSort](https://en.wikipedia.org/wiki/Shellsort)
================================================
FILE: ShellSort/ShellSort.kt
================================================
fun MutableList<Int>.swap(index1: Int, index2: Int) {
val tmp = this[index1]
this[index1] = this[index2]
this[index2] = tmp
}
fun MutableList<Int>.shellSort(): MutableList<Int> {
var sublistCount = count() / 2
while (sublistCount > 0) {
var index = 0
outer@while (index >= 0 && index < count()) {
if (index + sublistCount >= count()) break
if (this[index] > this[index + sublistCount]) {
swap(index, index + sublistCount)
}
if (sublistCount == 1 && index > 0) {
while (this[index - 1] > this[index] && index - 1 > 0) {
swap(index - 1, index)
index -= 1
}
index++
} else {
index++
continue@outer
}
}
sublistCount /= 2
}
return this
}
fun main(args: Array<String>) {
var mutableListOfInt = mutableListOf(10, 4, 5, 2, 1, 3, 6, 9, 8, 7)
print(mutableListOfInt.shellSort().toString())
}
================================================
FILE: Shuffle/README.markdown
================================================
# Shuffle
Randomly rearranges the contents of an array.
## The code
Here is a implementation of Shuffle in kotlin:
```kotlin
fun <T:Comparable<T>>shuffle(items:MutableList<T>):List<T>{
val rg : Random = Random()
for (i in 0..items.size - 1) {
val randomPosition = rg.nextInt(items.size)
val tmp : T = items[i]
items[i] = items[randomPosition]
items[randomPosition] = tmp
}
return items
}
```
Shuffle implementation provide by Markus Kramer. This implementation reuses existing code to do the shuffling and can be called like other kotlin collection functions.
```kotlin
/**
* Returns a randomized list.
*/
fun <T> Iterable<T>.shuffle(seed: Long? = null): List<T> {
val list = this.toMutableList()
val random = if (seed != null) Random(seed) else Random()
Collections.shuffle(list, random)
return list
}
```
================================================
FILE: Shuffle/Shuffle.kt
================================================
/**
* Created by gazollajunior on 03/04/16.
*/
import java.util.Random
fun <T:Comparable<T>>shuffle(items:MutableList<T>):List<T>{
val rg : Random = Random()
for (i in 0..items.size - 1) {
val randomPosition = rg.nextInt(items.size)
val tmp : T = items[i]
items[i] = items[randomPosition]
items[randomPosition] = tmp
}
return items
}
/* extension version */
fun <T> Iterable<T>.shuffle(): List<T> {
val list = this.toMutableList().apply { }
Collections.shuffle(list)
return list
}
fun main(args: Array<String>) {
println("\nOrdered list:")
val ordered = listOf<String>("Adam", "Clark", "John", "Tim", "Zack")
println(ordered)
println("\nshuffled list:")
val shuffled = shuffle(ordered as MutableList<String>)
print(shuffled)
val orderedB = listOf(1, 2, 3, 4, 5)
print(orderedB.shuffle())
}
================================================
FILE: Stack/README.markdown
================================================
# Stack
Stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element that was not yet removed. The order in which elements come off a stack gives rise to its alternative name, LIFO (for last in, first out). Additionally, a peek operation may give access to the top without modifying the stack.

## The code
```kotlin
class Stack<T:Comparable<T>>(list:MutableList<T>) {
var items: MutableList<T> = list
fun isEmpty():Boolean = this.items.isEmpty()
fun count():Int = this.items.count()
fun push(element:T) {
val position = this.count()
this.items.add(position, element)
}
override fun toString() = this.items.toString()
fun pop():T? {
if (this.isEmpty()) {
return null
} else {
val item = this.items.count() - 1
return this.items.removeAt(item)
}
}
fun peek():T? {
if (isEmpty()) {
return null
} else {
return this.items[this.items.count() - 1]
}
}
}
```
================================================
FILE: Stack/Stack.kt
================================================
/**
* Created by gazollajunior on 03/04/16.
*/
class Stack<T:Comparable<T>>(list:MutableList<T>):Iterator<T> {
var itCounter: Int = 0
var items: MutableList<T> = list
fun isEmpty():Boolean = this.items.isEmpty()
fun count():Int = this.items.count()
fun push(element:T) {
val position = this.count()
this.items.add(position, element)
}
override fun toString() = this.items.toString()
fun pop():T? {
if (this.isEmpty()) {
return null
} else {
val item = this.items.count() - 1
return this.items.removeAt(item)
}
}
fun peek():T? {
if (isEmpty()) {
return null
} else {
return this.items[this.items.count() - 1]
}
}
// Note Let the default implementation exist
// override fun toString(): String {
// val topDivider = "---Stack---\n"
// val bottomDivider = "\n-----------"
//
// val stackElements = array.map {
// "$it"
// }.reversed().joinToString("\n")
//
// return topDivider + stackElements + bottomDivider
//
// }
override fun hasNext(): Boolean {
val hasNext = itCounter < count()
// As soon as condition fails, reset the counter
if (!hasNext) itCounter = 0
return hasNext
}
override fun next(): T {
if (hasNext()) {
val topPos: Int = (count() - 1) - itCounter
itCounter++
return this.items[topPos]
} else {
throw NoSuchElementException("No such element")
}
}
}
fun main(args: Array<String>) {
var initialValue = mutableListOf<Int>(10)
var stack = Stack<Int>(initialValue)
println(stack)
stack.push(22)
println(stack)
stack.push(55)
println(stack)
stack.push(77)
println(stack)
stack.pop()
println(stack)
for (item in stack) println("Item in stack : " + item)
}
================================================
FILE: Tree/README.markdown
================================================
# Tree
Tree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.
A tree data structure can be defined recursively (locally) as a collection of nodes (starting at a root node), where each node is a data structure consisting of a value, together with a list of references to nodes (the "children"), with the constraints that no reference is duplicated, and none points to the root.
source: Wikipedia
## The code
```kotlin
class TreeNode<T>(value:T){
var value:T = value
var parent:TreeNode<T>? = null
var children:MutableList<TreeNode<T>> = mutableListOf()
fun addChild(node:TreeNode<T>){
children.add(node)
node.parent = this
}
override fun toString(): String {
var s = "${value}"
if (!children.isEmpty()) {
s += " {" + children.map { it.toString() } + " }"
}
return s
}
}
```
================================================
FILE: Tree/Tree.kt
================================================
/**
* Created by gazolla on 10/04/16.
*/
class TreeNode<T>(value:T){
var value:T = value
var parent:TreeNode<T>? = null
var children:MutableList<TreeNode<T>> = mutableListOf()
fun addChild(node:TreeNode<T>){
children.add(node)
node.parent = this
}
override fun toString(): String {
var s = "${value}"
if (!children.isEmpty()) {
s += " {" + children.map { it.toString() } + " }"
}
return s
}
}
fun main(args: Array<String>) {
val tree = TreeNode<String>( "beverages")
val hotNode = TreeNode<String>( "hot")
val coldNode = TreeNode<String>( "cold")
val teaNode = TreeNode<String>( "tea")
val coffeeNode = TreeNode<String>( "coffee")
val chocolateNode = TreeNode<String>( "cocoa")
val blackTeaNode = TreeNode<String>( "black")
val greenTeaNode = TreeNode<String>( "green")
val chaiTeaNode = TreeNode<String>( "chai")
val sodaNode = TreeNode<String>( "soda")
val milkNode = TreeNode<String>( "milk")
val gingerAleNode = TreeNode<String>( "ginger ale")
val bitterLemonNode = TreeNode<String>( "bitter lemon")
tree.addChild(hotNode)
tree.addChild(coldNode)
hotNode.addChild(teaNode)
hotNode.addChild(coffeeNode)
hotNode.addChild(chocolateNode)
coldNode.addChild(sodaNode)
coldNode.addChild(milkNode)
teaNode.addChild(blackTeaNode)
teaNode.addChild(greenTeaNode)
teaNode.addChild(chaiTeaNode)
sodaNode.addChild(gingerAleNode)
sodaNode.addChild(bitterLemonNode)
println(tree)
}
gitextract_bjd7u91h/
├── .idea/
│ ├── Kotlin-Algorithm.iml
│ ├── compiler.xml
│ ├── copyright/
│ │ └── profiles_settings.xml
│ ├── inspectionProfiles/
│ │ ├── Project_Default.xml
│ │ └── profiles_settings.xml
│ ├── kotlinc.xml
│ ├── markdown-navigator/
│ │ └── profiles_settings.xml
│ ├── markdown-navigator.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── vcs.xml
│ └── workspace.xml
├── BinarySearch/
│ ├── BinarySearch.kt
│ └── README.markdown
├── Combinatorics/
│ └── Combinatorics.kt
├── Compression/
│ ├── Compresion.kt
│ ├── CompressionTest.kt
│ └── README.markdown
├── DepthFirstSearch/
│ ├── AdjacencyList.kt
│ ├── DepthFirstSearch.kt
│ ├── Edge.kt
│ ├── Graphable.kt
│ ├── README.markdown
│ └── Vertex.kt
├── Deque/
│ ├── Deque.kt
│ ├── DequeTest.kt
│ └── README.markdown
├── InsertionSort/
│ ├── InsertionSort.kt
│ └── README.markdown
├── LinearSearch/
│ ├── LinearSearch.kt
│ └── README.markdown
├── LinkedList/
│ ├── LinkedList.kt
│ └── README.markdown
├── MergeSort/
│ ├── MergeSort.kt
│ └── README.markdown
├── OrderedArray/
│ ├── OrderedArray.kt
│ └── README.markdown
├── OrderedSet/
│ ├── OrderedSet.kt
│ └── README.markdown
├── Queue/
│ ├── Queue.kt
│ └── README.markdown
├── QuickSort/
│ ├── QuickSort.kt
│ └── README.markdown
├── README.markdown
├── SelectionSort/
│ ├── README.markdown
│ └── SelectionSort.kt
├── ShellSort/
│ ├── README.markdown
│ └── ShellSort.kt
├── Shuffle/
│ ├── README.markdown
│ └── Shuffle.kt
├── Stack/
│ ├── README.markdown
│ └── Stack.kt
└── Tree/
├── README.markdown
└── Tree.kt
Condensed preview — 54 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (114K chars).
[
{
"path": ".idea/Kotlin-Algorithm.iml",
"chars": 336,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module type=\"JAVA_MODULE\" version=\"4\">\n <component name=\"NewModuleRootManager\" "
},
{
"path": ".idea/compiler.xml",
"chars": 686,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"CompilerConfiguration\">\n <resourceExt"
},
{
"path": ".idea/copyright/profiles_settings.xml",
"chars": 74,
"preview": "<component name=\"CopyrightManager\">\n <settings default=\"\" />\n</component>"
},
{
"path": ".idea/inspectionProfiles/Project_Default.xml",
"chars": 376,
"preview": "<component name=\"InspectionProjectProfileManager\">\n <profile version=\"1.0\">\n <option name=\"myName\" value=\"Project De"
},
{
"path": ".idea/inspectionProfiles/profiles_settings.xml",
"chars": 235,
"preview": "<component name=\"InspectionProjectProfileManager\">\n <settings>\n <option name=\"PROJECT_PROFILE\" value=\"Project Defaul"
},
{
"path": ".idea/kotlinc.xml",
"chars": 232,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"KotlinCommonCompilerArguments\">\n <opt"
},
{
"path": ".idea/markdown-navigator/profiles_settings.xml",
"chars": 104,
"preview": "<component name=\"MarkdownNavigator.ProfileManager\">\n <settings default=\"\" pdf-export=\"\" />\n</component>"
},
{
"path": ".idea/markdown-navigator.xml",
"chars": 4007,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"MarkdownProjectSettings\">\n <PreviewSe"
},
{
"path": ".idea/misc.xml",
"chars": 2346,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"NullableNotNullManager\">\n <option nam"
},
{
"path": ".idea/modules.xml",
"chars": 284,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"ProjectModuleManager\">\n <modules>\n "
},
{
"path": ".idea/vcs.xml",
"chars": 167,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"VcsDirectoryMappings\">\n <mapping dire"
},
{
"path": ".idea/workspace.xml",
"chars": 41037,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"ChangeListManager\">\n <list default=\"t"
},
{
"path": "BinarySearch/BinarySearch.kt",
"chars": 1412,
"preview": "import java.util.*\n\n/**\n * Created by gazollajunior on 03/04/16.\n */\n\nfun <T: Comparable<T>> binarySearch(list: List<T>,"
},
{
"path": "BinarySearch/README.markdown",
"chars": 1058,
"preview": "# Binary Search\n\nBinary Search is a search algorithm that finds the position of a target value, whether alone or part of"
},
{
"path": "Combinatorics/Combinatorics.kt",
"chars": 1088,
"preview": "/**\n * Created by gazollajunior on 06/04/16.\n */\n\nfun factorial(number:Long):Long{\n if (number <= 1) return 1 else r"
},
{
"path": "Compression/Compresion.kt",
"chars": 417,
"preview": "package compression\n\n/**\n * Calculation of Run Length Encoding using Tail Recursion\n * Created by Andy on 05/05/2016.\n *"
},
{
"path": "Compression/CompressionTest.kt",
"chars": 1119,
"preview": "import compression.runLengthEncoding\nimport org.jetbrains.spek.api.Spek\nimport org.junit.Assert.*\n\n/**\n * Spek BDD test "
},
{
"path": "Compression/README.markdown",
"chars": 1306,
"preview": "# Run-length encoding\n\nRun-length encoding (RLE) is a very simple form of lossless data compression in which runs of dat"
},
{
"path": "DepthFirstSearch/AdjacencyList.kt",
"chars": 2012,
"preview": "class AdjacencyList<T: Comparable<T>>: Graphable<T> {\n\n var adjacencyMap: MutableMap<Vertex<T>, MutableList<Edge<T>>>"
},
{
"path": "DepthFirstSearch/DepthFirstSearch.kt",
"chars": 1901,
"preview": "fun main(args: Array<String>) {\n\n val adjacencyList = AdjacencyList<String>()\n\n val s = adjacencyList.createVertex"
},
{
"path": "DepthFirstSearch/Edge.kt",
"chars": 189,
"preview": "sealed class EdgeType\n\nclass Directed() : EdgeType()\nclass Undirected(): EdgeType()\n\ndata class Edge<T:Comparable<T>>(va"
},
{
"path": "DepthFirstSearch/Graphable.kt",
"chars": 300,
"preview": "interface Graphable<T:Comparable<T>> {\n\n fun createVertex(data: T): Vertex<T>\n fun add(type: EdgeType, source: Ver"
},
{
"path": "DepthFirstSearch/README.markdown",
"chars": 1110,
"preview": "# Depth-First Search\n\nDepth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures"
},
{
"path": "DepthFirstSearch/Vertex.kt",
"chars": 119,
"preview": "data class Vertex<T:Comparable<T>>(val data: T) {\n override fun toString(): String {\n return \"$data\"\n }\n}\n"
},
{
"path": "Deque/Deque.kt",
"chars": 1198,
"preview": "package deque\n\n/**\n * Implementation of the Deque functionality which provides a double ended queue.\n *\n * This implemen"
},
{
"path": "Deque/DequeTest.kt",
"chars": 2406,
"preview": "package deque\n\nimport org.jetbrains.spek.api.Spek\nimport org.junit.Assert.*\n\n/**\n * Spek BDD Test for Deque Class\n */\ncl"
},
{
"path": "Deque/README.markdown",
"chars": 1465,
"preview": "# Dequeue\n\nIn computer science, a double-ended queue (dequeue, often abbreviated to deque, pronounced deck) is an abstra"
},
{
"path": "InsertionSort/InsertionSort.kt",
"chars": 608,
"preview": "/**\n * Created by gazollajunior on 09/04/16.\n */\n\nfun <T:Comparable<T>> insertionsort(items:MutableList<T>):List<T>{\n "
},
{
"path": "InsertionSort/README.markdown",
"chars": 662,
"preview": "# Insertion sort\n\nInsertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at "
},
{
"path": "LinearSearch/LinearSearch.kt",
"chars": 528,
"preview": "/**\n * Created by gazollajunior on 05/04/16.\n */\n\nfun <T:Comparable<T>>linearSearch(list:List<T>, key:T):Int?{\n for ("
},
{
"path": "LinearSearch/README.markdown",
"chars": 752,
"preview": "# Linear Search\n\nLinear search is the simplest search algorithm; it is a special case of brute-force search. Its worst c"
},
{
"path": "LinkedList/LinkedList.kt",
"chars": 3114,
"preview": "/**\n * Created by gazollajunior on 07/04/16.\n */\n\nclass Node<T>(value: T){\n var value:T = value\n var next: Node<T>"
},
{
"path": "LinkedList/README.markdown",
"chars": 3004,
"preview": "# Linked List\n\nA linked list is a linear collection of data elements, called nodes pointing to the next node by means of"
},
{
"path": "MergeSort/MergeSort.kt",
"chars": 1073,
"preview": "/**\n * Created by gazollajunior on 09/04/16.\n */\nfun <T:Comparable<T>>mergesort(items:MutableList<T>):MutableList<T>{\n "
},
{
"path": "MergeSort/README.markdown",
"chars": 1218,
"preview": "# MergeSort\n\nMerge Sort is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produ"
},
{
"path": "OrderedArray/OrderedArray.kt",
"chars": 1911,
"preview": "/**\n * Created by gazollajunior on 02/04/16.\n */\n\n\nclass OrderedArray<T:Comparable<T>>(list:MutableList<T>){\n\n var it"
},
{
"path": "OrderedArray/README.markdown",
"chars": 1844,
"preview": "# Ordered Array\n\nA sorted array is an array data structure in which each element is sorted in numerical, alphabetical, o"
},
{
"path": "OrderedSet/OrderedSet.kt",
"chars": 2679,
"preview": "/**\n * Created by gazollajunior on 08/04/16.\n */\n\nclass OrderedSet<T:Comparable<T>>(list:MutableList<T>){\n\n var items"
},
{
"path": "OrderedSet/README.markdown",
"chars": 1988,
"preview": "# Ordered Set\n\nAn ordered set is a common data structure that supports O(log N) lookups, insertions and removals. Ordere"
},
{
"path": "Queue/Queue.kt",
"chars": 1530,
"preview": "/**\n * Created by gazollajunior on 05/04/16.\n */\nclass Queue <T>(list:MutableList<T>): Iterator<T>{\n\n var itCounter: "
},
{
"path": "Queue/README.markdown",
"chars": 1502,
"preview": "# Queue\n\nQueue is a particular kind of abstract data type or collection in which the entities in the collection are kept"
},
{
"path": "QuickSort/QuickSort.kt",
"chars": 658,
"preview": "/**\n * Created by gazollajunior on 01/04/16.\n */\n\nfun <T:Comparable<T>>quicksort(items:List<T>):List<T>{\n if (items.c"
},
{
"path": "QuickSort/README.markdown",
"chars": 781,
"preview": "# Quicksort\n\nQuicksort is an efficient sorting algorithm, serving as a systematic method for placing the elements of an "
},
{
"path": "README.markdown",
"chars": 2629,
"preview": "# Welcome to Kotlin Algorithms \n\nHere you'll find implementations of popular algorithms and data structures in [Kotlin p"
},
{
"path": "SelectionSort/README.markdown",
"chars": 899,
"preview": "# Selection sort\n\nSelection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) time com"
},
{
"path": "SelectionSort/SelectionSort.kt",
"chars": 708,
"preview": "/**\n * Created by gazollajunior on 09/04/16.\n */\n\nfun <T:Comparable<T>>selectionsort(items:MutableList<T>):MutableList<T"
},
{
"path": "ShellSort/README.markdown",
"chars": 714,
"preview": "# Shell Sort\n\nShellsort, also known as Shell sort or Shell's method, is an in-place comparison sort.\nIt can be seen as e"
},
{
"path": "ShellSort/ShellSort.kt",
"chars": 1068,
"preview": "fun MutableList<Int>.swap(index1: Int, index2: Int) {\n val tmp = this[index1]\n this[index1] = this[index2]\n thi"
},
{
"path": "Shuffle/README.markdown",
"chars": 914,
"preview": "# Shuffle\n\nRandomly rearranges the contents of an array.\n\n## The code\n\nHere is a implementation of Shuffle in kotlin:\n\n`"
},
{
"path": "Shuffle/Shuffle.kt",
"chars": 894,
"preview": "/**\n * Created by gazollajunior on 03/04/16.\n */\n\nimport java.util.Random\n\nfun <T:Comparable<T>>shuffle(items:MutableLis"
},
{
"path": "Stack/README.markdown",
"chars": 1258,
"preview": "# Stack\n\nStack is an abstract data type that serves as a collection of elements, with two principal operations: push, wh"
},
{
"path": "Stack/Stack.kt",
"chars": 1978,
"preview": "/**\n * Created by gazollajunior on 03/04/16.\n */\n\n\nclass Stack<T:Comparable<T>>(list:MutableList<T>):Iterator<T> {\n\n "
},
{
"path": "Tree/README.markdown",
"chars": 1048,
"preview": "# Tree\n\nTree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarch"
},
{
"path": "Tree/Tree.kt",
"chars": 1581,
"preview": "/**\n * Created by gazolla on 10/04/16.\n */\nclass TreeNode<T>(value:T){\n var value:T = value\n\n var parent:TreeNode<"
}
]
About this extraction
This page contains the full source code of the gazolla/Kotlin-Algorithm GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 54 files (102.1 KB), approximately 27.5k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.