Essay Writer » Essay Blog » Computer Science Essays Help » Coding & Algorithm Assignment

Coding & Algorithm Assignment

For this Homework, please consider writing a good code (good algorithm).

 

 

Problem statement:

 

Write a C function SELECT with the following profile:

 

int Select(int * A, int p, int r, int i)

 

where A is an array of distinct integers, p and r are the slice boundaries of the subarray being used i.e. A[p . . r] and i is the order statistic we are selecting.

 

Submit:

  • Well­-documented code source code(//comments)
  • h and select.c . The header file contains the profile and the other the implementation.

 

You may only use <stdlib.h>.

 

Hint: use dynamic programming

For this Homework,please consider writing a good code (good algorithm). It is going to be tested for a big triangle of random numbers.

 

 

Problem statement:

 

By starting from the top of the triangle below and moving to adjacent number on the row below, the maximum total from the top to bottom is 23:

 

3

7      4

2      4      6

8     5      9      3

 

That is, 3 + 7 + 4 + 9 = 23.

 

Write a C function called maxPathTotalwhich takes two parameters: The depth of the triangle and an array containing the triangle. The function returns as an integer the maximum path total.

 

The profile for this function is

 

int maxPathTotal(int, int* );

 

The triangle is represented in the array by reading the triangle from the left to the right. The example above is written

 

A = {3, 7, 4, 2, 4, 6, 8, 5, 9, 3}

 

Submit two files maxpath.h and maxpath.c containing the profile and the implementation of the maxPathTotalfunction.

 

Submit:

  • Well­-documented code source code(//comments)
  • Two files:handmaxpath.c. The header file contains the profile and the other is the implementation of the maxPathTotalfunction.

 

Last Updated on April 21, 2019

Don`t copy text!
Scroll to Top