Due: Monday, October 9 2017, 11:59 pm
The purpose of this part is to understand the function handler of the C language. The library function qsort is good practice for this purpose. You are expected to use qsort to address the following question.
Given an array of random integers, sort the array in a way that the even numbers apper first and the odd numbers apper later. The even numbers should be sorted in descending order and the odd numbers should be sorted in ascending order. For example, given [3, 8, 2, 9, 1, 6], the output of your program should be [8, 6, 2, 1, 3, 9].
Download the template of the program. Read and understand the program. Implement your comparator function. Compile and run the program. The output of the program should be as follows.
The sorted array is: 12 10 8 6 4 2 0 1 3 5 7 9 11 13
In this part you'll explore both the syntax and semantics of certain types of statements in your chosen languages.
For each of your languages, complete the following tasks.
What control flow statements does the language provide? Write a program that uses all these control flow statements. Name the source file to task1.xx. For each of the statements, compare it with C if C also has it. Briefly describe the differences if there are any.
Function Type: write a program to shows how are functions treated in the language as a data type? Name the program to task2.xx. Can you assign a function to a variable? Can you pass a function to another function? If so, how do you then execute the function using the reference? Explain thes in your write-up.
Implement a general sort algorithm (e.g., quick sort, merge sort) that can be used for any type and can be used to obtain any desired order. Write a test program for your implementation, and demonstrate your algorithm works.
The haiku Python def shows how the def function adds a new symbol to the computer's state which can subsequently be called.
The submission of this project has three components:
Please note that it is your responsibility to explicitly indicate the extensions you have taken. If you take the extension in qsort of C, please indicate explicitly in the codes and README file. If you take the extensions in selected languages, please indicate explicitly in your wiki write-up or source codes and README.
© 2017 Ying Li. Page last modified: .