- #36
I like Serena
Homework Helper
MHB
- 16,336
- 258
evinda said:Or do I have to add at the code something else? (Thinking)
Weird.
I thought I had already answered in this thread.
evinda said:So, would I just have to replace the lines 7-12 with [m]Nth(A,i+1).data = Nth(A,i).data[/m] ? (Thinking)Code:1.Insertion Sort (NODE *A){ 2. int key, i, j; 3. for(j=2; j<n+1; j++){ 4. key=Nth(A,j).data; 5. i=j-1; 6. while(i>0 && Nth(A,i).data>key){ 7. Nth(A,i+1).data = Nth(A,i).data 8. } 9. return A; 10.}
Yes, but you still need lines 8-10:
Code:
8. i=i-1;
9. }
10. A[i+1]=key;