answersLogoWhite

0

Suppose we have a Queue as follows: E -> D -> C -> B

We maintain a head pointer to E and a tail pointer to B.

To add an element, we make a new queue item (say A), we set B->next = A, and set tail = A.

To delete an element, we let a temp pointer to the head (say tempHead = head), set head = E->next and deallocate tempHead.

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

What operation is supported in constant time by the doubly linked list but not by the singly linked list?

examples:- delete this node (identified by a pointer)- insert a new node before this node- replace this node with another node


How do you implement stack using linked list in turbo c?

Assume the Linked list has following operations 1.node* insert(node* node, bool head); /* head = true if insertion at head else insertion at tail */ 2. node* remove(bool head); /* head = true if removal at head else removal at tail */ Now implement the stack functions as below. STK_RET push(node* pnode) { node* head; head = insert(pnode, true); /* insert the node at head */ if (head) return STK_OK; else return STK_NOK; } similarly pop can be implemented to remove the node at head Also the conventioin of inserting and removal from the tail can be used.


What pointer type will you use to implement a heterogeneous linked list in c?

void pointer


Explain the features of doubly linked list?

Well, in a singly linked list you can only move forward, if the pointer you seek is behind your current position you'll have to cross the hole list to get there. In a doubly linked list you can simply move back as well as forward.... hope this helps...


Why you use doubly link list?

In a doubly linked list, you can iterate backwards as easily as forwards, as each element contains links to both the prior and the following element. You can also insert or delete an element without needing to iterate and remember the prior element's link. This comes at a cost. You are adding storage to each element for the second link, and you are adding processing overhead to the insert and delete operation. You have to determine the tradeoff.

Related Questions

How do you implement stack using linked list in turbo c?

Assume the Linked list has following operations 1.node* insert(node* node, bool head); /* head = true if insertion at head else insertion at tail */ 2. node* remove(bool head); /* head = true if removal at head else removal at tail */ Now implement the stack functions as below. STK_RET push(node* pnode) { node* head; head = insert(pnode, true); /* insert the node at head */ if (head) return STK_OK; else return STK_NOK; } similarly pop can be implemented to remove the node at head Also the conventioin of inserting and removal from the tail can be used.


What operation is supported in constant time by the doubly linked list but not by the singly linked list?

examples:- delete this node (identified by a pointer)- insert a new node before this node- replace this node with another node


Which is the easy insertion operator single linked-list or double-linked list?

It is easier to insert into a singly linked list.


Is it possible to implement stack and queues using linkes list?

Yes it is possible to implement stack and queue using linked list


Can you insert node in the middle of linked list?

Yes, it is easy.


Adavantage of pointer based of a list over an array?

One advantage of a linked list (with pointers) is that it is fairly cheap to insert or delete an element - once you know where it is. A disadvantage is that getting a specific element - for example, the 1000th. element - is expensive.


What pointer type will you use to implement a heterogeneous linked list in c?

void pointer


Explain the features of doubly linked list?

Well, in a singly linked list you can only move forward, if the pointer you seek is behind your current position you'll have to cross the hole list to get there. In a doubly linked list you can simply move back as well as forward.... hope this helps...


What is macro operations?

Macro operations are those not linked to individual types and invoked on objetcs - but rather general operations associated with the database as a whole.


Why you use doubly link list?

In a doubly linked list, you can iterate backwards as easily as forwards, as each element contains links to both the prior and the following element. You can also insert or delete an element without needing to iterate and remember the prior element's link. This comes at a cost. You are adding storage to each element for the second link, and you are adding processing overhead to the insert and delete operation. You have to determine the tradeoff.


Convert single linked list to double linked list?

You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.


what are the various operations in linked list which can be performed on linked list?

In linked list, there are various operations in linked list that you can perform on linked list, eg: adding new elements, deleting elements, getting the first element, getting the next element after an element, any many others.