程序代写代做代考 flex data structure cache algorithm C c++ compiler 1.

1.
T
DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING
A LEVEL 3 MODULE, AUTUMN SEMESTER
SCALABLE CROSS-PLATFORM SOFTWARE DESIGN
Time allowed ONE HOUR
Candidates may complete the front cover of their answer book and sign their desk card but must NOT write anything else until the start of the examination period is announced
Complete ALL Questions
Dictionaries are not allowed with one exception. Those whose first language is not English may use a standard translation dictionary to translate between that language and English provided that neither language is the subject of this examination. Subject specific translation dictionaries are not permitted.
DO NOT turn examination paper over until instructed to do so
Note to students:
1 point for each correct answer
0 points for incorrect or no answer
H63EEH-E1
H63EEH-E1 Turn over

2.
1. Which of the following statements is conventionally regarded as true?
A. Templated functions and classes provide a mechanism for implementing generic programming in C++.
B. Generic programming is not possible in C++.
C. Generic programming is not defined in the C++language standard, rather is an add on provided by some commercial compilers.
D. Generic programming is only a meaningful concept when one is programming in C++.
2. Given that a C++ class object defines a member function such as;
float operator()(float);
which of the following could be used to conventionally describe the nature of the object?
A. A functor.
B. An operator.
C. A float mimicker.
D. None of the above as it is illegal code syntax.
3. Given the code
class S { public:
S(int _n):n(_n){}
float operator()(int x) const {return(n*x);} private:
int n; };
A. A line of code int y=S(7)(3); is illegal syntax .
B. A line of code int y=S(7)(3); is legal syntax and evaluates y as 21, and with
inlining will probably not create an S object at run time.
C. A line of code int y=S(7)(3); is legal syntax and evaluates y as 21, and with
inlining will create an S object at run time.
D. Will compile but throw a run time exception.
4. Which of the following statements is conventionally regarded as true?
A. Parallelising any algorithm will yield a run time speed up.
B. The most effective approach to parallelising an algorithm is independent of the nature of the algorithm.
C. Not all algorithms are amenable to faster execution by parallelisation.
D. Only SIMD algorithms parallelise effectively.
H63EEH-E1 Turn over
H63EEH-E1

3.
5. Which of the following statements is conventionally regarded as true?
A. MPI is only appropriate on shared memory computers.
B. MPI is appropriate for distributed memory computers.
C. MPI uses a fork-join approach.
D. MPI cannot be used to parallelise loops.
6. A computer code evaluates the year mark by summing the individual module marks for each student on a degree. In terms of parallelising this operation, is this algorithm
A. SIMD
B. SISD C. MIMD D. MISD
7. Given the OpenMP directive
#pragma omp parallel default(shared) { // existing serial code
}
which of the following statements is conventionally regarded as true?
A. The compiler automatically parallelises the code within the {…} for optimal performance.
B. As no other directives are included, the code within the {…} will just be run on one thread always giving the same ¡°results¡± as in the serial execution case.
C. The code within the {…} will be independently run in an identical manner on a number of threads, each giving the same ¡°results¡± as in the serial execution case. D. The code within the {…} will be run on a number of threads. However, as all variables are shared between threads, it is not possible to predict the outcome without further knowledge of the code within the {…}
8. When parallelising the loop on a multi-core CPU using OpenMP or MPI
for (j=0; j
struct F {
enum {value=n*F::value}; };
//———————————————————— template<>
struct F<0> {
enum {value=1}; };
//———————————————————— main(){
cout<::value; }
//————————————————————
A. 6 is written on the screen. B. 3 is written on the screen. C. 1 is written on the screen. D. None of the above
H63EEH-E1
Turn over

5.
H63EEH-E1 11. Which of the following statements is conventionally regarded as untrue?
A. Namespaces are a more robust way to achieve the advantages of global variables.
B. Namespaces offer no advantages over using global variables.
C. std is namespace defined by the C++ standard.
D. The symbols within a namespace called SCALABLEMODULE can all be
accessed within a code if the line using namespace SCALABLEMODULE; is included at the top of the file.
12. Given a list of student names stored as strings which of the following STL structures conveniently allows an integer id number to be associated with each student name?
A. vector. B. list.
C. set.
D. map.
13. Which of the following statements is conventionally regarded as true?
A. STL vectors provide most efficient element insertion at their beginning.
B. STL vectors provide most efficient element insertion at their end.
C. STL vectors provide efficient element insertion anywhere in their range.
D. STL vectors should always be avoided and simple C style dynamic arrays
used instead.
14. Which of the following prints the first value contained in a vector, vector v;
A. cout<<*(v.begin()); B. cout<<*(v.end()); C. cout<<*(v.rbegin()); D. cout<<*(v.rend()); 15. Which is generally better to manage data that must be held in a sorted order? A. To use a list structure, calling its sort member function every time new data is added. B. To use a vector structure, calling the general (i.e. non-member) sort algorithm every time new data is added. C. To use a set data structure. D. One cannot say, it depends upon how the data is to be generated, queried and removed in the program. H63EEH-E1 Turn over 6. H63EEH-E1 16. Given that many general STL algorithms might need to swap the contents of objects being held in a data structure such as a vector, which of the following is conventionally regarded as good practice. A. Always implement the copy constructor and assignment operators for non- trivial user defined objects to ensure predictable operation. B. Always implement a swap member function for all user defined objects. C. Assume that compilers will auto generate any missing functionality for your objects in order to work predictably with the STL. D. Avoid use of the STL. 17. Consider the following STL definition template struct unary_function {
typedef Arg argument_type;
typedef Result result_type; };
This defines an object with no data or obvious functionality. Why does it exist?
A. To provide a universal object that can be used to test code possessing
functors.
B. To act as dummy object that is replaced by a real object with actual data when the program is running.
C. To provide an intellectually valuable completeness to the STL, but otherwise it has no practical purpose.
D. To act as a base class from which STL users can derive their own functor objects so that the types of the actual argument and result in the user¡¯s functor can be referred to through known names.
18. Which of the following statements is conventionally regarded as untrue?
A. The use of virtual member functions does not deteriorate run time speed.
B. The use of virtual member functions generally limits the compiler¡¯s ability to optimise the machine code as the particular variant of the function that is called cannot be determined until runtime.
C. The use of virtual member functions provides good scope for future code expansion/upgrades etc.
D. Virtual member functions can be used in multiple inheritance scenarios. H63EEH-E1 Turn over

19. Consider the following code,
template struct S;
template<> S {enum{value=10};
template<> S {enum{value=5};
template<> S {enum{value=8};
Which of the following statements is conventionally regarded as true?
A. This is an illustration of a policy class.
B. This is an illustration of a traits class.
C. This is an illustration of a factory class.
D. This is an illustration of a double dispatching class.
20. Which of the following statements is conventionally regarded as untrue?
A. Public inheritance implements the concept of ¡°Has A¡±.
B. Public inheritance implements the concept of ¡°Is A¡±.
C. Private inheritance can have uses even though it is questionable whether it implements a human being concept.
D. The difference between public, private and public inheritance concerns the visibility of base class members to derived classes.
H63EEH-E1 End
7.
H63EEH-E1