GAMEDEV.NET
counting iterations in linear search
I am attempting to count the iterations in a linear search#include <iostream>using namespace std;int cnt = 0;int searchList(int stdList[], int numElems, int value){ int index = 0; int position = -1; bool found = false; while (index < numElems && !found) { cnt++; if (stdList[index] == value) { found = true; position = index; } index++; } cout <<
0 Comments 0 Shares 44 Views