How To Search For A Key In A Binary Search Tree #560
How to search for a key in a binary search tree?
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Binary Trees - Binary Search Tree - Quiz No.1.
How to search for a key in a binary search tree?
public Tree search(Tree root, int key) { if( root == null || root.key == key ) { return root; } if( root.key < key ) { return search(root.right,key); } else return search(root.left,key); }
public Tree search(Tree root, int key) { if( root == null || root.key == key ) { return root; } if( root.key < key ) { return search(root.left,key); } else return search(root.right,key); }
public Tree search(Tree root, int key) { if( root == null) { return root; } if( root.key < key ) { return search(root.right,key); } else return search(root.left,key); }
public Tree search(Tree root, int key) { if( root == null) { return root; } if( root.key < key ) { return search(root.right.right,key); } else return search(root.left.left,key); }
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes