diff --git a/bubble_sort_bash/bubble_sort_bash.sh b/bubble_sort_bash/bubble_sort_bash.sh new file mode 100644 index 0000000..cfc5b07 --- /dev/null +++ b/bubble_sort_bash/bubble_sort_bash.sh @@ -0,0 +1,24 @@ +#!/bin/bash +arr=( "$@" ) + +echo "Array in original order" +echo ${arr[*]} + +for ((i = 0; i<5; i++)) +do + + for((j = 0; j<5-i-1; j++)) + do + + if [ ${arr[j]} -gt ${arr[$((j+1))]} ] + then + # swap + temp=${arr[j]} + arr[$j]=${arr[$((j+1))]} + arr[$((j+1))]=$temp + fi + done +done + +echo "Array in sorted order :" +echo ${arr[*]} \ No newline at end of file diff --git a/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.Build.CppClean.log b/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.Build.CppClean.log new file mode 100644 index 0000000..60b1324 --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.Build.CppClean.log @@ -0,0 +1,13 @@ +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\vc142.pdb +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\vc142.idb +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.obj +c:\users\kmate\source\repos\bubble_sort_cpp\debug\bubble_sort_cpp.exe +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.ilk +c:\users\kmate\source\repos\bubble_sort_cpp\debug\bubble_sort_cpp.pdb +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.obj.enc +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.tlog\cl.command.1.tlog +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.tlog\cl.read.1.tlog +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.tlog\cl.write.1.tlog +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.tlog\link.command.1.tlog +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.tlog\link.read.1.tlog +c:\users\kmate\source\repos\bubble_sort_cpp\bubble_sort_cpp\debug\bubble_sort_cpp.tlog\link.write.1.tlog diff --git a/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.exe.recipe b/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.exe.recipe new file mode 100644 index 0000000..edfc622 --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.exe.recipe @@ -0,0 +1,11 @@ + + + + + C:\Users\kmate\source\repos\bubble_sort_cpp\Debug\bubble_sort_cpp.exe + + + + + + \ No newline at end of file diff --git a/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.log b/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.log new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/Debug/bubble_sort_cpp.log @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.cpp b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.cpp new file mode 100644 index 0000000..0f5a240 --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.cpp @@ -0,0 +1,75 @@ +// bubble_sort_cpp.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include +#include + +using namespace std; + +int* sort_func(int *sort,int len, bool repeat); +int size_array = 0; + + +int main() +{ + int tmp[] = { 2,7,2,1,3,100,3,32,342,2,44,23 }; + size_array = (sizeof(tmp) / sizeof(int))-1; + int* sorted= sort_func(tmp, size_array,false); + + for (int i = 0; i <= size_array; i++) + { + cout << sorted[i] << endl; + } +} + +int* sort_func(int *sort, int len, bool repeat) { + + bool t = true; + int j = 0; + + while (t) + { + for (int i = 0; i <= len - 1; i++) + { + if (sort[i] > sort[i + 1]) + { + int tmp1 = sort[i]; + sort[i] = sort[i + 1]; + sort[i + 1] = tmp1; + j = 0; + } + else if (sort[i] == sort[i + 1] && !repeat) + { + int del = i; + for (int a = del - 1; a < len; a++) + { + sort[del] = sort[del+ 1]; + del++; + } + + size_array--; + len--; + j = 0; + } + else + { + if (j == len) + t = false; + else + j++; + } + } + } + return sort; +} + +// Run program: Ctrl + F5 or Debug > Start Without Debugging menu +// Debug program: F5 or Debug > Start Debugging menu + +// Tips for Getting Started: +// 1. Use the Solution Explorer window to add/manage files +// 2. Use the Team Explorer window to connect to source control +// 3. Use the Output window to see build output and other messages +// 4. Use the Error List window to view errors +// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project +// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj new file mode 100644 index 0000000..8cdc272 --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {548c242a-3440-47b6-bd0a-2b0a3a030b67} + bubblesortcpp + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj.filters b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj.filters new file mode 100644 index 0000000..68be82c --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj.user b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj.user new file mode 100644 index 0000000..0f14913 --- /dev/null +++ b/bubble_sort_cpp/bubble_sort_cpp/bubble_sort_cpp.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/bubble_sort_cs/bubble_sort_cs/bubble_sort_cs.csproj b/bubble_sort_cs/bubble_sort_cs/bubble_sort_cs.csproj new file mode 100644 index 0000000..1d2d39a --- /dev/null +++ b/bubble_sort_cs/bubble_sort_cs/bubble_sort_cs.csproj @@ -0,0 +1,8 @@ + + + + Exe + net5.0 + + + diff --git a/bubble_sort_cs/bubble_sort_cs/obj/Debug/net5.0/apphost.exe b/bubble_sort_cs/bubble_sort_cs/obj/Debug/net5.0/apphost.exe new file mode 100644 index 0000000..fae5afa Binary files /dev/null and b/bubble_sort_cs/bubble_sort_cs/obj/Debug/net5.0/apphost.exe differ diff --git a/bubble_sort_cs/bubble_sort_cs/obj/Debug/net5.0/bubble_sort_cs.assets.cache b/bubble_sort_cs/bubble_sort_cs/obj/Debug/net5.0/bubble_sort_cs.assets.cache new file mode 100644 index 0000000..8f4cae3 Binary files /dev/null and b/bubble_sort_cs/bubble_sort_cs/obj/Debug/net5.0/bubble_sort_cs.assets.cache differ diff --git a/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.dgspec.json b/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.dgspec.json new file mode 100644 index 0000000..b608d57 --- /dev/null +++ b/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.dgspec.json @@ -0,0 +1,68 @@ +{ + "format": 1, + "restore": { + "C:\\Users\\kmate\\source\\repos\\bubble_sort_cs\\bubble_sort_cs\\bubble_sort_cs.csproj": {} + }, + "projects": { + "C:\\Users\\kmate\\source\\repos\\bubble_sort_cs\\bubble_sort_cs\\bubble_sort_cs.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\Users\\kmate\\source\\repos\\bubble_sort_cs\\bubble_sort_cs\\bubble_sort_cs.csproj", + "projectName": "bubble_sort_cs", + "projectPath": "C:\\Users\\kmate\\source\\repos\\bubble_sort_cs\\bubble_sort_cs\\bubble_sort_cs.csproj", + "packagesPath": "C:\\Users\\kmate\\.nuget\\packages\\", + "outputPath": "C:\\Users\\kmate\\source\\repos\\bubble_sort_cs\\bubble_sort_cs\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages", + "C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\" + ], + "configFilePaths": [ + "C:\\Users\\kmate\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config" + ], + "originalTargetFrameworks": [ + "net5.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net5.0": { + "targetAlias": "net5.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net5.0": { + "targetAlias": "net5.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.403\\RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.g.props b/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.g.props new file mode 100644 index 0000000..cb252ee --- /dev/null +++ b/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.g.props @@ -0,0 +1,20 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\kmate\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\ + PackageReference + 5.11.0 + + + + + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + \ No newline at end of file diff --git a/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.g.targets b/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.g.targets new file mode 100644 index 0000000..d212750 --- /dev/null +++ b/bubble_sort_cs/bubble_sort_cs/obj/bubble_sort_cs.csproj.nuget.g.targets @@ -0,0 +1,6 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + \ No newline at end of file diff --git a/bubble_sort_js/bubble_sort_js.js b/bubble_sort_js/bubble_sort_js.js new file mode 100644 index 0000000..2639a41 --- /dev/null +++ b/bubble_sort_js/bubble_sort_js.js @@ -0,0 +1,42 @@ +var size_array = 0; +function sort_func(sortA, len, repeat) { + var sort = []; + + // Loop through array values + for (var value of sortA) { + sort.push(value); + } + size_array = sort.length; + len = len - 1; + var t = true; + var j = 0; + + while (t) { + for (var i = 0; i <= len - 1; i++) { + if (sort[i] > sort[i + 1]) { + var tmp = sort[i]; + sort[i] = sort[i + 1]; + sort[i + 1] = tmp; + j = 0; + } else if (sort[i] == sort[i + 1] && !repeat) { + var del = i; + for (var a = del - 1; a < len; a++) { + sort[del] = sort[del + 1]; + del++; + } + + size_array--; + len--; + j = 0; + } else { + if (j == len) t = false; + else j++; + } + } + } + return sort; +} + +var to_sort = [1, 3, 1, 4, 254, 23, 423, 2, 1, 2, 3]; +var sorted = sort_func(to_sort, to_sort.length, true); +for (var i = 0; i <= size_array - 1; i++) document.write(sorted[i] + "
"); diff --git a/bubble_sort_php/bubble_sort_php.php b/bubble_sort_php/bubble_sort_php.php new file mode 100644 index 0000000..c0f2554 --- /dev/null +++ b/bubble_sort_php/bubble_sort_php.php @@ -0,0 +1,49 @@ + $sort[$i + 1]) + { + $tmp = $sort[$i]; + $sort[$i] = $sort[$i + 1]; + $sort[$i + 1] = $tmp; + $j = 0; + } + else if ($sort[$i] == $sort[$i + 1]&& !$repeat) + { + $del = $i; + for ($a = $del - 1; $a < $len; $a++){ + $sort[$del] = $sort[$del + 1]; + $del++; + } + + $size_array--; + $len--; + $j = 0; + } + + else + { + if ($j == $len) + $t = false; + else + $j++; + } + } + } + return $sort; + } + +$to_sort=array(1, 223, 54, 32,1,2,3,5,1,1,1,64); +$sorted= & sort_func($to_sort,count($to_sort),false); + +for($i=0;$i<=count($sorted)-1;$i++) + echo "$sorted[$i] \n"; +