Examveda

Consider the following algorithm to insert an element in a triply linked list.
insertelement(data)
{
    create a node with given data.
    if the linked list is empty
    {
        _____________
        _____________
    }
    if the given node is less than the head
    {
        link the nodes through address and adjust the tail
    }
    if the given node is not less than the head
    {
        if the given node is equal to the head
        {
            new node is inserted on top of the head    
        }
        else
        {
            traverse the linked list to find an element greater than the node and insert in front of the node     
        }   
    } 
}

Which of the following option is best suited to fill the blank?

A.

initializing previous, next and top pointers to null
    pointing the head and tail to the node created

B.

pointing previous, next and top pointers to the node created
    initializing the head and tail to null

C.

initializing previous, next and top pointers to null
    initializing the head and tail to null

D.

pointing previous, next and top pointers to the node

Answer: Option A


This Question Belongs to Data Structure >> Linked Lists In Data Structures

Join The Discussion

Related Questions on Linked Lists in Data Structures

What is a circular linked list?

A. A list where each node points to the next

B. A list where the last node points to the first node

C. A list where each node points to itself

D. A list where the nodes are in a circle