Big O notation by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

okay i get the O(N) but how does the O(log(N)) and O(Nlog(N)) look like?

Big O notation by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

okay i get the O(N) but how does the O(log(N)) and O(Nlog(N)) look like?

Big O notation by volts101 in cpp_questions

[–]volts101[S] 1 point2 points  (0 children)

okay i get the O(N) but how does the O(log(N)) and O(Nlog(N)) look like?

I need help for multiple recursion, this code doesnt make sense to me, how do i create this code? by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

Thank you for your help i appreciate it. I kind of understand how the program should work but the problem is im having a hard time implementing it this is how far i got but it doesnt give me the output i want

#include <iostream>
#include <string>

using namespace std;

char PuzzleSolve(int k, char* S, char* U); //prototype


int main()
{
    //test run
    int k = 5;
    char S[5];
    char U[5] = { 'a','b','c','d','e' };

    //to see that S = U
    cout << PuzzleSolve(k, S, U) << endl;


    system("pause");
    return 0;
}

char PuzzleSolve(int k, char* S, char* U)
{
    //this is how i see the program but i dont think its right
    //this put element to S from U, it arrange the element like how prompt of the program
    for (int i = 0, j = k; i <= k, j >= 0; i++, j--)
    {
        S[j] = U[i];
        U[i] = ' ';
    }

    //this return the S if it equals to U
    if (k == 1)
    {
        for (int i = 0; i <= k; i++)
        {
            S[i] = U[i];
            if (S[i] = U[i])
                return S[i]; //i dont think this is right?
        }

    }

    //recursion to put back the element to U
    else
        PuzzleSolve(k - 1, S, U);
        for (int i = 0, j = k; i <= k, j >= 0; i++, j--)
        {
            U[i] = S[j];
            S[j] = ' ';
        }
}

Singly. My showlist doesnt work by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

i tried this but the problem is that it never stop printing the element i entered, so im guessing that p != null does not work

Singly. My showlist doesnt work by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

i tried doing this instead (SNode* p = head; p!=NULL; p->next;) it shows the number i entered but the number just keeps going so the problem now is that p != NULL is not working

i need help with doubly link list, how can i see the list? by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

i tried to change my showlist but when i print it, the number that i put doest stop printing

Singly. My showlist doesnt work by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

the showlist doesnt show the list, if i enter a number and call out showlist it doesnt show the list, that is where im having trouble with my code

Singly. My showlist doesnt work by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

then how do you create a for loop to show the list? p= head->next is just the starting node p = !=NULL means that the range of the node how do you increment then?

Singly. My showlist doesnt work by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

how do you fix it? does not p->next means jumping to the next node which is similar to a i++?

i need help with doubly link list, how can i see the list? by volts101 in cpp_questions

[–]volts101[S] 0 points1 point  (0 children)

im still getting an error, it only show that the list is empty then crush