i was wondering since systemverilog has oops concepts. Is it possible to create binary tree of n nodes in systemverilog
class node;
int val;
node left,right;
function new(int data);
val=data;
left=null;
right=null;
endfunction
endclass
class btree;
node root;
function new(int info);
root=new(info);
endfunction
endclass
btree b1;
module abc();
initial begin
b1=new(1);
b1.root=new(2)
b1.root.left= new(3);
b1.root.right= new(4);
$display("%0p",b1);
end
endmodule
i am trying to create a binary tree capable of adding any number of nodes, delete nth node and could tranverse through tree to print.