Skip to content

Commit 7ee50d7

Browse files
committed
Program.cs includes the main file.
1 parent a1f0f22 commit 7ee50d7

File tree

11 files changed

+1038
-0
lines changed

11 files changed

+1038
-0
lines changed

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.5" />
5+
</startup>
6+
</configuration>

ArrayOperation.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace DSA
8+
{
9+
class ArrayOperation
10+
{
11+
public static int[] Insert(int numberToInsert, int location, int[] arr)
12+
{
13+
int[] arrN = new int[arr.Length + 1];
14+
for (int i = 0; i < location; i++)
15+
{
16+
arrN[i] = arr[i];
17+
}
18+
for (int i = arrN.Length - 1; i > location; i--)
19+
{
20+
arrN[i] = arr[i - 1];
21+
}
22+
arrN[location] = numberToInsert;
23+
for (int i = 0; i < arrN.Length; i++)
24+
{
25+
Console.WriteLine("\nThe new Array is :" + arrN[i]);
26+
}
27+
for (int i = 0; i < arr.Length; i++)
28+
{
29+
Console.WriteLine("\nThe old array insertion is :" + arr[i]);
30+
}
31+
return arr;
32+
}
33+
}
34+
}

Class1.cs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace DSA
8+
{
9+
class HashTable
10+
{
11+
12+
class HashEntry
13+
{
14+
private int key;
15+
private string value;
16+
17+
public HashEntry(int key, string value)
18+
{
19+
this.key = key;
20+
this.value = value;
21+
}
22+
23+
public int GetKey()
24+
{
25+
return key;
26+
}
27+
28+
public string GetValue()
29+
{
30+
return value;
31+
}
32+
}
33+
public class HashTableUsingArray
34+
{
35+
private int size = 128;
36+
HashEntry[] newHashTable;
37+
public HashTableUsingArray()
38+
{
39+
newHashTable = new HashEntry[size];
40+
for(int i =0; i<size; i++)
41+
{
42+
newHashTable[i] = null;
43+
}
44+
}
45+
46+
public string Get(int key)
47+
{
48+
int hash = key%size;
49+
while(newHashTable[hash] != null && newHashTable[hash].GetKey() != key)
50+
{
51+
hash = (hash + 1) % size + 10 % 3;
52+
}
53+
if(newHashTable[hash].GetKey() == key)
54+
{
55+
return newHashTable[hash].GetValue();
56+
}
57+
else {
58+
return "Key not found";
59+
}
60+
}
61+
62+
public void Put(int key, string value)
63+
{
64+
int hash = key%size;
65+
while(newHashTable[hash] != null && newHashTable[hash].GetKey() != key)
66+
{
67+
hash = (hash+1)%size;
68+
}
69+
newHashTable[hash] = new HashEntry(key, value);
70+
}
71+
}
72+
73+
public static void ImplementHashTableinCSharp()
74+
{
75+
Dictionary<string, int> EmployeeID = new Dictionary<string, int>();
76+
EmployeeID.Add("Susan", 24);
77+
EmployeeID.Add("Robert", 42);
78+
EmployeeID.Add("Abhinav", 26);
79+
EmployeeID.Add("Amith", 24);
80+
EmployeeID.Add("Mukul", 22);
81+
82+
int getAge =0;
83+
if(EmployeeID.TryGetValue("Susan", out getAge))
84+
{
85+
Console.WriteLine("The age of the given emplyee is :" + getAge);
86+
}
87+
88+
foreach(var match in EmployeeID)
89+
{
90+
if(match.Value<35 )
91+
Console.WriteLine("\n The key is : " + match.Key + " & the value is : " + match.Value);
92+
}
93+
}
94+
95+
public static string ReverseString(string Str)
96+
{
97+
char[] StrCh= Str.ToCharArray();
98+
for (int i = 0; i < StrCh.Length/2; i++)
99+
{
100+
char c = StrCh[i];
101+
StrCh[i] = StrCh[Str.Length - 1 - i];
102+
StrCh[Str.Length - 1 - i] = c;
103+
}
104+
Console.WriteLine(StrCh);
105+
return StrCh.ToString();
106+
}
107+
108+
public static void PrintTables()
109+
{
110+
for (int i =1;i<13;i++)
111+
{
112+
for(int j =1;j<13;j++)
113+
{
114+
Console.Write("\t"+i * j);
115+
}
116+
Console.WriteLine("\n ");
117+
}
118+
}
119+
}
120+
}

DSA.csproj

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{0580C8EF-5A53-4A04-A04E-C7789561D068}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>DSA</RootNamespace>
11+
<AssemblyName>DSA</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
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.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="ArrayOperation.cs" />
45+
<Compile Include="Class1.cs" />
46+
<Compile Include="Graphs.cs" />
47+
<Compile Include="LinkedList.cs" />
48+
<Compile Include="Program.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
<Compile Include="SearchOPerations.cs" />
51+
<Compile Include="Sort.cs" />
52+
<Compile Include="StacksAndQueues.cs" />
53+
<Compile Include="Trees.cs" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<None Include="App.config" />
57+
</ItemGroup>
58+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
59+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
60+
Other similar extension points exist, see Microsoft.Common.targets.
61+
<Target Name="BeforeBuild">
62+
</Target>
63+
<Target Name="AfterBuild">
64+
</Target>
65+
-->
66+
</Project>

Graphs.cs

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace DSA
8+
{
9+
class Graphs
10+
{
11+
public class graphNode
12+
{
13+
public int vertex;
14+
public graphNode next = null;
15+
}
16+
public graphNode root = null;
17+
18+
public graphNode AddgraphNode(graphNode node, int data)
19+
{
20+
while(node!=null)
21+
{
22+
node = node.next;
23+
}
24+
node = new graphNode()
25+
{
26+
vertex = data
27+
28+
};
29+
return node;
30+
}
31+
32+
public class graph
33+
{
34+
35+
public int numVertex;
36+
public graphNode[] vertexArray;
37+
38+
int GetVertex()
39+
{
40+
Console.WriteLine("Please Enter the number of vertices you need th graph for:");
41+
Int32.TryParse(Console.ReadLine(), out this.numVertex);
42+
return numVertex;
43+
}
44+
45+
public graph()
46+
{
47+
GetVertex();
48+
vertexArray = new graphNode[numVertex];
49+
for (int i = 0; i < numVertex; i++)
50+
{
51+
vertexArray[i] = new graphNode() { vertex = i + 1 };
52+
Console.WriteLine(vertexArray[i]);
53+
}
54+
}
55+
56+
public void AddConnection(int src, int destination)
57+
{
58+
int i = 0;
59+
while (vertexArray[i].vertex != src && i < vertexArray.Length-1)
60+
{
61+
i++;
62+
}
63+
graphNode curr = vertexArray[i];
64+
if (curr.vertex == src)
65+
{
66+
while(curr.next!=null)
67+
{
68+
curr = curr.next;
69+
}
70+
curr.next = new graphNode(){
71+
vertex = destination
72+
};
73+
}
74+
75+
else
76+
{
77+
Console.WriteLine("No source vertex found");
78+
}
79+
}
80+
81+
82+
}
83+
84+
public static void DFSTraversal(graph g)
85+
{
86+
87+
bool[] visited = new bool[g.vertexArray.Length];
88+
for (int i = 0; i < visited.Length; i++)
89+
{
90+
visited[i] = false;
91+
}
92+
StacksAndQueues.Stacks s = new StacksAndQueues.Stacks();
93+
StacksAndQueues.InitializeStack(s, g.vertexArray.Length);
94+
95+
graphNode startPoint = g.vertexArray.First();
96+
graphNode currPoint = g.vertexArray.First();
97+
visited[0] = true;
98+
int pos = 1;
99+
StacksAndQueues.PushOntoStack(s, currPoint.vertex);
100+
while (s.top != 0)
101+
{
102+
while (currPoint.next != null && pos < g.vertexArray.Length)
103+
{
104+
if (!visited[currPoint.next.vertex - 1])
105+
{
106+
StacksAndQueues.PushOntoStack(s, currPoint.next.vertex);
107+
visited[currPoint.next.vertex - 1] = true;
108+
Console.WriteLine("The vertex " + currPoint.vertex + " was pushed onto the stack and is marked as visited\n");
109+
Console.WriteLine("The vertex " + currPoint.next.vertex + " is visited");
110+
currPoint = g.vertexArray[currPoint.next.vertex - 1];
111+
Console.WriteLine("tHE STACK top IS " + s.top);
112+
pos++;
113+
}
114+
else if (visited[currPoint.next.vertex - 1])
115+
{
116+
currPoint = currPoint.next;
117+
visited[currPoint.vertex - 1] = true;
118+
}
119+
}
120+
StacksAndQueues.PopStack(s);
121+
if(s.top!=0)
122+
currPoint = g.vertexArray[s.top-1];
123+
124+
Console.WriteLine("The first depth is done, retrackting to " + currPoint.vertex);
125+
}
126+
127+
Console.WriteLine("The depth search is complete");
128+
}
129+
}
130+
}

0 commit comments

Comments
 (0)