diff options
author | Haidong Ji | 2022-04-15 15:51:30 -0500 |
---|---|---|
committer | Haidong Ji | 2022-04-15 15:51:30 -0500 |
commit | 442a49ad5a48d417345959b903ae6a6d32d55759 (patch) | |
tree | c7127bb497e5e439018b1915e0136eec2c9cb124 /16_subseq/README |
Excellent fundamentals and displine training, many tools and techniques
exercises: gdb, emacs, valgrind, git
Diffstat (limited to '16_subseq/README')
-rw-r--r-- | 16_subseq/README | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/16_subseq/README b/16_subseq/README new file mode 100644 index 0000000..9966603 --- /dev/null +++ b/16_subseq/README @@ -0,0 +1,34 @@ + + 1. Create a file called maxSeq.c and write the function: + size_t maxSeq(int * array, size_t n); + + which returns the length of the maximum increasing contiguous + subsequence in the array. The parameter n specifies the length + of the array For example, if the array passed in were + + { 1, 2, 1, 3, 5, 7, 2, 4, 6, 9} + + this function would return 4 because the longest sequence + of (strictly) increasing numbers in that array is 1, 3, 5, 7 + which has length 4. Note that 1,3,5,7,9 is an increasing + subsequence, but is not contiguous (finding discontiguous + ones efficiently takes techniques we haven't learned yet). + + Note that the subseqence does not need to increase at a + constant rate (or follow any other pattern besides being strictly + increasing). 2, 4, 67, 93, 94, 102 would be a valid increasing + sequence of length 6. + + Also note that the series consisting of one element is considered an + increasing sequence of length 1. + + +2. Compile and test your code using the test-subseq.c you wrote + previously. (as before, compile the .c files separately, and link + them together). + +3. Submit your code for maxSeq.c + + +Hint: + Can you abstract a complex step out into a simple function? |