Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a function named getColumnsum0 that takes 1) a column index and 2) a tw

ID: 3808642 • Letter: 1

Question

1. Write a function named getColumnsum0 that takes 1) a column index and 2) a two-dimensional array with 10 rows and 15 columns and returns the sum of the elements in the specified column. 2. What is the difference (if any) between the following? Hinclude filename> #include "filename" 3. Which methods in a class are automatically generated by the compiler if not specified and when is this acceptable? 4. What code (client code, class members, friends, main(), etc.) can access a private data member? 5. What code (client code, class members, friends, main(), etc.) can call a private method? 6, Members of a class are public by default. A) True B) False 7. Given the following definition: struct MyCollection int num1; float num2; double num3; write code that declares an array of 100 elements of MyCollection and prints out the num2 value of the 3rd element.

Explanation / Answer

6) In the case, if no label is mentioned before the type in the class, then by default 'private' access specifier is taken by the compiler.

Eg: class Hello {
   private:
       int a,b;
}

8) Abstraction mainly focus on essential features on a object instead irrelevant data. Ofcourse Encapsulation leads to another advantage of data abstraction.As the data and members are combined each other, data structure is independent of implementation.

9) Dangling Pointer

   It is also a pointer which points to a memory which is not currently in the memory segment. After deleting the memory using free() function, yet the pointer variable allocates same location to previous memory.

Eg:

   char *ch = new char[5];
   *ch=90;
   cin>>ch
   delete ch;
   cout<<ch;

   // Trying to access ch, once it is deallocated.

12. O(n2)

14. index of

first =4

middle = 4

last=4

explanation:

first=0
last= 10
mid= first+last/2
mid= 0+10/2=5
then compare a[5]=59
55 is less than 59 take lower half

first=0 last=mid-1=4
new mid=0+4/2=2
a[2]=38<55 the search value is greater than a[2](38).

first=first+1=2+1,last=4

new mid=first+last/2

mid=3+4/2=7/2=3.5=3

a[3]=48<55 then

first=4 last=4 mid= 4+4/2=4

first=4
mid=4
last=4

  
18) Advantage of Double Linked List
   Double Linked List has ability to traverse the nodes in both directions i.e forward and backward. There will be two pointers in the node which make a node to traverse from either of the sides. One is 'next' pointer handles address of next node and 'prev' pointer holds address of previous node.

Eg:

   struct DLL{
       struct DLL *prev;
       int info;
       struct DLL *next;
   };

   typedef DLL *object;


21) Copy Constructor

   A copy constructor is a sppecial member function of the form: i.e
   class_name(class_name *ptr)

Eg:

class Awesomeclass{
   private:
       int a,b,c;
   public:
       Awesomeclass(int x,int,y,int z){
           a=x;
           b=y;
           c=z;
       }
       Awesomeclass(Awesomeclass &ptr){
           a=ptr.a;
           b=ptr.b;
           c=ptr.c;
       }
};

Awesomeclass awe(1,2,3);
Awesomeclass awe1(awe)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote