### Question:
MeanDVSearch extends Searcher { public static void bubble(double[] sims, byte[][] names, double this_sim, byte[] name, int K) { int i = K-1; for (; i>=0 && this_sim > sims[i]; i--) { sims[i+1] = sims[i]; names[i+1] = names[i]; } sims[i+1] = this_sim; names[i+1] = name; } MeanDVSearch(Environment env); static void bubble(double[] sims, byte[][] names, double this_sim, byte[] name, int K); List<Passage> query(Question question); static final int K; static final int N; static final int LEN; }### Answer:
@Test public void testBubble() { double[] sims = new double[5]; byte[][] names = new byte[5][]; byte[] name_e = bytes("e"); byte[] name_f = bytes("f"); byte[] name_g = bytes("g"); sims[0]=0.8; sims[1]=0.5; sims[2]=0.0; sims[3]=-1; names[0]=bytes("a"); names[1]=bytes("b"); names[2]=bytes("c"); names[3]=bytes("d"); MeanDVSearch.bubble(sims, names, 0.9, name_e, 4); assertEquals(0.9, sims[0], 0.01); assertEquals(0.8, sims[1], 0.01); assertEquals(0.5, sims[2], 0.01); assertEquals(0.0, sims[3], 0.01); assertEquals(name_e, names[0]); MeanDVSearch.bubble(sims, names, 0.1, name_f, 4); assertEquals(0.9, sims[0], 0.01); assertEquals(0.8, sims[1], 0.01); assertEquals(0.5, sims[2], 0.01); assertEquals(0.1, sims[3], 0.01); assertEquals(name_f, names[3]); MeanDVSearch.bubble(sims, names, 0.5, name_g, 4); assertEquals(0.9, sims[0], 0.01); assertEquals(0.8, sims[1], 0.01); assertEquals(0.5, sims[2], 0.01); assertEquals(0.5, sims[3], 0.01); assertEquals(name_g, names[3]); }