Skip to content

Commit d11b764

Browse files
authored
Merge pull request #251 from ikesnowy/Dev-1.5
1.5 Finished
2 parents a01fd63 + 56ea706 commit d11b764

File tree

157 files changed

+7280
-258
lines changed

Some content is hidden

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

157 files changed

+7280
-258
lines changed

1 Fundamental/1.5/1.5.1/Program.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using UnionFind;
73

84
namespace _1._5._1
@@ -29,7 +25,7 @@ static void Main(string[] args)
2925
int p = int.Parse(numbers[0]);
3026
int q = int.Parse(numbers[1]);
3127

32-
int[] id = quickFind.GetID();
28+
int[] id = quickFind.GetParent();
3329
quickFind.Union(p, q);
3430
foreach (int root in id)
3531
{

1 Fundamental/1.5/1.5.1/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// 有关程序集的一般信息由以下
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>{BDD56032-B77A-43CB-9C8D-02C98A28BB8B}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>_1._5._10</RootNamespace>
10+
<AssemblyName>1.5.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>
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>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace _1._5._10
2+
{
3+
/*
4+
* 1.5.10
5+
*
6+
* 在加权 quick-union 算法中,
7+
* 假设我们将 id[find(p)] 的值设为 q 而非 id[find[q]],所得的算法是正确的吗?
8+
* 答:是,但这会增加树的高度,因此无法保证同样的性能。
9+
*
10+
*/
11+
class Program
12+
{
13+
static void Main(string[] args)
14+
{
15+
// 答案已经给出,这里简单解释。
16+
// 输入是 p、q。
17+
// 现在执行 union,但只是把 p 挂到 q 上而不是挂到 q 的根节点上。
18+
// 结果显然是整棵树的高度增加了,find 操作的效率会降低。
19+
}
20+
}
21+
}
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("1.5.10")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("1.5.10")]
12+
[assembly: AssemblyCopyright("Copyright © 2017")]
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("bdd56032-b77a-43cb-9c8d-02c98a28bb8b")]
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")]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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>{79AC7B52-9F05-47C2-8EDB-77F462C23E9D}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>_1._5._11</RootNamespace>
10+
<AssemblyName>1.5.11</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+
<Compile Include="WeightedQuickFindUF.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<ProjectReference Include="..\TestCase\TestCase.csproj">
54+
<Project>{0a116d2e-0da8-4f18-9607-a9f2a4648227}</Project>
55+
<Name>TestCase</Name>
56+
</ProjectReference>
57+
<ProjectReference Include="..\UnionFind\UnionFind.csproj">
58+
<Project>{b18b7737-dfdd-4319-ab4f-db6ac3352a3d}</Project>
59+
<Name>UnionFind</Name>
60+
</ProjectReference>
61+
</ItemGroup>
62+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
63+
</Project>
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>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using UnionFind;
3+
4+
namespace _1._5._11
5+
{
6+
/*
7+
* 1.5.11
8+
*
9+
* 实现加权 quick-find 算法,其中我们总是将较小的分量重命名为较大分量的标识符。
10+
* 这种改变会对性能产生怎样的影响?
11+
*
12+
*/
13+
class Program
14+
{
15+
static void Main(string[] args)
16+
{
17+
char[] split = { '\n', '\r' };
18+
string[] input = TestCase.Properties.Resources.mediumUF.Split(split, StringSplitOptions.RemoveEmptyEntries);
19+
int size = int.Parse(input[0]);
20+
21+
QuickFindUF quickFind = new QuickFindUF(size);
22+
WeightedQuickFindUF weightedQuickFind = new WeightedQuickFindUF(size);
23+
24+
int p, q;
25+
string[] pair;
26+
for (int i = 1; i < size; ++i)
27+
{
28+
pair = input[i].Split(' ');
29+
p = int.Parse(pair[0]);
30+
q = int.Parse(pair[1]);
31+
quickFind.Union(p, q);
32+
weightedQuickFind.Union(p, q);
33+
}
34+
35+
Console.WriteLine("quick-find: " + quickFind.ArrayVisitCount);
36+
Console.WriteLine("weighted quick-find: " + weightedQuickFind.ArrayVisitCount);
37+
}
38+
}
39+
}
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("1.5.11")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("1.5.11")]
12+
[assembly: AssemblyCopyright("Copyright © 2017")]
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("79ac7b52-9f05-47c2-8edb-77f462c23e9d")]
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")]

0 commit comments

Comments
 (0)