English 中文(简体)
宾平搜索的两个先决条件是什么? [闭门]
原标题:What are the two precondition on Binary search? [closed]

i 在面谈中询问了双轨搜索的两个先决条件。 我已经告诉他们阵列,应该按 as令分类,但我不知道什么是双轨搜查的第二个先决条件?

任何人都能够告诉我宾平搜索的第二个先决条件?

问题回答

数据Array应当分类并在right上分类。 I.e.:如果在双轨搜索假设降级命令时按速率排列,它就赢得了笔工作。

一些澄清,因为人们似乎放弃了他们的Algorithms 101。

Precondition is a condition, that if not met - the algorithm is not required to provide the correct result.

Random access is not a precondition for a binary search algorithm, as it can and should return the correct answer even if the random access is not available (Binary Search Trees rely on that).

运营商的不足肯定不需要界定,因为它是具体语言的执行细节。 但它与事实接近。

http://en.wikipedia.org/wiki/Strict_weak_ordering”rel=“nofollow”>weak-ordered。

Data structure must be sorted in the same order as the one assumed by the binary search algorithm. As I mentioned, if the data is sorted in the ascending order, like the OP said, it doesn t mean that the binary search will provide the correct result, if the search is built for descending order, for example. There are many orders, ascending, descending, lexicographic, etc etc.

当你使用双轨搜索功能时,你必须确保对投入进行分类,并按你再次使用的顺序进行分类。 如果这两条没有得到满足,你就不必提供正确结果。

The pre-conditions of binary search here:

The array must be sorted in ascending order according to the ordering used by the comparisons in the search function.

作者只具体说明了一条先决条件,但我期望你可以将其分成两个相互相关的条件。

  • Must be sorted in ascending or descending order, depending on your search algorithm
  • Input must be compatible with the comparison algorithm

或许,你需要随机访问,以便进行双轨搜索。 或者说,至少阵列应当多变。

这些要素必须界定的经营者比较少。

各种要素需要分级,因此我猜测这些要素意味着

1) The elements are in an array (or in any data structure that enables indexed access).

(2) 储存按照比较功能进行分类。

这意味着:

  1. 必须分类

  2. 职业选择法





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签