What is the step count for this in terms of n ?
SequentialSearch(a,x,n)
{
i=n;
a [0]=x;
while(a [i]!= x) do
i = i-1
return i
}
What is the step count for this in terms of n ?
SequentialSearch(a,x,n)
{
i=n;
a [0]=x;
while(a [i]!= x) do
i = i-1
return i
}
What is your problem, looks simple enough and I think you should be finding average or worst case behaviour complexity in O notation.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.