-
Where to begin?
Here is the question:
Write a recursive lookup function to search an array in sorted order. Write a program in C to test your function. Use random() to fill array a[] of size n, and use bubble_sort() to sort the array. The function call look_up(v, a, n) should be used to look for the value v in the array a[]. If just one of the elements of the array, say a[i] has the value v, then i should be returned. If two or more of the elements of the array have the value v, then the index of any one of them in an acceptable answer.
Can someone point me in the right direction on where to start? Thank you.
-
-
I'm not asking for the answer to the question, I just want just help on how to start going about solving this.
-
Have you ever written a program before? This is usually a good start:
Code:
int main(void)
{
// your code here
return 0;
}
Read your text book and class notes. We have tutorials here, and Google has lots more. Work your way from beginning to end. Do the practice problems until you understand user input, arrays and function calls at the very least. Start writing your code, get as far as you can and come back when you're really stuck, not lazy stuck (to quote Tater). You need to put in some serious effort before you get serious help.
-
Can you write random()?
Can you write bubble_sort()?
Can you write look_up(), if you ignore the "recursive" bit (that is, just make it a simple loop)?
You should be able to think about each one in turn without worrying too much about the whole picture.
Plus, it would go a really long way to showing us that you're making an effort, and not just dumping your assignment on us, with no real indication as to what is really bothering you about it.