answersLogoWhite

0


Best Answer

If the data is sorted, you don't need a tree, you can use a sorted array with constant time random access and zero overhead. To perform a binary search, start with the middle element (what would be the root of a balanced tree). If that's not the value you're looking for, repeat the search with the left subarray if the middle element is larger, or the right subarray if not. This reduces the number of elements to search by half on each iteration. If the chosen subarray is empty, the value you're looking for does not exist. If the value does exist, you will eventually find it in the middle of the remaining subarray.

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How sorted data effects binary search tree?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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 do you print all data in a Binary Search Tree?

By using Depth First Search or Breadth First search Tree traversal algorithm we can print data in Binary search tree.


How many search techniqe's in data structure?

There are two types of searching technique used in data structure.such as linear and binary search.


What is binary search and linear search in data structure?

A Binary Search is a technique for quickly locating an item in a sequential list.A Sequential Search is a procedure for searching a table that consists of starting at some table position (usually the beginning) and comparing the file-record key in hand with each table-record key, one at a time, until either a match is found or all sequential positions have been searched.


Why linear search is called sequential search?

A linear search is called a sequential search because a sequential search takes linear time and therefore has a worst-case time-complexity of O(n) for a data sequence of n elements. Although there are more efficient search algorithms than linear search, not all data containers are ideally suited to them. For example, although a binary search can be performed in quadratic time (O(log n)) when the data container is in sorted order, we can only achieve maximum efficiency when the data container also supports constant-time random-access. Arrays and vectors do support constant-time random-access, but if the container is not sorted then we must resort to the less-efficient linear search. Linked lists do not support constant-time random-access thus a linear search would be more efficient even if the list were in sorted order.

Related questions

Which type of search algorithm checks every element on the list in sequence until a matching data is found?

It's called "Linear Search". If the list is sorted, then it is possible to perform more advanced searches like binary search. If the list isn't sorted, then you can either sort the list first and then binary search or simply use a linear search. Linear search is typically a brute force solution when the data isn't "planned" or if the data is stored in a linked list where random access of the values in the list is slow.


Why do you need to sort data before searching?

Sorting data before searching can significantly improve search performance because it enables more efficient search algorithms like binary search to be used. Sorting allows for faster lookup times by reducing the number of comparisons needed to find a specific value in the data set.


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).


What is best algorithm for searching?

It depends on how the data is arranged. In case it is an array, use linear search or binary search or interpolation search according as the array is sorted or not and based on the distribution of data. If some other data structures are used (like heap) for making data retrieval efficient, other algorithms exist.


How do you print all data in a Binary Search Tree?

By using Depth First Search or Breadth First search Tree traversal algorithm we can print data in Binary search tree.


What are the disadvantages of Fibonacci search?

There are a few disadvantages of the Fibonacci search: It can be slower than other search algorithms if the data is not sorted. It can be less accurate than other search algorithms if the data is not sorted. It can be more difficult to implement than other search algorithms.


What role does knowledge of data organization have in information retrieval?

Knowledge of how information is organized will allow a programmer to make more informed decisions on how to retrieve information. A simple example of this is the binary search. If you're looking for information in a list of data, you would normally need to perform an inefficient O(n) linear search. But if you happen to know that the data will always be in sorted order, you can use a nice O(log n) binary search instead.


How many search techniqe's in data structure?

There are two types of searching technique used in data structure.such as linear and binary search.


What is binary search and linear search in data structure?

A Binary Search is a technique for quickly locating an item in a sequential list.A Sequential Search is a procedure for searching a table that consists of starting at some table position (usually the beginning) and comparing the file-record key in hand with each table-record key, one at a time, until either a match is found or all sequential positions have been searched.


Why linear search is called sequential search?

A linear search is called a sequential search because a sequential search takes linear time and therefore has a worst-case time-complexity of O(n) for a data sequence of n elements. Although there are more efficient search algorithms than linear search, not all data containers are ideally suited to them. For example, although a binary search can be performed in quadratic time (O(log n)) when the data container is in sorted order, we can only achieve maximum efficiency when the data container also supports constant-time random-access. Arrays and vectors do support constant-time random-access, but if the container is not sorted then we must resort to the less-efficient linear search. Linked lists do not support constant-time random-access thus a linear search would be more efficient even if the list were in sorted order.


What condition linear search is better than binary search?

In linear search, the searched key will be compared with each element of the array from the beginning and terminate comparing when the searched key is found or the array is reached. Here time complexity in worst case and average case is O (n). To find an element quickly we use divide and conquer method by using binary search algorithm. Here probed region is reduced from n to n/2. Time complexity is O (log2 n), but here the array should be sorted. But in interpolation search the probed region is reduced from n to n1/2. If the array elements are uniformly distributed the average case complexity is O (log2 (log2n)). Am also searching for hashing to compare & contrast with above.


What are the advantages and disadvantages of binary search algorithms?

the major limitation of binary search is that there is a need of sorted array to perform binary search operation. if array is not sorted the output is either not correct or may be after a long number of steps and according to data structure the output should come in minimum number of steps.