Hi guys! the following table i prepared was for a search algorithm where i was supposed to analyse the number of steps repeated for a number to be searched so . it has 8 elements and the k element and couple of questions i want to confirm . i need an algebriac formula for this and couple of others question related to this. your answer would be appreciated.
step 10 and total is messed up due to come prob with the text box. i hope u can view that.

Target step step 1 step 2 step 3 step 4 step 5 step 6 step 7 step 8 step 9 step 10 Total
Element 1 1 1 1 2 1 1 0 0 1 0 9
Element 2 1 1 1 3 2 1 0 1 1 0 12
Element 3 1 1 1 4 3 1 0 2 1 0 15
Element 4 1 1 1 5 4 1 0 3 1 0 18
Element 5 1 1 1 6 5 1 0 4 1 0 21
Element 6 1 1 1 7 6 1 0 5 1 0 24
Element 7 1 1 1 8 7 1 0 6 1 0 27
Element 8 1 1 1 9 8 1 0 7 1 0 30
Element k 1 1 1 k-1 k+1 1 0 k+1 1 0


Give your formula simplified for the number of steps required in 2.4 for list length k.


Enter your prediction for the number of steps it would take to find the 100th element in the list.

Your element K line is wrong, it should be 1 1 1 k+1 k 1 0 k-1 1 0 Making this a formula is trivial, what problems are you having?

thanks alot buddy. ya i knew there was some prob with tha formula . now i need the overall formula algebriac formula so that i can put any number elements that can give me the number of steps required to complete the task. thanks

Add up all the terms in your element K line, that's the formula.

will the formula be like (k+1) (k-1) = k2(square)-1 ?
plz correct me if m wrong.

You are wrong. What is 1+1+1+(k+1)+k+1+0+(k-1)+1+0?

It's clearly 1+1+1+k+1+k+1+k-1+1+99-99.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.