搜索结果排序图书 - 搜索相关问题 [英] Sort out Books - Search related question

查看:109
本文介绍了搜索结果排序图书 - 搜索相关问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在问技术面试一个问题,是这样的。

I've recently been asked a question in technical interview that goes like this.

您必须找到一个特定的书在图书馆,你走了进去的那一刻,你看到所有的书都散落各地的图书馆,也就是书不放在库里面有组织的方式。您将如何继续寻找特定的书?有不同之处在于,你知道这本书的名称不规范有关的书

You have to find a specific book in a library, and the moment you went inside, you saw that all the books are scattered all around the library, i.e. books are not placed in organized way inside library. How will you proceed to look for that specific book? There is no specification about the book except that you know the Name of the Book.

我知道这是关系到一些搜索算法,但什么算法可用于在这种情况下,在搜索书?

I know this is related to some search algorithm, but what algorithm can be used for searching book in this case?

推荐答案

开始的第一本书和搜索每本书,直到你遇到了你想要的书的第一次出现执行线性搜索(可能有多个副本课程)。

Perform a linear search starting at the first book and searching each book until you come across the first occurrence of the the book you want (there may be multiple copies of course).

如果您是唯一的搜索,有很多书,然后把它们整理寻找这本书看起来像时间的巨大浪费低效之前 - 除非你打算寻找在未来更多的书。

If you are the sole searcher and there are many books, then sorting them before looking for the book would seem like a hugely inefficient waste of time - unless you intend to search for more books in the future.

您可以随时要求图书管理员告诉你,这本书是对他们的系统或者你可以招募一些朋友帮你查,并在并行和工作分开的问题。

You could always ask the librarian to tell you where the book is on their system or you could enlist some friends to help you search and split the problem up and work in parallel.

修改 还有一个量子算法,称为 Grovers算法(如果你是在以那种事)比对一个未排序的数据库进行线性搜索速度更快,但我不知道太多关于它是诚实的。

EDIT There is also a quantum algorithm called Grovers algorithm (if you're in to that sort of thing) that is faster than a linear search for an unsorted database but I don't know too much about it to be honest.

这篇关于搜索结果排序图书 - 搜索相关问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆