Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with code and text file, C++ Program 1 - Linear Search Algorithm In Computer Science, it is often very important to be able

Please help with code and text file, C++

image text in transcribedimage text in transcribed

Program 1 - Linear Search Algorithm 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, please 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 79) was located at index 44 Number 2 74) was not in the file. Number 3 56) was not in the file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago