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

1. Suppose that Element is the class for the nodes of a linked list class named

ID: 3547089 • Letter: 1

Question

1.    Suppose that Element is the class for the nodes of a linked list class named LinkedElements. What are the two main components (variables) of the Element class? What is the main component (variable) in the LinkedElements class?              a. First component/variable in Element:    

b.    Second component/variable in Element:                   

c.    The component/variable in LinkedElements:


2.   Describe one advantage and one disadvantage to using a linked list versus using a static (not dynamic) array.


3.    Explain the steps needed to add a link in the middle of a linked list.


4..    When can be using a stack be the most convenient data structure to use?


5  Write a function to deallocate memory created for a 2 D array when you are done using it.


6.    Write a function insert that puts 5 values into a stack. Now create another function print that will print to the screen the values that are in the stack you have created.


7.   Explain how you can (i) insert and (i) delete an item in a linked list with Header and trailer nodes.



Explanation / Answer

i've given the answers in reverse order




7]

insertion


void insert_begin(int ele)

{

node *temp = new node;

temp->data = ele;

if(front == NULL)

{

temp->next = NULL;

front = temp;

rear = temp;

}

else

{

temp->next = front;

front = temp;

}

}


deletion


void del_begin()

{

node *temp = front;

if(temp == NULL)

cout<<" List is empty ";

else

{

temp = temp->next;

delete front;

front = temp;

}

}