answersLogoWhite

0

_node* search (_node* head, _key key) {

_node* node;

for (node=head; node != NULL;;) {

if (key == node->key) return node;

else if (key < node.>key) node = node->left;

else node = node->right;

}

return node;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is the time complexity for finding an element in a binary search tree?

The time complexity for finding an element in a binary search tree is O(log n), where n is the number of nodes in the tree.


What are the advantages and disadvantages of searching in C programming?

If the data is sorted and every element is directly accessible, then you can perform binary search (see built-in function bsearch), otherwise you have to do linear search (which is slower).


How can one perform a binary search?

One can perform a binary search easily in many different ways. One can perform a binary search by using an algorithm specifically designed to test the input key value with the value of the middle element.


What is the output of C programming of binary searching?

The output of a binary search routine is either (usually) the address of the element that matched the search term, or, if there was no match, the address of where the new element should be placed. Of course, this means that there are two outputs, one, an address, and two, whether or not the search term was found; which means that a single valued function will not suffice - it is necessary that one of the parameters be an address, perhaps of the flag variable.


What is the time complexity of an algorithm that uses a binary search to find an element in a sorted array in logn time?

The time complexity of an algorithm that uses binary search to find an element in a sorted array in logn time is O(log n).


How many comparisons are typically made in a binary search algorithm when searching for a specific element in a sorted array?

In a binary search algorithm, typically log(n) comparisons are made when searching for a specific element in a sorted array, where n is the number of elements in the array.


How many comparisons are typically required in a binary search algorithm to find a specific element in a sorted array?

In a binary search algorithm, typically log(n) comparisons are required to find a specific element in a sorted array, where n is the number of elements in the array.


What is the binary search definition in computer science and how is it used to efficiently locate a specific element in a sorted array?

Binary search is a search algorithm in computer science that efficiently finds the position of a specific element in a sorted array by repeatedly dividing the search interval in half. This method is used to quickly locate the desired element by comparing it to the middle element of the array and eliminating half of the remaining elements each time, until the target element is found or determined to be absent.


What is the maximum number of comparisons required in a binary search algorithm to find a specific element in a sorted array?

The maximum number of comparisons required in a binary search algorithm to find a specific element in a sorted array is log(n), where n is the number of elements in the array.


Does binary search tree take much time than the list to delete or insert an element?

No. Binary search tree will take less time to delete or insert an element. While deleting from list, more time will be required to search for the element to be deleted but BST will work faster if the no. of elements are more. Plus it depends upon which element is to be deleted and where the element is to be added. But the average time to perform these operations will be less in BST as compared to lists


How can I find an element in a binary search tree using Java?

To find an element in a binary search tree using Java, you can start at the root node and compare the element you are looking for with the current node's value. If the element is smaller, move to the left child node; if it is larger, move to the right child node. Repeat this process until you find the element or reach a null node, indicating that the element is not in the tree. This search process is efficient because it eliminates half of the remaining nodes at each step.


Which are the searching algorithm always compare the middle element with the searching elements in the given array?

binary search system