Skip to content

Commit c3d526a

Browse files
authored
Merge pull request #356 from ikesnowy/dev
2.3 Finished
2 parents cfac2e9 + 5fb692a commit c3d526a

File tree

189 files changed

+10899
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+10899
-21
lines changed

2 Sorting/2.1/2.1.18/Form3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public partial class Form3 : Form
1010
double[] randomDoubles;
1111
int sortI;
1212
int sortJ;
13-
int n = 0;
13+
1414
public Form3(int N)
1515
{
1616
InitializeComponent();

2 Sorting/2.2/2.2.26/AuxInMergeMergeSort.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Diagnostics;
72
using Merge;
83

94
namespace _2._2._26

2 Sorting/2.2/2.2.26/AuxInSortMergeSort.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Diagnostics;
72
using Merge;
83

94
namespace _2._2._26

2 Sorting/2.3/2.3.1/2.3.1.csproj

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{0B42B539-F300-4D97-B4D0-47249CCC6F01}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>_2._3._1</RootNamespace>
10+
<AssemblyName>2.3.1</AssemblyName>
11+
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Net.Http" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="Program.cs" />
46+
<Compile Include="Properties\AssemblyInfo.cs" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="App.config" />
50+
</ItemGroup>
51+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
52+
</Project>

2 Sorting/2.3/2.3.1/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
5+
</startup>
6+
</configuration>

2 Sorting/2.3/2.3.1/Program.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace _2._3._1
2+
{
3+
/*
4+
* 2.3.1
5+
*
6+
* 按照 Partition() 方法的轨迹的格式给出该方法是如何切分数组
7+
* E A S Y Q U E S T I O N 的。
8+
*
9+
*/
10+
class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
// a[]
15+
// i j 0 1 2 3 4 5 6 7 8 9 10 11
16+
// 0 16 E A S Y Q U E S T I O N
17+
// 1 6 E A S Y Q U E S T I O N
18+
// 1 6 E A E Y Q U S S T I O N
19+
// 3 2 E A E Y Q U S S T I O N
20+
// 3 2 E A E Y Q U S S T I O N
21+
// 2 E A E Y Q U S S T I O N
22+
}
23+
}
24+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// 有关程序集的一般信息由以下
5+
// 控制。更改这些特性值可修改
6+
// 与程序集关联的信息。
7+
[assembly: AssemblyTitle("2.3.1")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("2.3.1")]
12+
[assembly: AssemblyCopyright("Copyright © 2018")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// 将 ComVisible 设置为 false 会使此程序集中的类型
17+
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
18+
//请将此类型的 ComVisible 特性设置为 true。
19+
[assembly: ComVisible(false)]
20+
21+
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
22+
[assembly: Guid("0b42b539-f300-4d97-b4d0-47249ccc6f01")]
23+
24+
// 程序集的版本信息由下列四个值组成:
25+
//
26+
// 主版本
27+
// 次版本
28+
// 生成号
29+
// 修订号
30+
//
31+
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
32+
// 方法是按如下所示使用“*”: :
33+
// [assembly: AssemblyVersion("1.0.*")]
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]

2 Sorting/2.3/2.3.10/2.3.10.csproj

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A084203F-4C71-4A74-9D8B-F76EFD052845}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>_2._3._10</RootNamespace>
10+
<AssemblyName>2.3.10</AssemblyName>
11+
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Net.Http" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="Program.cs" />
46+
<Compile Include="Properties\AssemblyInfo.cs" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="App.config" />
50+
</ItemGroup>
51+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
52+
</Project>

2 Sorting/2.3/2.3.10/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
5+
</startup>
6+
</configuration>

2 Sorting/2.3/2.3.10/Program.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
3+
namespace _2._3._10
4+
{
5+
/*
6+
* 2.3.10
7+
*
8+
* Chebyshev 不等式表明,
9+
* 一个随机变量的标准差距离均值大于 k 的概率小于 1/k^2 。
10+
* 对于 N=100 万,
11+
* 用 Chebyshev 不等式计算快速排序所使用的比较次数大于 1000 亿次的概率(0.1N^2)。
12+
*
13+
*/
14+
class Program
15+
{
16+
static void Main(string[] args)
17+
{
18+
// 切比雪夫不等式(Chebyshev's inequality)
19+
// P(|X-μ| ≥ kσ) ≤ 1/(k^2)
20+
// 其中 μ 是期望,σ 是标准差。
21+
// 在快速排序的比较次数中,μ=2NlnN,σ=0.65N
22+
// (这两个结论可以见 2.3 节的命题 K 和命题 L)
23+
// 题目中要求比较次数大于 0.1N^2,可以得到等式:
24+
// 0.65N * k = 0.1N^2
25+
// k = 2/13 * N
26+
// 将 N = 1 000 000 代入
27+
// P(|X-27 631 021| ≥ 100 000 000 000) ≤ 0.00000000004225
28+
// P ≤ 0.000000004225 %
29+
double N = 10000000;
30+
double k = 0.1 * N / 0.65;
31+
Console.WriteLine(1.0 / (k * k));//4.225x10^-13
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)