Reference no: EM13854473
Problem 1. This program will be graded based on whether the required functionality were implemented correctly instead of whether it produces the correct output, for the functionality part (80% of the grade).
Modify selection_sort.c so that it includes the following functions:
void selection_sort(int *a, int n);
int *find_largest(int *a, int n);
void swap(int *p, int *q);
selection_sort function: it should call find_largest function and swap function.
find_largest function: when passed an array of length n, the function will return a pointer to the array's largest element. The function should use pointer arithmetic - not subscripting - to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.
swap function: when passed the addresses of two variables, the function should exchange the values of the variables:
swap(&i, &j); /* exchange values of i and j */
Your program will call find_largest function and swap function in selection_sort function.
Problem 2.
A vector is an ordered collection of values in mathematics. An array is a very straightforward way to implement a vector on a computer. Two vectors are multiplied on an entry-by-entry basis, e.g. (1, 2, 3) * (4, 5, 6) = (4, 10, 18).
Write a program that include the following functions. The functions should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the functions.
void multi_vec (int *v1, int *v2, int *v3, int n);
int comp_vec(int *v1, int *v2, int n);
The multi_vec function multiplies vectors v1 and v2 and stores the result in v3. n is the length of the vectors.
The comp_vec function compares v1 and v2, return 1 if vectors v1 and v2 are equal (their corresponding components are equal), and 0 otherwise. n is the length of the vectors.
In the main function, ask the user to enter the length of the vectors, declare two arrays with the length, read in the values for two vectors, and call the two functions to compute the multiplication and comparison of them. The main function should display the result.
Enter the length of the vectors: 5
Enter the first vector: 3 4 9 1 4
Enter the second vector: 5 7 2 6 8
Output:
The multiplication of the vectors is: 15 28 18 6 32
The vectors are not the same.
Gender and culture paper
: Students will complete a 5 page paper (double spaced, 12pt., Times New Roman) paper on how sex and/or gender operate in a specific culture or subculture. Any culture is acceptable as long as conducting the research does not pose harm to you or anyone..
|
Discuss the classification of functionalities used
: Discuss the classification of functionalities used in this article and leading vendors. Why are these classifications used and what do they mean
|
Briefly state how the cultures of both civilzations
: Why did both the Mesopotamian and Egyptian civilzations emerge where they did, and what do you think were the biggest contributions of these two civilizations by 600 B.C.E. Briefly state how the cultures of both civilzations were preserved and spr..
|
What are risks associated with nikes core marketing strategy
: What are the pros, cons, and risks associated with Nike"s core marketing strategy?
|
Compute the multiplication and comparison of them
: Compute the multiplication and comparison of them. The main function should display the result.
|
A journalist was interested in college students
: A journalist was interested in college students' knowledge of current events. The journalist compared a large group of college students to the general public using a questionnaire about recent items in the news. In this study, she tested large number..
|
Describe in detail a bad decision
: Describe in detail a bad decision that you made at work in the past, or any work-related decision that you wish you could "do over." Be sure to indicate your career field, as you describe this decision. Analyze that bad decision using Steps 1-7 of th..
|
Financial statements and the closing process
: The information needed to prepare the income statement is found in the Income Statement columns of the work sheet. Revenue is shown first, followed by an itemized and totaled list of expenses. Net income may be calculated or copied from the Income..
|
Design a raptor program that uses an array
: Design a Raptor program that uses an array to store 5 values entered by the user and then displays the numbers in reverse order. Use two loops: one for reading the user entered values into the array
|