Linear search or sequential search is a method for finding a particular value in a list, that consists of checking every one of its elements, one at a time and in sequence, until the desired one is found. Linear search is the simplest search algorithm. Its worst case cost is proportional to the number of elements in the list.
Questions tagged [linear-search]
280 questions
-3
votes
1 answer
error: control may reach end of non-void function
Please someone can explain me what's wrong why am I getting this error:
error: control may reach end of non-void function
I am trying to make a function linearsearch() taking a key and a table returning the index of an element if found.
It's…

Asmaa Asmae
- 11
- 4
-3
votes
1 answer
Templated Linear Search
Implement a function called find that takes in the following as parameters (in this order):
The object we want to find within the array
A dynamic array of ANY type
The size of the array
This function should look within the array for the element…

hicu0
- 29
- 8
-3
votes
1 answer
Value of type '1-dimensional array of String' cannot be converted to '1-dimensional array of Integer' because 'String' is not derived from 'Integer'
I am getting this error while trying to use a linear search to look for a name entered by the user into an array. Here is when I declare the array and get the input.
Public Const SIZE_ARRAY = 9
Public Sub cmdStart_Click(sender As Object, e As…

user3029128
- 127
- 1
- 1
- 7
-4
votes
3 answers
Recursive Linear Search in C debug
Problem:1
In this code if I search a number which is not in array it should display Value not found but I don't know it's not displaying that message instead everytime it's showing Found value in element -5I don't have any clue why it's happening. …

Claudia
- 33
- 4
-4
votes
1 answer
Linear search in c#
Hey guys I am a beginner at coding and I'm doing a linear search in c# and can't figure out how to make it show in what array the number was found when doing the search. It just makes it say that it's on the last array. Here's my code:
Random…

Snoodelz
- 3
- 1
- 3
-4
votes
2 answers
Implementing a Linear Search
The question:
Read up to 6 pairs of names and ages into TWO separate arrays, and use a linear search to locate a target name and to print that person’s age. The two arrays are called names and ages:
I am getting lots of errors .. I am not sure…

user3541302
- 35
- 1
- 1
- 3
-5
votes
1 answer
Which "for" loop has a better time complexity?
int i;
for(i=0;i

Alok Singh
- 51
- 1
- 10
-5
votes
2 answers
Search a string array for a specific string.
I was hoping someone could help. Well I know how to use linear search to find a numerical value inside of an array. But now I want to learn how to search a string array for a string.
For example if I have a string array of students names how could…

shrillhook
- 37
- 3
-6
votes
2 answers
C++ Linear search returning just 0
So I am a newbie in C++, I do code in JS, for some reason I can't figure out the mistake here, please help me out. thanks!
#include
using namespace std;
int search(char input, char sentence[]){
for(int i = 2; i != '\0'; i++){
…

siddarth saha
- 3
- 1