test_redblacktree.m

来自「Comparison of C++, Java, Python, Ruby an」· M 代码 · 共 21 行

M
21
字号
% // ==================================
% // test program
% // ==================================

function test_RedBlackTree

nodelist= [11,4,8,14,17,6,9,7,16,15,13,5,19,18,12,10,3,20,1];
root = RedBlackTree(2);
for n=nodelist
    root.insert(n)
end

% class implementing the NodeVisitor interface
v=NodeVisitor;
fprintf('M      = ');
root.inorder(v,0);
fprintf('\n');

% find the specified element and print its value
x=root.find(16);
fprintf([x.s '\n']);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?