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, 22.06.2019 15:10
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
What is the most popular genre of video games?
Answers: 1
question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
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
Social Studies, 29.07.2019 13:30