Beruflich Dokumente
Kultur Dokumente
Exercise 1
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
• Accept two arrays, A1 and A2, each of size 10, from the
user.
• Declare an array, result, of size 20.
• Set i = j = k = 0.
• If (A1 [i] <= A2 [j]): // Insert the smaller element in the
// result array
a. result [k] = A1 [i]
b. Set k = k + 1
c. Set i = i + 1
• If (A1[i] > A2[j]): // Insert the smaller element in the
// result array
a. result [k] = A2 [j]
b. Set k = k + 1
c. Set j = j + 1
1. Set i = i – 1.
2. Go to step 6.
1. If j < 3, go to step 6.
2. Set i = i + 1.
3. If i < 3, go to step 5.
4. Display result.