Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Comapre Binary Trees

public bool IsEqual(Node first, Node second)
{
    if (first == null && second == null) return true;

    if(first != null && second != null)
    {
      return first.data == second.data && 
          IsEqual(first.rightChild,second.rightChild) &&
          IsEqual(first.leftChild,second.leftChild);
    }
    return false;
}


// Node structure

public class Node
{
    private int data;
    private Node leftChild;
    private Node rightChild;
    public Node(int data)
    {
      	this.data = data;
    }
}
Comment

compare binary trees

compare(tree1 ,tree2 ){

let x =tree1.count()
let y =tree2.count()

if(x==y)return true; else return false;
}


//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
Comment

PREVIOUS NEXT
Code Example
Csharp :: mathf.clamp unity 
Csharp :: c# date 
Csharp :: how to change loaded scene in unity 
Csharp :: c# append multiline textbox 
Csharp :: photon rpc 
Csharp :: c# linq remove duplicate items from list of integer 
Csharp :: c# LCP 
Csharp :: update models with ef core 
Csharp :: displayname c# 
Csharp :: using serial port in c# 
Csharp :: c# groupby date 
Csharp :: weighted random c# 
Csharp :: how to chagne rotation in unity 
Csharp :: How do i destroy a prefab without the error? 
Csharp :: know to which direction Vector.MoveTowards is moving unity 2D 
Csharp :: c# messagebox yes no "wpf" 
Csharp :: make window not resizable wpf 
Csharp :: convert iformfile to byte array c# 
Csharp :: linux command line switch statement 
Csharp :: onkeypressed unity 
Csharp :: convert.tostring with datetime string 
Csharp :: list removeall unity 
Csharp :: unity c# debug.log 
Csharp :: C# decimal with two places store as string with two places 
Csharp :: change button color in script unity 
Csharp :: What is the difference between String and string in C#? 
Csharp :: .net mvc decimal displayformat currency 
Csharp :: how to see image from website in wpf 
Csharp :: c# calculator 
Csharp :: C# array of repeated value 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =