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

1. Quadratic Equation: Design and write a C++ code that solves a quadratic equat

ID: 3801893 • Letter: 1

Question

1. Quadratic Equation: Design and write a C++ code that solves a quadratic equation ax^2 + bx + c = 0. Please use class and object definitions and do not use procedural style. Let the roots of be and ax^2 + bx + c = 0 be p and q. Show that the following: p + q = -(b/a) and pq = (c/a), for at least 5 different and non-trivial of values of a, b, c. Make sure that you address that complex numbers as objects.

Notes: Please use class of real numbers and class of complex numbers. Also, make sure that you add relevant member functions in solving the above conditions. When p and q are complex numbers then invoke complex addition and multiplication. When p and q are real then invoke binary addition and multiplication of real numbers. Show for both scenarios.

2. Matrix Operations: Design and write C++ codes that solves the following:

1. Matrix Addition (2x2, 3x5)

2. Matrix Multiplication (2x2, 4x4).

Show your results with at least two examples of each. Use C++ objects.

Note: You will create NxM matrix where N = number of rows and M = number columns that are specified by the user. So, write a generic class of matrix that accepts user-defined N and M as input parameters and generates a random matrix. Each cell of the matrix is a random number. Example: Consider a 2x2 matrix: A = [23.1, 54.6 98.2, 87.2 ] Where A[i][j] is a randomly generated number between (0,99). Consider a 3x3 matrix: A = [23.1 54.6 12.4 98.2 87.2 16.3 15.7 31.8 71.2] Where A[i][j] is a randomly generated number between (0,99). Thus generate a random matrix A. Similarly you can generate matrices of other dimensions by specifiying user values N and M. Perform your operations on these matrices.

3. Sorting

1. Implement the quicksort algorithm in C++ code

2. Suggest creative and original variations that can make this algorithm better. It should have code of your tryouts. [10 points]

4. Recursion

Tower of Hanoi (https://en.wikipedia.org/wiki/Tower_of_Hanoi)

1. Implementation

2. Detail explanation of how it works

Implement the following recurrence relations

o F(n) = F(n-1) + F(n-2) F(0)=0; F(1)=1; // Fibonacci Series

o F(n) = n^2 + F(n-1) F(0)=0; // sum of squares

Print all n-digit strictly increasing numbers

Given number of digits n in a number, print all n-digit numbers whose digits are strictly increasing from left to right

Examples:

Input: n = 1

Output: 0 1 2 3 4 5 6 7 8 9

Input: n = 2

Output: 01 02 03 04 05 06 07 08 09 12 13 14 15 16 17 18 19 23 24 25 26 27 28 29 34 35 36 37 38 39 45 46 47 48 49 56 57 58 59 67 68 69 78 79 89

5. Dictionary

1. Design a scalable dictionary that stores an English word and its meanings.

2. Implementation

3. Suggest a creative solution

Explanation / Answer

I am writing solution for problem 3 i.e., quick sort:

#include <iostream>
using namespace std;
int partition(int[],int,int);
void quickSort(int[],int,int);
int partition(int a[],int l,int u)
{
    int v,i,j,temp;
    v=a[l];
    i=l;
    j=u+1;
    do
    {
        do
            i++;
        while(a[i]<v&&i<=u);
        do
            j--;
        while(v<a[j]);
        if(i<j)
        {
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }while(i<j);
    a[l]=a[j];
    a[j]=v;
    return(j);
}
void quickSort(int a[],int left,int right)
{
    int j;
    if(left<right)
    {
        j=partition(a,left,right);
        quickSort(a,left,j-1);
        quickSort(a,j+1,right);
    }
}
int main()
{
    int a[100],n,i;
    cout<<"*********** Quick Sort Programme ************"<<endl;
    cout<<"No.of Elements you want to enter in arry: ";
    cin>>n;
    cout<<endl<<"Enter array elements: "<<endl;
    for(i=0;i<n;i++)
    {
        cout<<"array["<<i<<"]: ";
        cin>>a[i];
    }
    quickSort(a,0,n-1);
    cout<<endl<<"Array after sorting:";
    for(i=0;i<n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    return 0;      
}

Note: In the above mentioned code i am using two methods those are partition() and quickSort(). Please verify once