binary-search

    -4熱度

    2回答

    // RecursiveBinarySearch.cpp : Defines the entry point for the console application. // #include "stdafx.h" #define N 9 int RecursiveBinarySearch(int A, int low, int high, int x); int main() {

    -1熱度

    1回答

    不知道爲什麼這不會返回搜索到的元素的索引。輸入是排序的數組,它的大小和要找到的元素。 int binarySearch(int a[], int size, int key){ int mid = (size)/2; if(a[mid] == key){ return mid; }else if(size ==1 || size ==0){ re

    2熱度

    2回答

    這是我的二進制搜索功能。我似乎無法找到錯誤,但每次我嘗試運行代碼時,它都會給我一個分段錯誤11.我覺得我的錯誤與我的最後一條if語句有關。 void binary(struct list *A[], char search[15], int start, int end) { if(start <= end) { int middle = (start + end)/2

    0熱度

    1回答

    嗨,我想通過使用用戶通過文本框的輸入在排序的數組中進行二進制搜索。 這是我的代碼: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Te

    0熱度

    3回答

    我被要求使用二進制搜索到找到特定單詞在我們閱讀的文件中。 我不明白的問題是如何使用二進制搜索,當你正在尋找單詞而不是數字。

    0熱度

    1回答

    我似乎無法從終端執行我的java類 - 錯誤:無法找到或加載主類BinarySearch。 我正在從我的兩個文本文件所在的目錄中的終端執行java代碼。 Java代碼我試圖執行: public class BinarySearch { public static int rank(int[] a, int key) { int lo = 0; int hi = a.len

    0熱度

    2回答

    所以我建立在JavaScript程序,我需要尋找值的多維字典這樣的內部: var myDict = { apple: {name: 'apple 1', age: 14}, bear: {name: 'apple 1', age: 14}, cup: {name: 'apple 1', age: 14}, deer: {name: 'apple 1', ag

    1熱度

    3回答

    我想實現一個二進制搜索功能,我想知道如何修改新的數組與新的最小值/最大值。另外我是C++的新手,所以任何人都可以告訴我這是否是二進制搜索的正確實現?謝謝。 #include <iostream> using namespace std; bool doSearch(int arr, int target) { int min = 0; int max = arr.length()

    4熱度

    3回答

    的第一次出現的二進制搜索我有代碼,搜索一個排序後的數組,並返回k的第一次出現的索引。 我想知道是否它可以編寫使用 while(left<right) ,而不是 while(left<=right) 下面這段代碼是全碼: public static int searchFirstOfK(List<Integer> A, int k) { int left = 0, right =

    0熱度

    2回答

    我想按照標題中所述的方式引入我的程序的二進制搜索功能。但不斷得到兩個我不知道如何解決的錯誤。 這是編譯錯誤,我得到了我的代碼: : expected expression before '{' token array[size]={1,3,6,8,12,13,16}; ^ upg10.8.c: In function 'binarySearch': upg10.8.c:55:7: