Skip to content

Commit

Permalink
BubbleSort 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
1byte2bytes committed Sep 17, 2017
1 parent 4a46604 commit 5cf823d
Show file tree
Hide file tree
Showing 14 changed files with 577 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions .idea/.idea.SortingAlgos/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.SortingAlgos/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

246 changes: 246 additions & 0 deletions .idea/.idea.SortingAlgos/.idea/workspace.xml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions .idea/.idea.SortingAlgos/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added BubbleSort/.DS_Store
Binary file not shown.
54 changes: 54 additions & 0 deletions BubbleSort/BubbleSort.csproj
Original file line number Diff line number Diff line change
@@ -0,0 1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{580FF020-9A74-45C3-8709-1F76CC8BEA23}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BubbleSort</RootNamespace>
<AssemblyName>BubbleSort</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
27 changes: 27 additions & 0 deletions BubbleSort/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,27 @@
using System;

namespace SortingAlgos
{
public class BubbleSort
{
public static void Sort(int[] input)
{
int len = input.Length;
bool swapped = true;
while (swapped == true)
{
swapped = false;
for (int i = 1; i <= len - 1; i )
{
if (input[i - 1] > input[i])
{
int temp = input[i - 1];
input[i - 1] = input[i];
input[i] = temp;
swapped = true;
}
}
}
}
}
}
36 changes: 36 additions & 0 deletions BubbleSort/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BubbleSort")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BubbleSort")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("580FF020-9A74-45C3-8709-1F76CC8BEA23")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
28 changes: 28 additions & 0 deletions SortingAlgos.sln
Original file line number Diff line number Diff line change
@@ -0,0 1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SortingAlgos", "SortingAlgos/SortingAlgos.csproj", "{1E0D8D69-975D-43B6-B97D-30614EDB6DF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BubbleSort", "BubbleSort\BubbleSort.csproj", "{580FF020-9A74-45C3-8709-1F76CC8BEA23}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1E0D8D69-975D-43B6-B97D-30614EDB6DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E0D8D69-975D-43B6-B97D-30614EDB6DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E0D8D69-975D-43B6-B97D-30614EDB6DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E0D8D69-975D-43B6-B97D-30614EDB6DF9}.Release|Any CPU.Build.0 = Release|Any CPU
{580FF020-9A74-45C3-8709-1F76CC8BEA23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{580FF020-9A74-45C3-8709-1F76CC8BEA23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{580FF020-9A74-45C3-8709-1F76CC8BEA23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{580FF020-9A74-45C3-8709-1F76CC8BEA23}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added SortingAlgos/.DS_Store
Binary file not shown.
60 changes: 60 additions & 0 deletions SortingAlgos/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,60 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;

namespace SortingAlgos
{
internal class Program
{
public static void GenerateArray(int[] array, int[] sortedArray, Random rnd, int arraySizes)
{
// Generate some random test data
for (int i = 0; i < arraySizes; i )
{
array[i] = rnd.Next();
}
Console.WriteLine("Generated random numbers!");

// Copy and sort array
Array.Copy(array, sortedArray, arraySizes);
Array.Sort(sortedArray);
}

public static bool ArrayEqual(int[] first, int[] second)
{
for (int i = 0; i < first.Length; i )
{
if (first[i] != second[i])
{
Console.WriteLine("Not equal, index " i);
return false;
}
}
return true;
}

public static void Main(string[] args)
{
// Create our initial variables
int arraySizes = 10;
Random rnd = new Random();
int[] array = new int[arraySizes];
int[] sortedArray = new int[arraySizes];

// Generate some random numbers
GenerateArray(array, sortedArray, rnd, arraySizes);

// Check that the sorted array and main array are not equal
if (ArrayEqual(array, sortedArray) == false)
{
Console.WriteLine("Done checking numbers");
}

// Complete BubbleSort test
BubbleSort.Sort(array);
ArrayEqual(array, sortedArray);
Console.WriteLine("BubbleSort finished");
}
}
}
36 changes: 36 additions & 0 deletions SortingAlgos/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SortingAlgos")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SortingAlgos")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1E0D8D69-975D-43B6-B97D-30614EDB6DF9")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
61 changes: 61 additions & 0 deletions SortingAlgos/SortingAlgos.csproj
Original file line number Diff line number Diff line change
@@ -0,0 1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1E0D8D69-975D-43B6-B97D-30614EDB6DF9}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SortingAlgos</RootNamespace>
<AssemblyName>SortingAlgos</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BubbleSort\BubbleSort.csproj">
<Project>{580ff020-9a74-45c3-8709-1f76cc8bea23}</Project>
<Name>BubbleSort</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit 5cf823d

Please sign in to comment.