Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Compare 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 :: unity clamp rotation 
Csharp :: c# error CS0515 
Csharp :: c# string is not null or empty 
Csharp :: c# update value in a json file 
Csharp :: milliseconds to seconds c# 
Csharp :: dynamic convert type c# 
Csharp :: c# bcrypt 
Csharp :: convert text to number c# 
Csharp :: how to save a c# dictionary 
Csharp :: round float c# 
Csharp :: how to make error sound c# 
Csharp :: c# socket listen on port 
Csharp :: c# string.join 
Csharp :: get 2d rotation from 2 position math 
Csharp :: how to set up blender with unity units 
Csharp :: C# removing the last value of an array 
Csharp :: c# void 
Csharp :: csharp 
Csharp :: accessing form controls from another class c# 
Csharp :: todictionary c# 
Csharp :: unity how to get the side ways velocity of a object 
Csharp :: unity camera follow player 3d smooth 
Csharp :: log to console c# unity 
Csharp :: string reverse c# 
Csharp :: c# console wait for input 
Csharp :: if number negative c sharp 
Csharp :: c-sharp - get current page url/path/host 
Csharp :: c# messagebox result 
Csharp :: editorfor date format mvc 
Csharp :: index of item in list C# 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =