linear-search Questions

20

I'm looking to optimize this linear search: static int linear (const int *arr, int n, int key) { int i = 0; while (i < n) { if (arr [i] >= key) break; ++i; } return i; } The array i...
Rubirubia asked 30/4, 2010 at 1:50

7

My goal is to understand why adopting linear search with sentinel is preferred than using a standard linear search. #include <stdio.h> int linearSearch(int array[], int length) { int eleme...
Licorice asked 25/10, 2015 at 11:50

2

Solved

I have an android linear search algorithm for finding duplicate files and packed it in the function public void startSearch() I was able to run it in a separate thread like this class ThreadTest ex...
Bosomy asked 31/10, 2020 at 4:44

11

What is the difference between Linear search and Binary search?
Insert asked 31/3, 2009 at 6:21

1

Solved

I was wondering if it was possible to return different types depending on the conditions in the function: This code will work if you remove '|| bool' and the 'if/else' statements. Thanks in advanc...
Poplin asked 28/10, 2015 at 11:55

2

Solved

So there is an if-else branch in my program with about 30 if-else statements. This part runs more than 100 times per second, so I saw it as an opportunity to optimize, and made it do binary search ...
Malvie asked 8/6, 2015 at 15:56

4

Solved

Suppose I am having a Collection of object: List<String> myList = populateMyArrayList(); //Here I am having an ArrayList with 1000 elements Which is the better approach: 1 : Mergesort the...

3

Solved

I've been fooling around with a bunch of different ways of searching collections, collections of collections, etc. Doing lots of stupid little tests to verify my understanding. Here is one which bo...
Pinstripe asked 20/10, 2012 at 4:46

1

Solved

This question is about the efficiency of a linear search vs. the efficiency of a binary search for a pre-sorted array in contiguous storage... I have an application written in fortran (77!). One f...

2

Solved

I am trying to derive the average case running time for deterministic linear search algorithm. The algorithm searches an element x in an unsorted array A in the order A[1], A[2], A[3]...A[n]. It st...
Pengelly asked 26/2, 2011 at 6:53
1

© 2022 - 2024 — McMap. All rights reserved.