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, 21.06.2019 23:00
What is one of the main problems that can occur when implementing a large number of new systems within an organization?
Answers: 1
question
Computers and Technology, 22.06.2019 02:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print?
Answers: 1
question
Computers and Technology, 22.06.2019 08:10
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
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
English, 27.12.2020 05:50
question
English, 27.12.2020 06:00
question
Biology, 27.12.2020 06:00
question
Mathematics, 27.12.2020 06:00
Questions on the website: 13722362