-
Given an increasing sequence S of N integers, the median
is the number at the middle position. For example, the median of
S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is
15. The median of two sequences is defined to be the median of the
nondecreasing sequence which contains all the elements of both
sequences. For example, the median of S1 and S2 is 13.
Given two increasing sequences of integers, you are asked to find their median.
输入描述:
Each input file contains one te ...
阅读题目
面试题
经典指数
-
有一个排过序的数组,包含n个整数,但是这个数组向左进行了一定长度的移位,例如,原数组为[1,2,3,4,5,6],向左移位5个位置即变成了[6,1,2,3,4,5],现在对于移位后的数组,需要查找某个元素的位置。请设计一个复杂度为log级别的算法完成这个任务。
给定一个int数组A,为移位后的数组,同时给定数组大小n和需要查找的元素的值x,请返回x的位置(位置从零开始)。保证数组中元素互异。
测试样例:
[6,1,2,3,4,5],6,6
返回:0 ...
阅读题目
面试题
经典指数
-
-
-
-
-
-
-
对下列关键字序列用快速排序法进行排序时,速度最快的情形是()
{21,25,5,17,9,23,30}
{25,23,30,17,21,5,9}
{21,9,17,30,25,23,5}
{5,9,17,21,23,25,30} ...
阅读题目
单选题
经典指数
-
你现在有一个文件,文件中顺序存有N个记录,R1,R2,...,RN,这些记录不是有序的,但是你知道一个整数M,这些记录满足R1以及RM+1。
1,设计一个算法或编写一个程序,将文件中的记录排序为R1',R2',...,RN',算法或程序读取文件的次数为O(N),不限内存使用,
2,设计一个算法或编写一个程序,将文件中的记录排序为R1',R2',...,RN',算法或程序读写文件的次数为O(N),空间复杂度为O(1),亦即,你使用的内存大小和M,N均无关。 ...
阅读题目
问答题
经典指数
扫描后移动端查看
相关标签
同类标签
|
微信公众号
|
|
欢迎加入,一起群聊
|