vendredi 27 avril 2018

Big O of Switch statement having function calls in its Cases?

How can we calculate Big O of switch statement whom are having function calls in there cases. that Function can be the Function in whom the switch statement is present and can also direst to another function whom can send it back to the same Switch statement.

void ifpascorrectSwitch(int *currentbalance) {

cout << "\n\n";
cout << "Current balance = £" << *currentbalance << endl;
string casee;
cout << "Enter any of the below option\n"
        "1 for Deposit cash \n"
        "2 for Withdraw cash\n"
        "e for Quiting the application\n"
        "= ";


cin >> casee;
if (casee.length() == 1) {
    const char *k = casee.c_str(); // character inter to a c string

    switch (*k) {

        case '1':
            cout << "1 Deopist cash \n";
            Depositcash(currentbalance);          

//Deposit is another function call whom can can come back to this function // and have this switch menu again because of bellow given //ifpascorrectSwitch(currentbalance) which is function call of the current //function

            ifpascorrectSwitch(currentbalance);

            break;
        case '2':
            cout << "2 Withdraw menu\n";
            WithdrawCash(currentbalance);
            ifpascorrectSwitch(currentbalance);

            break;
        case 'e':
            cout << "r is working";
            break;
        default:
            cout << "Default switch wrong entery";
            ifpascorrectSwitch(currentbalance);
            break;
    }

} else {
    cout << "Wrong entery please try again";
    ifpascorrectSwitch(currentbalance);
}   }

All other function call other then ifpascorrectSwitch(currentbalance)which is current function call are having same scenario of switch stament. almost.

If only someone could help me atleast undesrtanding this Switch statement Big O calcultaion.

Aucun commentaire:

Enregistrer un commentaire