-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecondLargestNode.cs
More file actions
46 lines (39 loc) · 1.24 KB
/
SecondLargestNode.cs
File metadata and controls
46 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using DataStructures.Libraries.Trees;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algorithms.Problem.Trees
{
[TestClass]
public class SecondLargestNode
{
public BinaryTreeNode FindSecondLargestNode(BinaryTreeNode root)
{
return null;
}
public double FindRightMostNode(BinaryTreeNode currentNode)
{
if (currentNode.Right != null)
{
return this.FindRightMostNode(currentNode.Right);
}
return currentNode.Value;
}
[TestMethod]
public void TestSecondLargetsNode()
{
BinaryTreeNode root = new BinaryTreeNode(5);
root.Left = new BinaryTreeNode(3);
root.Right = new BinaryTreeNode(8);
root.Left.Left = new BinaryTreeNode(1);
root.Left.Right = new BinaryTreeNode(4);
root.Right.Left = new BinaryTreeNode(7);
root.Right.Right = new BinaryTreeNode(9);
root.Right.Right.Right = new BinaryTreeNode(12);
double largest = this.FindRightMostNode(root);
}
}
}