Question: My code has errors and i need help fixing it. Preferably in the next 30 minutes if possible. Hers's the question and code Question: the

My code has errors and i need help fixing it. Preferably in the next 30 minutes if possible. Hers's the question and code

Question:

the sequential search algorithm as given in this chapter does not assume that the list is in order. therefore, it usually works the same for both sorted and unsorted lists. however, if the elements of the list are sorted, you can somewhat improve the performance of the sequential search algorithm. for example, if the search item is not in the list, you can stop the search as soon as you find an element in the list that is larger than the search item. write the function seqordsearch to implement a version of the sequential search algorithm for sorted lists. add this function to the class orderedarraylisttype and write a program to test it.

//Header file section #include #include using namespace std;

class orderedArrayListType { //Variable declaration int a[100], i, n; public: //The following function to read the sorted array elements //Function definition void read() { /*Prompt the user to enter an input value*/ cout << "Enter the length of the array: " << endl; cin >> n; cout << "Enter the array elements in ascending order: " << endl; for (i = 0;i> a[i]; }

} void seqOrdSearch() { int j; cout << "Enter the element you want to search: " << endl; cin >> j; for (i = 0; i < n; i++) { if (a[i] > j); { /*When element in the list is greater than the search element it displays that the search item is not found*/ cout << break; } if (a[i] == j) { cout < index:"< break; } }

}

}; void main() { orderedArrayListType s; s.read(); s.seqOrdSearch();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!