CPP

CPP

C Style Algorithms has 9 Questions
Pick out the in correct type of function in header file.

Partitions
Sort
Merge
Join
What type of algorithm is not available in creating our own STL style algorithms?

copy_if()
remove_copy_if()
sort
None of the mentioned
What is meant by hash tables in C++?

Array data structure
Keyed array data structure
Data structure
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int main ()  
  6.     {
  7.         int myints[] = {10, 20, 30, 5, 15};
  8.         vector<int> v(myints, myints + 5);
  9.         make_heap (v.begin(), v.end());
  10.         pop_heap (v.begin(), v.end());
  11.         v.pop_back();
  12.         cout << v.front() << '\n';
  13.         return 0;
  14.     }

10
20
30
5
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     bool myfunction (int i, int j)
  6.     { 
  7.         return (i < j);
  8.     }
  9.     struct myclass {
  10.     bool operator() (int i, int j)
  11.     {
  12.         return (i < j);
  13.     } 
  14.     } myobject;
  15.     int main () 
  16.     {
  17.         int myints[] = {10, 9, 8};
  18.         vector<int> myvector (myints, myints + 3);
  19.         sort (myvector.begin(), myvector.begin() + 2);
  20.         sort (myvector.begin() + 1, myvector.end(), myfunction);
  21.         sort (myvector.begin(), myvector.end(), myobject);
  22.         for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
  23.             cout << ' ' << *it;
  24.         return 0;
  25.     }

8 9 10
10 8 9
9 8 10
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int main () 
  6.     {
  7.         int first[] = {5, 10, 15};
  8.         int second[] = {50, 40, 30};
  9.         vector<int> v(4);
  10.         vector<int> :: iterator it;
  11.         sort (first, first + 3);
  12.         sort (second, second + 3);
  13.         it = set_symmetric_difference (first, first + 2, second, second + 2, 
  14.         v.begin());
  15.         v.resize(it - v.begin());
  16.         for (it = v.begin(); it != v.end(); ++it)
  17.         cout << ' ' << *it;
  18.         return 0;
  19.     }

5 10
30 40
50 40
Both a & b
How many parameters are required for sort_heap function?

1
2
2 or 3
3
What is the use of includes function in c++?

Compares two ranges of data
Compares two sorted ranges of data
Includes a new element in the range
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     bool myfunction (int i,int j) 
  6.     {
  7.         return (i < j);
  8.     }
  9.     int main () 
  10.     {
  11.         int myints[] = {9, 8, 7, 6};
  12.         vector<int> myvector (myints, myints + 4);
  13.         partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end());
  14.         partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
  15.         myfunction);
  16.         for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
  17.             cout << ' ' << *it;
  18.         return 0;
  19.     }

6 7 8 9
9 8 6 7
6 7 9 8
None of the mentioned