Computers and Technology

In computer science, it is often very important to be able to locate a specific data item inside a list or collection of data. algorithms that perform this function are called searching algorithms, and there are many such algorithms in computer science.

although it is inefficient, one of the most common searching algorithms is called linear search. in linear search we have a set of data that serves as the standard, usually stored within an array, and a separate value that we are searching for within that data set. we’d like to know whether the value is within the data set, so we scan through the data set looking for it, one element at a time, starting at the beginning of the array and proceeding, if necessary, to the very last element. if the value is found within the standard array, we return a number indicating its index position within the array. if the value is not found, we return an error indicator, oftentimes a -1, that indicates the value was not in the data set.

for this problem, implement a linear search algorithm that performs this function. you will be given two input files, "lsstandard. txt" and "lstest. txt". the lsstandard. txt file contains integer values against which we are searching. (there will be no more than 100 of these.) the lstest. txt file contains a set of numbers that we are trying to locate within the standard data set. (there will be no more than 50 of these.) read both of these into separate arrays and then determine which of the numbers in the lstest file are included in the lsstandard data set by using a linear search algorithm. have your program print out a report (to the console only is sufficient) that indicates whether the number was found or not.

your output should look something like:
number 1 ( 34) was located at index 15.
number 2 ( 74) was not in the file.
number 3 ( 56) was not in the file.
number 4 (103) was located at index 75. etc.
note that the number for which we searched is indicated in parenthesis in the report. the "index" number refers to the index of the element within the lsstandard data.
your function header for the linear search function should look like: int searchlist(int stdlist [], int numelems, int value)
you’ll notice that this function accepts an array as input parameter. that array, called "stdlist" in the parameter list, will be the array that contains the standard data set. the parameter "numelems" is the number of elements in that array, and the parameter "value" is the element that we are searching for.
your function should search for "value" within the "stdlist" array and return one of two answers: (a) a -1 if "value" is not in "stdlist", or (b) the index position of "value" within "stdlist" if "value" is in "stdlist". (this should be a number between 0 and (numelems- your program should then use that result to determine what should be printed in the report

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, dondre54
in 2007, floridians died in alcohol-related collisions.a.  501b.  1,051c.  5,015d.  10,839
Answers: 1
image
Computers and Technology, 22.06.2019 16:30, buky0910p6db44
Corey set up his presentation for delivery to his team. the information he had to convey was critical to their job performance. he knew he would need a lot of time to explain each point
Answers: 3
image
Computers and Technology, 22.06.2019 22:10, Metlife
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, paulusl19
The first screen you see when you open word2016 what is called?
Answers: 1
Do you know the correct answer?
In computer science, it is often very important to be able to locate a specific data item inside a l...

Questions in other subjects:

Konu
Mathematics, 14.01.2021 18:40
Konu
Mathematics, 14.01.2021 18:40
Konu
Mathematics, 14.01.2021 18:40
Konu
Mathematics, 14.01.2021 18:40
Konu
Mathematics, 14.01.2021 18:40