שאלות ותשובות - Wet 1 Frequently Asked Questions - Wet 1 Вопросы и Ответы - Wet 1 أسئلة وأجوبة - Wet 1
Note addition to question regarding array initialization in O(1) time.
Should the salary functions (AverageRequestedSalary, MedianRequestedSalary, MinimalFieldSalary, GetRequestedSalary) reflect the updates made to the average market salary? |
Yes.
|
If the function IncreaseAverageMarketSalary(DS, update) is called, should the future salaries be affected? |
No. The above function only affects the salaries of candidates in the data structure at the time it is called.
|
For the function MedianRequestedSalary(), in determining the median, should we count salaries that appear several times once or several times?
For example, if the salaries are 1,1,2,3, is 1 the median or 2? |
You should count each salary the number of times it appears. For example, in the above case, 1 is the median.
|
Can we create an array with new X[n] in O(1) time? (where X is a class) |
While new X[n] really requires O(n) time (due to the n constructors called), you may assume for the sake of the exercise that new X[n] requires O(1) time. For future reference: note that allocating an uninitialized array can be done using malloc (really in O(1) time). ------------------------------------------------------------------------------------------------------------------------------ *Note* that the bonus points for Init() in O(1) time will not be given if you use the fact that the array's entries are initialized.
|
What would be the result of calling IncreaseAverageMarketSalary twice? Would it increase all the salaries twice? |
Yes, the salaries would be increased twice.
|
We have differences in results because of precision issues of floating point numbers. What should we do? |
Keep all values you need as int-s and only when you need to, calculate using those values. For example, the average of k salaries is the sum divided by k. Also, calculate all results as double and not as float.
|
We initialized our data structure in O(1) time to get the 5 point bonus, but we get errors while running our program with valgrind of the form "Conditional jump or move depends on uninitialized value(s)". Is this OK? |
Yes, it is. Keep in mind, though, that valgrind is your friend, and make sure that this is the only cause of errors you have.
|
We used assert()s in our code. Will you compile our code with DNDEBUG or will we have to remove the assert()s before submitting the code? |
To allow you to better build your project, we will compile with DNDEBUG. If you did use assert()s, make sure that removing them by compiling with the DNDEBUG flag doesn't harm the correctness of your program. If you did not use assert()s, this will not affect compilation or running of the program for you.
|
Another possible error regarding initialization in O(1): We get another error message: "Use of uninitialised value of size 8". Is this ok? |
Yes. This particular error will also be disregarded.
|