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

please respond fast thank you Question 20 Not yet answered Marked out of 2.00 P

ID: 3716261 • Letter: P

Question

please respond fast thank you

Question 20 Not yet answered Marked out of 2.00 P Flag queston Given the the variable list represents a reference to a linked list. Define a method called delete, that remores the last node in the list. ?14 B | 1 |--| e® | ectangular Question 21 Not yet answered Markad out of 2.00 Given the the variable list represents a reference to a linked list. Define a method called countNodes, that counts and returas the number of nodes in the list. Flag question Question 22 When it comes to Graphical User Interface programming difterentiate between a container object and a component object object. Give one example of each. Not yet answered P Flag question

Explanation / Answer

Solution No. 20:

/* Function to delete the entire linked list */

void deleteList(struct Node** head_ref)

{

   /* deref head_ref to get the real head */

   struct Node* current = *head_ref;

   struct Node* next;

   while (current != NULL)

   {

       next = current->next;

       free(current);

       current = next;

   }

   

   /* deref head_ref to affect the real head back

      in the caller. */

   *head_ref = NULL;

}

Solution No. 21:

Java's Component class represents visual elements of a Graphical User Interface. Its subclasses include Button, Checkbox, TextField, Choice, and Canvas. The Container class is another subclass of Component. A Container is a component that can contain other components (including other containers). This is the essential difference between containers and other types of component. Subclasses of Container include Frame, Panel, and Applet.

/* Counts no. of nodes in linked list */

int getCount(struct Node* head)

{

    int count = 0; // Initialize count

    struct Node* current = head; // Initialize current

    while (current != NULL)

    {

        count++;

        current = current->next;

    }

    return count;

}

Solution No 22: