subject

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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:00
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
How do you know if the website is secure if you make a purchase
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
It is not necessary to develop strategies to separate good information and bad information on the internet. true or false
Answers: 1
You know the right answer?
In computer science, it is often very important to be able to locate a specific data item inside a l...
Questions
question
Computers and Technology, 01.12.2019 09:31
Questions on the website: 13722362