Expert Answers

1. a) What is the difference between a C++ Class and a C++ Struct?
b) Write the C++ code for Struct of the name ‘BankAccount’ with members ‘account_no’ (integer), ‘balance’ (float), and ‘interest_rate’ (double).
c) Given the above, write the C++ statement that declares a bank account for ‘TU_Account’ of type ‘BankAccount’.

2. Give the Big O for the following:
a) sum=0;
for (i = 1; i <= n*n; i++)
sum = sum + 1;
b) sum=0;
for (i = 1; i <= n; i++)
sum = sum + n;
c) sum=0;
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j*=2)
sum = sum + 1;

3. Give the postfix, prefix and infix expressions from the following expression tree.

4. a) Write in no more than three C++ code statements the declaration of a fixed C integer array of size 20.
b) Write in no more than three C++ code statements the declaration of a dynamic integer array of size 20.