CSC2720 – HW2 Solved

$ 20.99
Category:

Description

For example, if our _le input.txt is:
1
6
1 2 3 4 -2 -3
then we should print:
2
since there are two pairs that sum to 1: 3+(-2) and 4+(-3). As another example, if input array is:
3
4
1 2 3 4
then we should print:
1
since there is one pair that sums to 3: 1+2
After you finish your code, please test
10
9
1,2,3,4,5,6,7,8,9
2) (30 points )Given three arrays arr1, arr2 and arr3, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Meanwhile, all elements in arr2 are also in arr3.
Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2.
Elements that do not appear in arr2 should be placed at the end of arr1 in ascending order. Meanwhile, Elements for arr3 that do not appear in arr2 should be placed at the front of arr1 in ascending order. For example, arr1:[2,4,3,5,6,1,9] arr2: [2,4,3] arr3: [2,4,3,11,8,13]
the output should be [8,11,13,2,4,3,1,5,6,9] since [2,4,3] shared by arr1, arr2,arr3. Elements [11,8,13] should have a ascending arder in front of arr1, and elements [5,6,1,9] have an ascending order at the end of arr1.
You can define your input arrays.
3) (20) Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers. Both even and odd numbers should follow an ascending order in the sorted array.
Return the sorted array For example,
input: [1,4,2,3] output: [2,4,1,3]
You can defined your input array.

Reviews

There are no reviews yet.

Be the first to review “CSC2720 – HW2 Solved”

Your email address will not be published. Required fields are marked *