From 778a34493524e927ea337b1f0f08e57f0eece2e9 Mon Sep 17 00:00:00 2001 From: Ethel Date: Sat, 6 Aug 2022 19:35:57 +0800 Subject: [PATCH 01/12] Added QuickSelect and QuickSelectTest java files --- .metadata/.lock | 0 .metadata/.log | 28 + .metadata/.mylyn/.taskListIndex/segments_1 | Bin 0 -> 71 bytes .metadata/.mylyn/.taskListIndex/write.lock | 0 .metadata/.mylyn/.tasks.xml.zip | Bin 0 -> 235 bytes .metadata/.mylyn/repositories.xml.zip | Bin 0 -> 562 bytes .metadata/.mylyn/tasks.xml.zip | Bin 0 -> 235 bytes .../.root/.indexes/history.version | 1 + .../.root/.indexes/properties.index | Bin 0 -> 57 bytes .../.root/.indexes/properties.version | 1 + .../org.eclipse.core.resources/.root/2.tree | Bin 0 -> 81 bytes .../.safetable/org.eclipse.core.resources | Bin 0 -> 530 bytes .../org.eclipse.e4.workbench/workbench.xmi | 2326 +++++++++++++++++ .../assumedExternalFilesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/externalFilesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/nonChainingJarsCache | Bin 0 -> 4 bytes .../variablesAndContainers.dat | Bin 0 -> 110 bytes .../org.eclipse.jdt.ui/OpenTypeHistory.xml | 2 + .../QualifiedTypeNameHistory.xml | 2 + .../org.eclipse.jdt.ui/dialog_settings.xml | 10 + .../0.log | 2 + .../logback.1.15.0.20191217-1149.xml | 43 + .../org.eclipse.oomph.setup/workspace.setup | 6 + .../org.eclipse.tips.ide/dialog_settings.xml | 3 + .../org.eclipse.ui.ide/dialog_settings.xml | 9 + .../.plugins/org.eclipse.ui.intro/introstate | 2 + .../dialog_settings.xml | 5 + .../org.eclipse.ui.workbench/workingsets.xml | 6 + .metadata/version.ini | 3 + .../algorithms/search/.metadata/.lock | 0 .../algorithms/search/.metadata/.log | 30 + .../.mylyn/.taskListIndex/segments_1 | Bin 0 -> 71 bytes .../.mylyn/.taskListIndex/write.lock | 0 .../.metadata/.mylyn/repositories.xml.zip | Bin 0 -> 562 bytes .../search/.metadata/.mylyn/tasks.xml.zip | Bin 0 -> 235 bytes .../.root/.indexes/history.version | 1 + .../.root/.indexes/properties.index | Bin 0 -> 57 bytes .../.root/.indexes/properties.version | 1 + .../org.eclipse.core.resources/.root/1.tree | Bin 0 -> 81 bytes .../.safetable/org.eclipse.core.resources | Bin 0 -> 449 bytes .../org.eclipse.e4.workbench/workbench.xmi | 2326 +++++++++++++++++ .../assumedExternalFilesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/externalFilesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/nonChainingJarsCache | Bin 0 -> 4 bytes .../variablesAndContainers.dat | Bin 0 -> 110 bytes .../org.eclipse.jdt.launching/.install.xml | 4 + .../libraryInfos.xml | 22 + .../org.eclipse.jdt.ui/OpenTypeHistory.xml | 2 + .../QualifiedTypeNameHistory.xml | 2 + .../org.eclipse.jdt.ui/dialog_settings.xml | 12 + .../0.log | 1 + .../logback.1.15.0.20191217-1149.xml | 43 + .../org.eclipse.oomph.setup/workspace.setup | 6 + .../org.eclipse.tips.ide/dialog_settings.xml | 3 + .../org.eclipse.ui.ide/dialog_settings.xml | 12 + .../.plugins/org.eclipse.ui.intro/introstate | 2 + .../dialog_settings.xml | 3 + .../org.eclipse.ui.workbench/workingsets.xml | 6 + .../algorithms/search/.metadata/version.ini | 3 + .../algorithms/search/QuickSelect.java | 138 + .../algorithms/search/QuickSelectTest.java | 242 ++ 61 files changed, 5308 insertions(+) create mode 100644 .metadata/.lock create mode 100644 .metadata/.log create mode 100644 .metadata/.mylyn/.taskListIndex/segments_1 create mode 100644 .metadata/.mylyn/.taskListIndex/write.lock create mode 100644 .metadata/.mylyn/.tasks.xml.zip create mode 100644 .metadata/.mylyn/repositories.xml.zip create mode 100644 .metadata/.mylyn/tasks.xml.zip create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/2.tree create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources create mode 100644 .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/externalFilesCache create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat create mode 100644 .metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml create mode 100644 .metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml create mode 100644 .metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log create mode 100644 .metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml create mode 100644 .metadata/.plugins/org.eclipse.oomph.setup/workspace.setup create mode 100644 .metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.intro/introstate create mode 100644 .metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml create mode 100644 .metadata/version.ini create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.lock create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.log create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/segments_1 create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/write.lock create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/repositories.xml.zip create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/tasks.xml.zip create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml create mode 100644 src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini create mode 100644 src/main/java/com/williamfiset/algorithms/search/QuickSelect.java create mode 100644 src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 000000000..e69de29bb diff --git a/.metadata/.log b/.metadata/.log new file mode 100644 index 000000000..2c23423b1 --- /dev/null +++ b/.metadata/.log @@ -0,0 +1,28 @@ +!SESSION 2022-08-06 18:55:22.612 ----------------------------------------------- +eclipse.buildId=4.15.0.I20200305-0155 +java.version=1.8.0_281 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_MY +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.egit.ui 2 0 2022-08-06 18:56:13.311 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Admin_pc'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. +!SESSION 2022-08-06 18:59:55.424 ----------------------------------------------- +eclipse.buildId=4.15.0.I20200305-0155 +java.version=1.8.0_281 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_MY +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.egit.ui 2 0 2022-08-06 19:00:33.030 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Admin_pc'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000000000000000000000000000000000000..9511bc23f47a36fe58ce0915d576666426169d71 GIT binary patch literal 71 zcmcD&o+HjtoSL4SnpaZHz`(%fd_n)$u9-J1J8v9ax#YK}1EV1uBTyU+m|zTs0~(WG Lz&I~InWg~%H=+}{ literal 0 HcmV?d00001 diff --git a/.metadata/.mylyn/.taskListIndex/write.lock b/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 000000000..e69de29bb diff --git a/.metadata/.mylyn/.tasks.xml.zip b/.metadata/.mylyn/.tasks.xml.zip new file mode 100644 index 0000000000000000000000000000000000000000..f7a59cb1fe8c275878d2459f759a82a9488a8055 GIT binary patch literal 235 zcmWIWW@Zs#;Nak35Sq>w%76rTfb5dQ;_RHv;u5`z+?>rD*Pl2WsNt=vb?(gh&7nqD zj01u^&U&BoKY7M`dngxg;pMFXo3?M}^wc@`?WB%gAV>2`6Q)%y9oFj8mMnWN9;#KL z@@(moB}}DHRh?UmRtE)75&0ujY{>HUZO)g(v|Ee}0p9E!dhup9i9m~6fH=ULkx7IB d;W%VDkmFDRvQq=RS=m6cj6i4wq-TSb0s!!zK->TT literal 0 HcmV?d00001 diff --git a/.metadata/.mylyn/repositories.xml.zip b/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000000000000000000000000000000000000..c03308804ac1429ba7a2c86bf551a082be428bf5 GIT binary patch literal 562 zcmWIWW@Zs#;Nak35Sq>w%76p}fb62wg8bsllKi5~)MCAg+?==5PWv4;5OA$m{Uq1k z)FO}-wXs1|NL2UD@{=Z8UmckyzwqVt$ICctRVFMeY2CH?&CJ=7=Rb!2I-GiFFVEC8 zC0>vIIAQ+F0WLbd%%AKk_w7{!oK^|37|BdsNA#oqAjC8qMB_joNkPVQy(Ufkf5 zyC-Q5^T#!h7-vc=e{FuhJJ;9niBHxNr=v&NZeA<&e*dbpqD^&&kS5!cK;sX`-|;L7 z@UT(;s5||MjsMERs|Cw=L#0^7k&k=Sdsm1SNVpt zf9ex`nSHrrmc7XPky*X+`06CC;6A@BwwUr2#}bq*CDvqd+_fq@%uB%4`lH)|MTGNJoO}w?M~9kgG_T1I@vzHc2t#hjX3HPd`Hp5)#+$R@S$ZZmEMFL zIH$7P`h&5j*`tbU(HX+`oVQ-km&oJN-T5ZOh4bsos8s>^ld@a){s`K7J?O%{!x6`S z{XX`q`C^eElYZ>BnEcqkkCv)ezC8U*uD@vOSM`$S=C6AHzQ+GuedKZZ^DNh8d3;;h z-^>52rD*Pl2WsNt=vb?(gh&7nqD zj01u^&U&BoKY7M`dngxg;pMFXo3?M}^wc@`?WB%gAV>2`6Q)%y9oFj8mMnWN9;#KL z@@(moB}}DHRh?UmRtE)75&0ujY{>HUZO)g(v|Ee}0p9E!dhup9i9m~6fH=ULkx7IB d;W%VDkmFDRvQq=RS=m6cj6i4wq-TSb0ssiLK?VQ- literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 000000000..25cb955ba --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000000000000000000000000000000000000..ed9b514964f6d401c82fa8fdb36ac30ac51534a7 GIT binary patch literal 57 zcmZQ%U|?WmVAN+|WMUA>FG|--P0qyJm CSO?Dl literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000000000000000000000000000000000000..8d5f2fbd6dce9a3b022b268fd478d86ab87ee20b GIT binary patch literal 530 zcmZ?R*xjhShe1S2b=vdAllRFf=Oz}Hq!uZZBqrsg@^UE$CzdEUmZmEhm?;=qS{WEx z85$`ByN4(k85kMya;2o^lq9-V6l4}9mSpDV#pf5L>!l{=WEK>s>Sd*r=q2YDrP>;r znOd4#7@L_JS(q8{awX@aCKkDXG@>X^NlhwEhiFJk%qa%ijYA>aT>Q#%D|0II^hy$o qvy1ggGi{-Y_4P`MQd4b#PCpRw`!m?%fuDP-cb6Y?7!3$WKmY))n7O?G literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 000000000..f5123dc6b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2326 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + active + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + + + + + + View + categoryTag:Mylyn + + + + org.eclipse.e4.secondaryNavigationStack + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Ant + + + + + + org.eclipse.e4.secondaryDataStack + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:Java + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Git + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Team + + + + + View + categoryTag:Team + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000000000000000000000000000000000000..0edae4b20855dcd5c83bdac184b9ed16afb1b634 GIT binary patch literal 110 zcmZQzU|?c^05&ki?iJ)3@8jvj2;?y`aD#ZkLC!(`{vjX{CI&9AP(RO*cn^PHSC9ZR e16Tu435dtSzz2~A^5IHY8Q6V|;)7fR{22i=Q4xRu literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 000000000..a4ee3cbc9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 000000000..9e390f501 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 000000000..124bc0823 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 000000000..ec33b9d43 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1,2 @@ +2022-08-06 18:56:12,689 [Worker-3: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2022-08-06 19:00:32,533 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml new file mode 100644 index 000000000..e33758c3a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 000000000..1f73e14c1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 000000000..5ca0b7769 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 000000000..07a485437 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,9 @@ + +
+
+ + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.intro/introstate b/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 000000000..02f134f0f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 000000000..5b583c4be --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 000000000..38ee6d832 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 000000000..e44d6b87e --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1,3 @@ +#Sat Aug 06 19:00:23 SGT 2022 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.15.0.v20200305-0155 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.lock b/src/main/java/com/williamfiset/algorithms/search/.metadata/.lock new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.log b/src/main/java/com/williamfiset/algorithms/search/.metadata/.log new file mode 100644 index 000000000..871104f44 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.log @@ -0,0 +1,30 @@ +!SESSION 2022-08-06 18:56:43.727 ----------------------------------------------- +eclipse.buildId=4.15.0.I20200305-0155 +java.version=1.8.0_281 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_MY +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.egit.ui 2 0 2022-08-06 18:57:15.421 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Admin_pc'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.ui.ide 4 0 2022-08-06 18:59:32.425 +!MESSAGE Could not import project located at C:\Users\Admin_pc\Algorithms\src\main\java\com\williamfiset\algorithms\search +!STACK 0 +org.eclipse.ui.internal.wizards.datatransfer.CouldNotImportProjectException: Could not import project located at C:\Users\Admin_pc\Algorithms\src\main\java\com\williamfiset\algorithms\search + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.toExistingOrNewProject(SmartImportJob.java:565) + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.run(SmartImportJob.java:252) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) +Caused by: org.eclipse.core.internal.resources.ResourceException: Invalid project description. + at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) + at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) + at org.eclipse.core.internal.resources.Project.create(Project.java:266) + at org.eclipse.core.internal.resources.Project.create(Project.java:252) + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.createOrImportProject(SmartImportJob.java:604) + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.toExistingOrNewProject(SmartImportJob.java:552) + ... 2 more diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/segments_1 b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000000000000000000000000000000000000..24f6e7697c324ace8bfc29a6370c99c9e96e476f GIT binary patch literal 71 zcmcD&o+HjtoSL4SnpaZHz`($E_)c+$OwFXUbva_(Dh!)C7!BDNf#P7m1YvIIAQ+F0WLbd%%AKk_w7{!oK^|37|BdsNA#oqAjC8qMB_joNkPVQy(Ufkf5 zyC-Q5^T#!h7-vc=e{FuhJJ;9niBHxNr=v&NZeA<&e*dbpqD^&&kS5!cK;sX`-|;L7 z@UT(;s5||MjsMERs|Cw=L#0^7k&k=Sdsm1SNVpt zf9ex`nSHrrmc7XPky*X+`06CC;6A@BwwUr2#}bq*CDvqd+_fq@%uB%4`lH)|MTGNJoO}w?M~9kgG_T1I@vzHc2t#hjX3HPd`Hp5)#+$R@S$ZZmEMFL zIH$7P`h&5j*`tbU(HX+`oVQ-km&oJN-T5ZOh4bsos8s>^ld@a){s`K7J?O%{!x6`S z{XX`q`C^eElYZ>BnEcqkkCv)ezC8U*uD@vOSM`$S=C6AHzQ+GuedKZZ^DNh8d3;;h z-^>52rD*Pl2WsNt=vb?(gh&7nqD zj01u^&U&BoKY7M`dngxg;pMFXo3?M}^wc@`?WB%gAV>2`6Q)%y9oFj8mMnWN9;#KL z@@(moB}}DHRh?UmRtE)75&0ujY{>HUZO)g(v|Ee}0p9E!dhup9i9m~6fH=ULkx7IB d;W%VDkmFDRvQq=RS=m6cj6i4wq-TSb0suFpL0A9) literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 000000000..25cb955ba --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000000000000000000000000000000000000..ed9b514964f6d401c82fa8fdb36ac30ac51534a7 GIT binary patch literal 57 zcmZQ%U|?WmVAN+|WMUA>FG|--P0qyJm CSO?Dl literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000000000000000000000000000000000000..3e3447e047da4c74b81ae5cd7193830ee7167e33 GIT binary patch literal 449 zcmZ?R*xjhShe1S2b=vdAllRFf=Oz}Hq!uZZBqrsg@^UE$CzdEUmZmEhm?;=qSeaT{ znOG!l{=WEK>s>Sd*r=q2YDrP>;r znOd4#7@JyHSehH~a_Q@p6r}=1dASZm{QeBKJMeQ)_3rXx4s>@*a!zVukqgKZC{9mF zO)5=?I6f^grx+LxI23~Xn3GtVmzzE6c6Ssm#+WNi5DT)+^0~nTb2l E0J~V69smFU literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 000000000..0da786e1d --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2326 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + active + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + + + + + + View + categoryTag:Mylyn + + + + org.eclipse.e4.secondaryNavigationStack + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Ant + + + + + + org.eclipse.e4.secondaryDataStack + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:Java + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Git + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Team + + + + + View + categoryTag:Team + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000000000000000000000000000000000000..0edae4b20855dcd5c83bdac184b9ed16afb1b634 GIT binary patch literal 110 zcmZQzU|?c^05&ki?iJ)3@8jvj2;?y`aD#ZkLC!(`{vjX{CI&9AP(RO*cn^PHSC9ZR e16Tu435dtSzz2~A^5IHY8Q6V|;)7fR{22i=Q4xRu literal 0 HcmV?d00001 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 000000000..754875573 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml new file mode 100644 index 000000000..4780ec2b0 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 000000000..a4ee3cbc9 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 000000000..9e390f501 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 000000000..40c861b1e --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+ + +
+ + + + + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 000000000..e030750b9 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1 @@ +2022-08-06 18:57:14,937 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml new file mode 100644 index 000000000..e33758c3a --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 000000000..1f73e14c1 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 000000000..5ca0b7769 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 000000000..00618f758 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+
+ + + + + + + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 000000000..02f134f0f --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 000000000..5ca0b7769 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 000000000..528058008 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini b/src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini new file mode 100644 index 000000000..0c1fcc802 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini @@ -0,0 +1,3 @@ +#Sat Aug 06 18:57:00 SGT 2022 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.15.0.v20200305-0155 diff --git a/src/main/java/com/williamfiset/algorithms/search/QuickSelect.java b/src/main/java/com/williamfiset/algorithms/search/QuickSelect.java new file mode 100644 index 000000000..548fe1a9e --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/QuickSelect.java @@ -0,0 +1,138 @@ +import java.util.*; + +/** + * An implementation of the Quickselect algorithm as described + * here. + */ +public final class QuickSelect { + + /** + * Selects the {@code n}-th largest element of {@code list}, i.e. the element that would + * be at index n if the list was sorted. + *

+ * Calling this function might change the order of elements in {@code list}. + * + * @param list the list of elements + * @param n the index + * @param the type of list elements + * @return the n-th largest element in the list + * @throws IndexOutOfBoundsException if n is less than 0 or greater or equal to + * the number of elements in the list + * @throws IllegalArgumentException if the list is empty + * @throws NullPointerException if {@code list} is null + */ + public static > T select(List list, int n) { + Objects.requireNonNull(list, "The list of elements must not be null."); + + if (list.size() == 0) { + String msg = "The list of elements must not be empty."; + throw new IllegalArgumentException(msg); + } + + if (n < 0) { + String msg = "The index must not be negative."; + throw new IndexOutOfBoundsException(msg); + } + + if (n >= list.size()) { + String msg = "The index must be less than the number of elements."; + throw new IndexOutOfBoundsException(msg); + } + + int index = selectIndex(list, n); + return list.get(index); + } + + private static > int selectIndex(List list, int n) { + return selectIndex(list, 0, list.size() - 1, n); + } + + private static > int selectIndex( + List list, + int left, + int right, + int n + ) { + while (true) { + if (left == right) + return left; + int pivotIndex = pivot(list, left, right); + pivotIndex = partition(list, left, right, pivotIndex, n); + if (n == pivotIndex) { + return n; + } else if (n < pivotIndex) { + right = pivotIndex - 1; + } else { + left = pivotIndex + 1; + } + } + } + + private static > int partition( + List list, + int left, + int right, + int pivotIndex, + int n + ) { + T pivotValue = list.get(pivotIndex); + Collections.swap(list, pivotIndex, right); + int storeIndex = left; + + for (int i = left; i < right; i++) { + if (list.get(i).compareTo(pivotValue) < 0) { + Collections.swap(list, storeIndex, i); + storeIndex++; + } + } + + int storeIndexEq = storeIndex; + + for (int i = storeIndex; i < right; i++) { + if (list.get(i).compareTo(pivotValue) == 0) { + Collections.swap(list, storeIndexEq, i); + storeIndexEq++; + } + } + + Collections.swap(list, right, storeIndexEq); + + return (n < storeIndex) + ? storeIndex + : Math.min(n, storeIndexEq); + } + + private static > int pivot( + List list, + int left, + int right + ) { + if (right - left < 5) { + return partition5(list, left, right); + } + + for (int i = left; i < right; i += 5) { + int subRight = i + 4; + if (subRight > right) { + subRight = right; + } + int median5 = partition5(list, i, subRight); + int rightIndex = left + (i - left) / 5; + Collections.swap(list, median5, rightIndex); + } + + int mid = (right - left) / 10 + left + 1; + int rightIndex = left + (right - left) / 5; + return selectIndex(list, left, rightIndex, mid); + } + + private static > int partition5( + List list, + int left, + int right + ) { + List ts = list.subList(left, right); + ts.sort(Comparator.naturalOrder()); + return (left + right) >>> 1; + } +} \ No newline at end of file diff --git a/src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java b/src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java new file mode 100644 index 000000000..b25918eeb --- /dev/null +++ b/src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java @@ -0,0 +1,242 @@ +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +import org.junit.jupiter.api.Test; + +import java.util.*; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.*; + +class QuickSelectTest { + @Test + void quickSelectMinimumOfOneElement() { + List elements = Collections.singletonList(42); + int minimum = QuickSelect.select(elements, 0); + assertEquals(42, minimum); + } + + @Test + void quickSelectMinimumOfTwoElements() { + List elements1 = Arrays.asList(42, 90); + List elements2 = Arrays.asList(90, 42); + + int minimum1 = QuickSelect.select(elements1, 0); + int minimum2 = QuickSelect.select(elements2, 0); + + assertEquals(42, minimum1); + assertEquals(42, minimum2); + } + + @Test + void quickSelectMinimumOfThreeElements() { + List elements1 = Arrays.asList(1, 2, 3); + List elements2 = Arrays.asList(2, 1, 3); + List elements3 = Arrays.asList(2, 3, 1); + + int minimum1 = QuickSelect.select(elements1, 0); + int minimum2 = QuickSelect.select(elements2, 0); + int minimum3 = QuickSelect.select(elements3, 0); + + assertEquals(1, minimum1); + assertEquals(1, minimum2); + assertEquals(1, minimum3); + } + + @Test + void quickSelectMinimumOfManyElements() { + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, 0); + int expected = elements.stream().min(Comparator.naturalOrder()).get(); + assertEquals(expected, actual); + } + + @Test + void quickSelectMaximumOfOneElement() { + List elements = Collections.singletonList(42); + int maximum = QuickSelect.select(elements, 0); + assertEquals(42, maximum); + } + + @Test + void quickSelectMaximumOfTwoElements() { + List elements1 = Arrays.asList(42, 90); + List elements2 = Arrays.asList(90, 42); + + int maximum1 = QuickSelect.select(elements1, 1); + int maximum2 = QuickSelect.select(elements2, 1); + + assertEquals(90, maximum1); + assertEquals(90, maximum2); + } + + @Test + void quickSelectMaximumOfThreeElements() { + List elements1 = Arrays.asList(1, 2, 3); + List elements2 = Arrays.asList(2, 1, 3); + List elements3 = Arrays.asList(2, 3, 1); + + int maximum1 = QuickSelect.select(elements1, 2); + int maximum2 = QuickSelect.select(elements2, 2); + int maximum3 = QuickSelect.select(elements3, 2); + + assertEquals(3, maximum1); + assertEquals(3, maximum2); + assertEquals(3, maximum3); + } + + @Test + void quickSelectMaximumOfManyElements() { + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, NUM_RND_ELEMENTS - 1); + int expected = elements.stream().max(Comparator.naturalOrder()).get(); + assertEquals(expected, actual); + } + + @Test + void quickSelectMedianOfOneElement() { + List elements = Collections.singletonList(42); + int median = QuickSelect.select(elements, 0); + assertEquals(42, median); + } + + @Test + void quickSelectMedianOfThreeElements() { + List elements1 = Arrays.asList(1, 2, 3); + List elements2 = Arrays.asList(2, 1, 3); + List elements3 = Arrays.asList(2, 3, 1); + + int median1 = QuickSelect.select(elements1, 1); + int median2 = QuickSelect.select(elements2, 1); + int median3 = QuickSelect.select(elements3, 1); + + assertEquals(2, median1); + assertEquals(2, median2); + assertEquals(2, median3); + } + + @Test + void quickSelectMedianOfManyElements() { + int medianIndex = NUM_RND_ELEMENTS / 2; + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, medianIndex); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(medianIndex), actual); + } + + @Test + void quickSelect30thPercentileOf10Elements() { + List elements = generateRandomIntegers(10); + int actual = QuickSelect.select(elements, 2); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(2), actual); + } + + @Test + void quickSelect30thPercentileOfManyElements() { + int percentile30th = NUM_RND_ELEMENTS / 10 * 3; + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, percentile30th); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(percentile30th), actual); + } + + @Test + void quickSelect70thPercentileOf10Elements() { + List elements = generateRandomIntegers(10); + int actual = QuickSelect.select(elements, 6); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(6), actual); + } + + @Test + void quickSelect70thPercentileOfManyElements() { + int percentile70th = NUM_RND_ELEMENTS / 10 * 7; + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, percentile70th); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(percentile70th), actual); + } + + @Test + void quickSelectMedianOfThreeCharacters() { + List elements = Arrays.asList('X', 'Z', 'Y'); + char actual = QuickSelect.select(elements, 1); + assertEquals(actual, 'Y'); + } + + @Test + void quickSelectMedianOfManyCharacters() { + List elements = generateRandomCharacters(NUM_RND_ELEMENTS); + char actual = QuickSelect.select(elements, NUM_RND_ELEMENTS / 30); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(NUM_RND_ELEMENTS / 30), actual); + } + + @Test + void quickSelectNullList() { + NullPointerException exception = assertThrows( + NullPointerException.class, + () -> QuickSelect.select(null, 0) + ); + String expectedMsg = "The list of elements must not be null."; + assertEquals(expectedMsg, exception.getMessage()); + } + + @Test + void quickSelectEmptyList() { + List objects = Collections.emptyList(); + IllegalArgumentException exception = assertThrows( + IllegalArgumentException.class, + () -> QuickSelect.select(objects, 0) + ); + String expectedMsg = "The list of elements must not be empty."; + assertEquals(expectedMsg, exception.getMessage()); + } + + @Test + void quickSelectIndexOutOfLeftBound() { + IndexOutOfBoundsException exception = assertThrows( + IndexOutOfBoundsException.class, + () -> QuickSelect.select(Collections.singletonList(1), -1) + ); + String expectedMsg = "The index must not be negative."; + assertEquals(expectedMsg, exception.getMessage()); + } + + @Test + void quickSelectIndexOutOfRightBound() { + IndexOutOfBoundsException exception = assertThrows( + IndexOutOfBoundsException.class, + () -> QuickSelect.select(Collections.singletonList(1), 1) + ); + String expectedMsg = "The index must be less than the number of elements."; + assertEquals(expectedMsg, exception.getMessage()); + } + + private static final int NUM_RND_ELEMENTS = 99; + private static final Random RANDOM = new Random(42); + private static final int ASCII_A = 0x41; + private static final int ASCII_Z = 0x5A; + + private static List generateRandomIntegers(int n) { + return RANDOM.ints(n).boxed().collect(Collectors.toList()); + } + + private static List generateRandomCharacters(int n) { + return RANDOM.ints(n, ASCII_A, ASCII_Z) + .mapToObj(i -> (char) i) + .collect(Collectors.toList()); + } + + private static > List getSortedCopyOfList(List list) { + return list.stream().sorted().collect(Collectors.toList()); + } +} \ No newline at end of file From 5e3144c382d9bad77d0e63812fb03bf827d1abda Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sat, 3 Sep 2022 17:37:47 +0800 Subject: [PATCH 02/12] Update gradle.yml --- .github/workflows/gradle.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8a80dd989..b7027ded1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -24,3 +24,15 @@ jobs: run: chmod +x gradlew - name: Run all tests run: ./gradlew test + - name: Use Node.js 10.x + uses: actions/setup-node@v1 + with: + node-version: 10.x + - name: npm install, make test-coverage + run: | + npm install + make test-coverage + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} From 9061d836c9f9a259aea2b7f3f50a683ac8d0096d Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sat, 3 Sep 2022 17:41:36 +0800 Subject: [PATCH 03/12] Create gradle2.yml --- .github/workflows/gradle2.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/gradle2.yml diff --git a/.github/workflows/gradle2.yml b/.github/workflows/gradle2.yml new file mode 100644 index 000000000..170ef7bc7 --- /dev/null +++ b/.github/workflows/gradle2.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build From 30ed60e2e7eab9f55e9dec2fca3a5600a663e31e Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sat, 3 Sep 2022 17:44:11 +0800 Subject: [PATCH 04/12] Delete code-formatting.yml --- .github/workflows/code-formatting.yml | 28 --------------------------- 1 file changed, 28 deletions(-) delete mode 100644 .github/workflows/code-formatting.yml diff --git a/.github/workflows/code-formatting.yml b/.github/workflows/code-formatting.yml deleted file mode 100644 index c74863c7c..000000000 --- a/.github/workflows/code-formatting.yml +++ /dev/null @@ -1,28 +0,0 @@ -# This workflow checks that the code in the repo is formatted according to the -# Google Java Style Guide - -name: Code Formatting Check - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Verify all Java files are formatted correctly according to the Google Java Style Guide - run: | - ./gradlew verifyGoogleJavaFormat - echo "Run the command './gradlew goJF' to fix Java formatting if this workflow fails" From 83f2a2574aaae5e9dcd7c841fb6e2e963f138aea Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 10:17:08 +0800 Subject: [PATCH 05/12] Update gradle.yml --- .github/workflows/gradle.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b7027ded1..2c929682b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,6 +1,3 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - name: Java CI with Gradle on: @@ -24,15 +21,11 @@ jobs: run: chmod +x gradlew - name: Run all tests run: ./gradlew test - - name: Use Node.js 10.x - uses: actions/setup-node@v1 - with: - node-version: 10.x - - name: npm install, make test-coverage - run: | - npm install - make test-coverage - - name: Coveralls - uses: coverallsapp/github-action@master + + #check java style + - name: Java CheckStyle + uses: dbelyaev/action-checkstyle@v0.5.1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: warning From 51b54d313eff40328ab13b2e918407a27701a26e Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 10:18:24 +0800 Subject: [PATCH 06/12] Create sonarcloud.yml --- .github/workflows/sonarcloud.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 000000000..fb0493403 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,40 @@ +name: SonarCloud analysis + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +permissions: + pull-requests: read # allows SonarCloud to decorate PRs with analysis results + +jobs: + Analysis: + runs-on: ubuntu-latest + + steps: + - name: Analyze with SonarCloud + + # You can pin the exact commit or the version. + # uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 + uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) + with: + # Additional arguments for the sonarcloud scanner + args: + # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) + # mandatory + -Dsonar.projectKey=EthelAw_Algorithms + -Dsonar.organization=ethelaw + # Comma-separated paths to directories containing main source files. + #-Dsonar.sources= # optional, default is project base directory + # When you need the analysis to take place in a directory other than the one from which it was launched + #-Dsonar.projectBaseDir= # optional, default is . + # Comma-separated paths to directories containing test source files. + #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ + # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. + #-Dsonar.verbose= # optional, default is false From cd3941a68ccde2080430baed86b9f0ca91c2af9b Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:04:20 +0800 Subject: [PATCH 07/12] Create KMPSearch.java --- .../algorithms/search/KMPSearch.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/main/java/com/williamfiset/algorithms/search/KMPSearch.java diff --git a/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java new file mode 100644 index 000000000..0f3239cea --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java @@ -0,0 +1,83 @@ +package com.thealgorithms.searches; + +class KMPSearch { + int KMPSearch(String pat, String txt) + { + int M = pat.length(); + int N = txt.length(); + + // create lps[] that will hold the longest + // prefix suffix values for pattern + int lps[] = new int[M]; + int j = 0; // index for pat[] + + // Preprocess the pattern (calculate lps[] + // array) + computeLPSArray(pat, M, lps); + + int i = 0; // index for txt[] + while ((N - i) >= (M - j)) { + if (pat.charAt(j) == txt.charAt(i)) { + j++; + i++; + } + if (j == M) { + System.out.println("Found pattern " + + "at index " + (i - j)); + int index = (i - j); + j = lps[j - 1]; + return index; + + } + + // mismatch after j matches + else if (i < N && pat.charAt(j) != txt.charAt(i)) { + // Do not match lps[0..lps[j-1]] characters, + // they will match anyway + if (j != 0) + j = lps[j - 1]; + else + i = i + 1; + } + } + System.out.println("No pattern found"); + return -1; + } + + void computeLPSArray(String pat, int M, int lps[]) + { + // length of the previous longest prefix suffix + int len = 0; + int i = 1; + lps[0] = 0; // lps[0] is always 0 + + // the loop calculates lps[i] for i = 1 to M-1 + while (i < M) { + if (pat.charAt(i) == pat.charAt(len)) { + len++; + lps[i] = len; + i++; + } + else // (pat[i] != pat[len]) + { + // This is tricky. Consider the example. + // AAACAAAA and i = 7. The idea is similar + // to search step. + if (len != 0) { + len = lps[len - 1]; + + // Also, note that we do not increment + // i here + } + else // if (len == 0) + { + lps[i] = len; + i++; + } + } + } + } + + +} +// This code has been contributed by Amit Khandelwal. From d1f9a7be57eb8b9e86ca9026c7c4e686aa217ce0 Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:05:11 +0800 Subject: [PATCH 08/12] Create KMPSearchTest.java --- .../algorithms/search/KMPSearchTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java diff --git a/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java new file mode 100644 index 000000000..812f0725b --- /dev/null +++ b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java @@ -0,0 +1,65 @@ +package com.thealgorithms.searches; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class KMPSearchTest { + + @Test + // valid test case + public void KMPSearchTestLast() { + String txt = "ABABDABACDABABCABAB"; + String pat = "ABABCABAB"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 10); + + } + + @Test + // valid test case + public void KMPSearchTestFront() { + String txt = "AAAAABAAABA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 0); + + } + + @Test + // valid test case + public void KMPSearchTestMiddle() { + String txt = "AAACAAAAAC"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 4); + + } + @Test + // valid test case + public void KMPSearchTestNotFound() { + String txt = "AAABAAAA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 4); + + } + @Test + // not valid test case + public void KMPSearchTest4() { + String txt = "AABAAA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, -1); + + } +} From 4b7781d8de69dfaa8c309020df002d16277e3aad Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:14:31 +0800 Subject: [PATCH 09/12] Delete KMPSearch.java --- .../algorithms/search/KMPSearch.java | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/main/java/com/williamfiset/algorithms/search/KMPSearch.java diff --git a/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java deleted file mode 100644 index 0f3239cea..000000000 --- a/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.thealgorithms.searches; - -class KMPSearch { - int KMPSearch(String pat, String txt) - { - int M = pat.length(); - int N = txt.length(); - - // create lps[] that will hold the longest - // prefix suffix values for pattern - int lps[] = new int[M]; - int j = 0; // index for pat[] - - // Preprocess the pattern (calculate lps[] - // array) - computeLPSArray(pat, M, lps); - - int i = 0; // index for txt[] - while ((N - i) >= (M - j)) { - if (pat.charAt(j) == txt.charAt(i)) { - j++; - i++; - } - if (j == M) { - System.out.println("Found pattern " - + "at index " + (i - j)); - int index = (i - j); - j = lps[j - 1]; - return index; - - } - - // mismatch after j matches - else if (i < N && pat.charAt(j) != txt.charAt(i)) { - // Do not match lps[0..lps[j-1]] characters, - // they will match anyway - if (j != 0) - j = lps[j - 1]; - else - i = i + 1; - } - } - System.out.println("No pattern found"); - return -1; - } - - void computeLPSArray(String pat, int M, int lps[]) - { - // length of the previous longest prefix suffix - int len = 0; - int i = 1; - lps[0] = 0; // lps[0] is always 0 - - // the loop calculates lps[i] for i = 1 to M-1 - while (i < M) { - if (pat.charAt(i) == pat.charAt(len)) { - len++; - lps[i] = len; - i++; - } - else // (pat[i] != pat[len]) - { - // This is tricky. Consider the example. - // AAACAAAA and i = 7. The idea is similar - // to search step. - if (len != 0) { - len = lps[len - 1]; - - // Also, note that we do not increment - // i here - } - else // if (len == 0) - { - lps[i] = len; - i++; - } - } - } - } - - -} -// This code has been contributed by Amit Khandelwal. From 1dfd7f844598ae86820c99fe66dfc0d493dcdac7 Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:14:50 +0800 Subject: [PATCH 10/12] Delete KMPSearchTest.java --- .../algorithms/search/KMPSearchTest.java | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java diff --git a/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java deleted file mode 100644 index 812f0725b..000000000 --- a/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.thealgorithms.searches; - -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - -class KMPSearchTest { - - @Test - // valid test case - public void KMPSearchTestLast() { - String txt = "ABABDABACDABABCABAB"; - String pat = "ABABCABAB"; - KMPSearch kmpSearch = new KMPSearch(); - int value = kmpSearch.KMPSearch(pat, txt); - System.out.println(value); - assertEquals(value, 10); - - } - - @Test - // valid test case - public void KMPSearchTestFront() { - String txt = "AAAAABAAABA"; - String pat = "AAAA"; - KMPSearch kmpSearch = new KMPSearch(); - int value = kmpSearch.KMPSearch(pat, txt); - System.out.println(value); - assertEquals(value, 0); - - } - - @Test - // valid test case - public void KMPSearchTestMiddle() { - String txt = "AAACAAAAAC"; - String pat = "AAAA"; - KMPSearch kmpSearch = new KMPSearch(); - int value = kmpSearch.KMPSearch(pat, txt); - System.out.println(value); - assertEquals(value, 4); - - } - @Test - // valid test case - public void KMPSearchTestNotFound() { - String txt = "AAABAAAA"; - String pat = "AAAA"; - KMPSearch kmpSearch = new KMPSearch(); - int value = kmpSearch.KMPSearch(pat, txt); - System.out.println(value); - assertEquals(value, 4); - - } - @Test - // not valid test case - public void KMPSearchTest4() { - String txt = "AABAAA"; - String pat = "AAAA"; - KMPSearch kmpSearch = new KMPSearch(); - int value = kmpSearch.KMPSearch(pat, txt); - System.out.println(value); - assertEquals(value, -1); - - } -} From a6bc83e2cb392b0e4c80f0bb5a6bc5ae76727b51 Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:15:45 +0800 Subject: [PATCH 11/12] Create KMPSearch.java --- .../algorithms/search/KMPSearch.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/main/java/com/williamfiset/algorithms/search/KMPSearch.java diff --git a/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java new file mode 100644 index 000000000..0f3239cea --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java @@ -0,0 +1,83 @@ +package com.thealgorithms.searches; + +class KMPSearch { + int KMPSearch(String pat, String txt) + { + int M = pat.length(); + int N = txt.length(); + + // create lps[] that will hold the longest + // prefix suffix values for pattern + int lps[] = new int[M]; + int j = 0; // index for pat[] + + // Preprocess the pattern (calculate lps[] + // array) + computeLPSArray(pat, M, lps); + + int i = 0; // index for txt[] + while ((N - i) >= (M - j)) { + if (pat.charAt(j) == txt.charAt(i)) { + j++; + i++; + } + if (j == M) { + System.out.println("Found pattern " + + "at index " + (i - j)); + int index = (i - j); + j = lps[j - 1]; + return index; + + } + + // mismatch after j matches + else if (i < N && pat.charAt(j) != txt.charAt(i)) { + // Do not match lps[0..lps[j-1]] characters, + // they will match anyway + if (j != 0) + j = lps[j - 1]; + else + i = i + 1; + } + } + System.out.println("No pattern found"); + return -1; + } + + void computeLPSArray(String pat, int M, int lps[]) + { + // length of the previous longest prefix suffix + int len = 0; + int i = 1; + lps[0] = 0; // lps[0] is always 0 + + // the loop calculates lps[i] for i = 1 to M-1 + while (i < M) { + if (pat.charAt(i) == pat.charAt(len)) { + len++; + lps[i] = len; + i++; + } + else // (pat[i] != pat[len]) + { + // This is tricky. Consider the example. + // AAACAAAA and i = 7. The idea is similar + // to search step. + if (len != 0) { + len = lps[len - 1]; + + // Also, note that we do not increment + // i here + } + else // if (len == 0) + { + lps[i] = len; + i++; + } + } + } + } + + +} +// This code has been contributed by Amit Khandelwal. From 6cffd85002f46fcac9ae9a0e9bd0c8abaa8a637f Mon Sep 17 00:00:00 2001 From: EthelAw <99605409+EthelAw@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:17:47 +0800 Subject: [PATCH 12/12] Create KMPSearchTest.java --- .../algorithms/search/KMPSearchTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java diff --git a/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java new file mode 100644 index 000000000..812f0725b --- /dev/null +++ b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java @@ -0,0 +1,65 @@ +package com.thealgorithms.searches; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class KMPSearchTest { + + @Test + // valid test case + public void KMPSearchTestLast() { + String txt = "ABABDABACDABABCABAB"; + String pat = "ABABCABAB"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 10); + + } + + @Test + // valid test case + public void KMPSearchTestFront() { + String txt = "AAAAABAAABA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 0); + + } + + @Test + // valid test case + public void KMPSearchTestMiddle() { + String txt = "AAACAAAAAC"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 4); + + } + @Test + // valid test case + public void KMPSearchTestNotFound() { + String txt = "AAABAAAA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 4); + + } + @Test + // not valid test case + public void KMPSearchTest4() { + String txt = "AABAAA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, -1); + + } +}