Is it possible to show the time it took a linear search to find the key you entered to find in the program?
This is the task our teacher gave us
Requirements: Write a C++ program that will do the following in sequence: Linear Search 1. Ask the user to input a positive integer value that we will denote as n. Here n represents the size of the problem space, specifically, the number of random elements. 2. For linear search, the user will input the key/value that will be searched. 3. Once the key/value is found it will display the value including the index value. 4. It will also display the time that it searched in milliseconds.
As stated in the comments of the question, I am not going to help you entirely as this is an assignment problem. Here is the starting point to do your work. Start looking to the clock()
library function of c++ in the header time.h
. That should do your work.