You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_Notice that this uses `g++` instead of `gcc`._ This because the `gtest`
96
+
*Notice that this uses `g++` instead of `gcc`.* This because the `gtest`
92
97
is technically a C++ library, but it also works for "plain" C code, which
93
98
is all we need it for here. The `-g` flag isn't strictly necessary; it
94
99
causes a variety of useful debugging information to be included in
@@ -105,7 +110,7 @@ the `gtest` library (that's the `-l` part) when generating the executable.
105
110
:bangbang: Remember: For each problem you should at a minimum
106
111
107
112
- Pass our tests, and
108
-
- Have _no_ memory leaks, as confirmed by `valgrind`.
113
+
- Have *no* memory leaks, as confirmed by `valgrind`.
109
114
- Remove any print statements, comments, or other code that you used to debug your code before you turn it in.
110
115
111
116
Also, please don't lose your brains and forget good programming practices just because you're working in a new language. C can be quite difficult to read under the best of circumstances, and using miserable names like `res`, `res2`, and `res3` doesn't help. *Use functions* to break up complicated bits of logic; it's really not fun when a group turns in a solution that is one huge function, especially when there are several instances of repeated logic.
@@ -134,7 +139,7 @@ void mergesort(int size, int values[]);
134
139
```
135
140
136
141
This is a
137
-
_destructive_ sorting operation, i.e., it should alter the array that it's
142
+
*destructive* sorting operation, i.e., it should alter the array that it's
138
143
given by rearranging the elements in that that array. Note that since C
139
144
doesn't know how large arrays are, we pass in
140
145
the size as an argument.
@@ -156,7 +161,7 @@ as you certainly wouldn't want a common operation like sorting to leak a
156
161
bunch of memory every time it's called. Again, `valgrind` should be your
157
162
friend.
158
163
159
-
:bangbang: C does (now) support _dynamically_ allocate
164
+
:bangbang: C does (now) support *dynamically* allocate
160
165
arrays for local use without using `malloc` or `calloc`.
161
166
For this lab **do not do that**.
162
167
Make sure that in your recursive calls to `mergesort` that you use `calloc`
@@ -183,10 +188,10 @@ is the length of the corresponding sub-array in `values`. If
183
188
`sizes[3]==10`, for example, then `values[3]` will be an array of 10
184
189
integers.
185
190
186
-
_Note how inherently icky it is to have to pass all this bookkeeping
191
+
*Note how inherently icky it is to have to pass all this bookkeeping
187
192
information around, and how many wonderfully unpleasant errors can
188
193
result from doing this incorrectly. It's a **lot** safer if arrays know
189
-
how big they are._
194
+
how big they are.*
190
195
191
196
`array_merge` should then generate a single sorted list (small to large) of the
192
197
unique values (i.e., no duplicates) in `values`. Since we haven't yet
0 commit comments