Dean_williams

Did you face a problem or an error in the code given?

If you did, post the error noted here for us to provide our perspective on the problem.

If you want to get an understanding on measuring time complexity, you can refer to the post i have made earlier that relates to this problem at the below link:-
Click Here

Dean_williams

I have used Prey client for more than a year. I havent came across a situation where my laptop was stolen. However, whenever the Prey client communicates to the Prey server through the network, a notification that the device made contact with server will be sent to your email.

But, i also use True Crypt as an added measure to encrypt my drive. Therefore, i dont rely completely on Prey to protect my PC as i do a regular backup of my data.

If the thief is a smart person, the person may just hard reset to factory settings before connecting to the network, then you wouldnt know what happened to your device. Consider regular backup of data, and drive encryption as an added measure.

Dean_williams

Consider Avast antivirus free version with Comodo Firewall. I have been using these two together for more than two years and no issues noted so far.

One more thing to note is that the programs need to be compatible with each other. The abovementioned combo worked fine for my windows. Besides, too many programs that serve the same purpose is not good and it may make the pc unstable.

Dean_williams

For case structure, you can try to do switch statements. I will give you a brief idea to complete your pseudocode. I don't see why return statement is needed as the method is declared as void. The method sum() and difference() doesn't return anything to main() as the value is printed in the function itself.

Next thing i see is the product() method that returns its computation to a variable declared in the calling method which in this case is the main() method. Try asking the user for option to be selected. For example, 1 for sum, 2 for difference and 3 for product. whatever the user input, use the switch case to execute the method according to user selection. For product() method, set a variable in main method like int product. set the value of product to be equivalent to the value returned from product() method. then print the value of product variable.

Another way of doing this is using the easy if else statement. Ask the user what he/she wants to do then execute the method. Since ther are only 3 choices for user, if else statement would be okay. A switch statement might make it look more readable and organised. Good luck :)

Dean_williams

Have you attempted to create the functions? If you are not clear on how to create the function, try creating a pseudocode. Easier way of completing this problem is by playing this game with another player to observe how this function would perform. Good Luck to you. :)

Dean_williams

If you have attempted something on your own, post them here. If you want to get some idea, i will provide you some basic idea to start with. If you want to obtain data from your database, you must connect to the database in PHP. Search on these commands to understand how the database is connected.

mysql_connect();
mysql_select_db();
mysql_query();
mysql_close();

Next is to create your form where the dropdown list would show the data from the database. To do this, make sure the connection is done right. Data can be fetched in a numeric manner or in an associative array. Search how to do this in database. As you are selecting a value from the dropdown list, you can assign the value to a new variable that can be passed to List C after you have pressed submit button.

This is a basic idea i can provide with. Good Luck :)

Dean_williams

If you are looking to learn more about JUnit, go through these links that I hope will be useful for you.
Click Here
Click Here
Click Here
Click Here
Click Here

Hope this helps :)

Dean_williams

Post your full code for us to find the error. Value of prix and $row_panier[] is not known.

Dean_williams

I will give you some idea to start with. If you want to display the results in a frame using GUI coponents, go through JFrame of Swing component in Java. Your JFrame will show the interface where your code is run and show the results. Go through JList and JScrollPane to display the results.

If you want to display the results in a frame in a simple way, go through JOptionPane.showMessageDialog to show all the results. See here on StackOverflow on similar problem: Click Here. Good Luck :)

Dean_williams

I have updated my code as the one I post was wrong. Its working. All I had to do is to complete the insertion into the tail and checking the value of the first node with the second while i iterate the list until it is lesser than the list size.

Dean_williams

Thank you for the links....if a newnode is added using a malloc() and the insertion is done in the beginning, so the previous should be null and head->next would be null, right?...How about the next insertion? I did a bit but not working....not sure if is correct.

typedef struct nodes
{
    int value;
    struct nodes *prev;
    struct nodes *next;
}node;

node *newnode, *current=head,*previous;
    printf("\nHow many integers to insert? ");
    scanf ("%d", &num);
    {
        for (i=0;i<num;i++)
        {
            printf("\nEnter integer %d: ",i+1);
            scanf("%d", &number);
            newnode=malloc(sizeof(node));
            if (newnode==NULL)
            {
                printf("\n\nUnable to allocate memory");
                exit(EXIT_FAILURE);
            }
            newnode->value=number;
            newnode->next=current;
            if (head==NULL)
            {
                head=newnode;
                head->prev=NULL;
                previous->next=newnode;
            }
            else
            {
                newnode->next=head;
                head->prev=newnode;
            }
            newnode=newnode->next;
        }

Dean_williams Professional poster

Hello. I am having a tough time understanding the concept of double linked list. For now, i understand double linked list has 2 links, one forward and another one previous. data is in the middle. when inserting must check where to insert. if previous is equal to null, then can insert it to previous. Set the previous to be equal to the newly allocated node. I am looking to do a bubble sort using double linked list. I want to understand the concept first then I can do it. Can someone give some usefule links or explain me the concept? Thank you.

Dean_williams

Check it here
http://dotnetslackers.com/Community/files/folders/data-structures-and-algorithms/entry28722.aspx

and here
http://ebookee.org/C-Data-Structures_65405.html

More information can be found by searching google for data structures in C.

Dean_williams

For the typedef, the older name would be

int Length;

after giving the user defined name like

typedef int Length newLength;

instead of using int Length, now you are able to use newLength.

If the typedef is like the one you state

typedef int Length;

then the int type variables can be represented with the user defined name which is Length.
For example:

Length value;
Length len[];

this is referring to the int type which you have defined.

Dean_williams

Just check the spelling. Go through the whole code. Check the classes and initiation of variables. Will work.

Dean_williams

I will try to explain the concept. First accept four integers input:

int num1,num2,num3,num4;

printf("Enter 4 integers seperated by space: ");
scanf("%d %d %d %d",num1,num2,num3,num4);

After this, do the function which accepts the two parameters.
For example, you are comparing two integers, num1 and num2:

bigger(num1,num2);

In the function, have a if else statement that checks the two parameters. If num1 is more than num2, then put:

return num1;

This will return the biggest number. Assign the returned value to an int parameter. Put a printf statement if that is necessary. The printbiggest function will compare the four input using the if else statement and determine the biggest value of them. The function bigger() can be called in this function and assigned to an int variable. Then printf it.

on93 commented: thans +0

Dean_williams

Complexity usually measured in terms of how the amount of a resource (time or space) required to run a program increases as the size of the program input increases.
Most common measure of complexity is the amount of time the program takes to run. If the algorithm of a program takes longer than the polynomial time(explained later), it is said to be intractable. If the algorithm takes lesser or within the polynomial time, it is said to be tractable.

O(1)         = constant
O(log a n)   = logarithmic
O(n)         = linear
O(n log a n) = “n log n”
O(n^2)       = quadratic
O(n^3)       = cubic
O(n^r)       = polynomial
O(a^n)       = exponential
O(n!)        = factorial

Anything that is larger than exponential is said to be exponential time algorithm or simply intractable. So, from constant to polynomial time algorithm can be classified as tractable while after polynomial can be classified as intractable. As the program goes down from constant to factorial, it has a reduced efficiency. I will provide an example of Big O notation.

(1) for(i = 0; i < n; i++)
    {
(2)     for(k = 0; k < n; k++)
        {     
(3)        A[i,k] = 0;
        }
    }

Line (3) takes O(1) time

Line (2) takes O(n) time, since it executed according to the value of n. If the value of n is 5, the inner loop goes 5 times.

Line (1) takes O(n^2) time. If the the value of n is 2, the outer loop executes once and the inner loop ...

Dean_williams

MVC stands for Model View Controller where the model consist of application data, view consist of the GUI and controller consist of input acceptance and mediation. Controller accepts input and passes to the model to process. The model passes the output to the view as an output presentation.

Dean_williams

I have used strtok() to get each strings in the file using while and fgets function and assigning to different initialised arrays using comma as delimitter. It works. Thanks for your replies.

Dean_williams

Thanks for your reply. My main problem is to copy contents from file and assign it an array. I have tried to implement fgetc but my program allows the user to accept new person with their details. So the program is not limitted to a specific size. After i copy the contents of the file to a array, i will tokenize the array by using the comma present in the file as the delimitter and assign the tokenized content to a specific variable like person_name. This is my new code:

    FILE *check = fopen("check.mrk","r");   
    int i=0,j=0;
    char line[8000];
    char buffer[81];

    if (check == 0)
    {
        printf("Could not open the file.\n");
    }
    else
    {
        while (fgets(buffer, 80, check) != NULL)
        {
            printf(buffer);
            for (j = 0; j < 80; j++) {
                line[i++] = buffer[j];
            }
        }
        printf("Content of Array.\n");
        printf("%s, \n", line); 
        fclose(check);
    }

I attempted more ways than this but am lost on how to implement them again as i commented them all. For this, it is printing only the first line of the file. The next line would have a comma. thats all. For now, i just want to copy contents of file to array.

Dean_williams

Thank you for your responses. Cleared my doubts.

Dean_williams Professional poster

Hello. I am new to this forum. I want to know exactly how long does any posts gets replies here.How long does a post stay in this forum. Does it get deleted after a period of time??. Thank you.

Dean_williams Professional poster

Hello. I was searching on how to copy the string from the first point in the file to the index of comma -1. I have a .mrk file that i would be reading. My idea is that the loop will go through the file and find the comma. There will be a counter to check the num of characters. When found, the first char to char at index of comma-1 is copied to a seperate array. But i do not know how to implement this. This is my code:

FILE *check = fopen("check.mrk","r");

   if (check == 0)
   {
    printf("Could not open the file.\n");
   }
   else
   {
      int i;

      while((i=fgetc(check))!=EOF)
      {
         printf("%c",i);
         if (i == '\n')
         {
            printf("\n");
        }
      }
      fclose(check);
   }

A guidance on this would be appreciated. Thank you.