[SOLVED] CECS342-Assignment 1

20.99 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

Homework 1

  1. Browse the Haskell website: https://www.haskell.org
  2. Read (at least the first two chapters of) “Learn You a Haskell for Great Good!”:
http://learnyouahaskell.com/chapters

Lab Assignment 1

  1. Remember the sorting algorithms quick sort (Tony Hoare, 1959) and merge sort (John von Neumann, 1945).
  2. Write each sorting algorithm in C and in Haskell by implementing the following functions:




void qsort2(int *a, int n);  // quick sort array a with n elements in place in C
void msort(int *a, int n);   // merge sort array a with n elements in place in C





qsort :: Ord a => [a] -> [a]  — quick sort a list in Haskell
msort :: Ord a => [a] -> [a]  — merge sort a list in Haskell


  1. Write a brief comment for every line of your code explaining what it does.
  2. In a separate text file write a few sentences explaining how and why the C and Haskell implementations of the same algorithms differ.
  3. Write a simple main function (one in C and one in Haskell) to test your sort functions with the input sequence 4, 65, 2, -31, 0, 99, 2, 83, 287, 1 and print the result to the console.
Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.