Debugging a merge sort implementation in c -
I'm debugging a single implementation of merge sort for some reason, r (merge In) is the value of nan . However, n2 (defined as (int - (r - q) ) is well defined. Why is r == Nain
#include & lt; Stdio.h & gt; # Include & lt; Limits.h & gt; # Include & lt; Math.h> Zero merge (int * a, float p, float q, float r) {float n = r - p + 1; / * Number of elements in array A * / int n1 = (int) (q - p + 1); Int N2 = (int) (r - Q); Printf ("n2 =% d \ n", n2); Int i, j; Float; Int * L, * R; For (i = 1; i & lt; = n1; i ++) {l [i] = a (for [(int (p + i - 1)];} (j = 1; j and lt ; N2; J ++) {R [j] = a [(int + q)]} l [n 1 + 1] = INT_MAX; [n2 + 1] = INT_MAX; I = 1; J = 1; Printf ("p =% f \ n", p); Printf ("r =% f \ n", r); for (k = p; k
int * l, * r; (I = 1; i & lt; = n1; i ++) {l [i] = a ([(int) (p + i - 1)];} L and R are used unused Similar to the array : < Code> int x, c, for array; ... (c = 0; c & lt; n; c ++) {scanf ("% d", and [sir] [c]);
Comments
Post a Comment