• Support PF! Buy your school textbooks, materials and every day products via PF Here!

Recursive Ideals

1,233
1
Hello all

What is the difference between merge sort, selection sert,binary search , linear search and insertion sort? Also if you are given a recursive method, is there an easy way without tracing the method to find how many calls you need to make? For example:

Code:
public int A(int a, int b )
{
   if ( a< 0 )
           return (b);
   else if  (b < 1)
          return (a);
   else
           return(A(a-2, b-4) + A(a-1, b-2));
}
I know that you work from the left to the right. Could you somehow use the formula [tex] 2^{k} - 1 [/tex]?

Thanks a lot guys :smile:
 
1,233
1
any ideas?

thanks
 
211
0
courtrigrad said:
Hello all

What is the difference between merge sort, selection sert,binary search , linear search and insertion sort? Also if you are given a recursive method, is there an easy way without tracing the method to find how many calls you need to make? For example:

Code:
public int A(int a, int b )
{
   if ( a< 0 )
           return (b);
   else if  (b < 1)
          return (a);
   else
           return(A(a-2, b-4) + A(a-1, b-2));
}
I know that you work from the left to the right. Could you somehow use the formula [tex] 2^{k} - 1 [/tex]?

Thanks a lot guys :smile:
I personally HATE recursion of all types, mainly because it is so hard to implement and to trace. I don't think there is an easier way to find out how many calls it needs to make other than tracing the program. Since each case is different, the function will have to call itself different numbers of times. All of the sorting methods I know are bubble sort, insertion sort and quick sort. Insertion sort doesn't use recursion. It simply consists of searching through the list (could be an array, for example) for the smallest number (using for loops and if statements) and copying that number in a new array. You do this until the new array contains the numbers in order. Then, you copy the values from the nuw array to the original array. Hope this helps... :smile:
 

Related Threads for: Recursive Ideals

  • Posted
Replies
1
Views
1K
  • Posted
Replies
2
Views
1K
  • Posted
Replies
24
Views
3K
  • Posted
Replies
3
Views
3K
  • Posted
Replies
4
Views
1K
Replies
10
Views
2K
Replies
4
Views
7K
Replies
1
Views
1K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top