Question

1. How many pointers are contained in the nodes of a circularly doubly-linked list with a...

1. How many pointers are contained in the nodes of a circularly doubly-linked list with a sentinel node of five data nodes?

2.given a circularly doubly-linked list with a sentinel node where each node has two references(forw and back); one that points to the next node and another that points to the previous node. Assume the linked list below:

SENTINEL - 30 - 70 - 90 - 50 - 10

Provide the output for the following statement

Print( head->forw->forw->forw->forw->back->data)

3.given a circularly doubly-linked list with a sentinel node where each node has two references(forw and back); one that points to the next node and another that points to the previous node. Assume the linked list below:

SENTINEL - 30 - 70 - 90 - 50 - 10

provide the output for the following pseudocode

ptr = head->forw->forw

ptr->back->forw=ptr->forw

ptr->forw->back=ptr->back

list.printForw()//lprints the list forward.

4.given a circularly doubly-linked list with a sentinel node where each node has two references(forw and back); one that points to the next node and another that points to the previous node. Assume the linked list below:

SENTINEL - 30 - 70 - 90 - 50 - 10

provide the output for the following pseudocode

head->forw->data+=head->back->data

list.printBack()//lprints the list backward.

Answer should only be numbers

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1)    12 Pointers

Explanation:

There are two pointers forward and previous for each node.
There are 10 pointers for five data nodes and two pointers for a sentinel node.
Thus, there are total 12 pointers contained in the circular doubly linked list of five data nodes with one sentinel node.


Answer 2)    50

Explanation:

List: SENTINEL - 30 - 70 - 90 - 50 - 10
print(head->forw->forw->forw->forw->back->data)

The head node will be node that is pointed as forward of sentinel node.
Here, head is the node with data 30,
head->forw points to node with data 70,
head->forw->forw points to node with data 90,
head->forw->forw->forw points to node with data 50,
head->forw->forw->forw->forw points to node with data 10.
head->forw->forw->forw->forw->back points to node (back of node with data 10) with data 50.
Hence the answer is: 50


Answer 3)    30, 70, 50, 10

Explanation:

The head node will be node that is pointed as forward of sentinel node.

ptr = head->forw->forw, ptr points to node with data 90

ptr->back->forw = ptr->forw, back pointer of node with data 90 points to node with data 70, forward pointer of this node is made to point to node with data 50 (which is the forward node of node with data 90)

ptr->forw->back=ptr->back, forward pointer of node with data 90 points to node with data 50, back pointer of this node is made to point to node with data 70 (which is the back node of node with data 90).

Hence node with data 90 is removed from the list.
list.printForw() //lprints the list forward, List prints forward from head to last node which is not a head node.
Hence, the answer is: 30, 70, 50, 10


Answer 4)    10, 50, 90, 80, 30

Explanation:

The head node will be node that is pointed as forward of sentinel node.

head->forw->data += head->back->data

Forward node of head node has the data as 70. Back node of head node points to sentinel which is a dummy node whose back node has the data as 10 (which is logically the back node of head node). 10 is added to 70 and the result is reflected in the that node (which has the data 70) to 80.

list.printBack()//lprints the list backward.
List prints backward from last node to head node which is not a last node.
Hence, the answer is: 10, 50, 90, 80, 30

Add a comment
Know the answer?
Add Answer to:
1. How many pointers are contained in the nodes of a circularly doubly-linked list with a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose we implement a doubly linked list class template LinkedList with template type T. LinkedList has...

    Suppose we implement a doubly linked list class template LinkedList with template type T. LinkedList has fields Node *headPtr, Node *tailPtr and int length, where the struct type Node has fields prev and next of type Node* along with data of type T. The prev and next pointers of each Node points to the previous and next Nodes in the list (or are respectively null in the case of the list’s head or tail node). We wish to detect "invalid"...

  • Linked Lists: Suppose you have a doubly linked list with both head and tail pointers, that...

    Linked Lists: Suppose you have a doubly linked list with both head and tail pointers, that stores integers. Implement a non-recursive function that takes a linked list, searches for an integer, and removes the node with the first occurrence of that integer and also removes the node directly after it regardless of value . This function will return to address of the resulting list. You ca n assume that there will be at least three nodes, and if there is...

  • A linked list is constructed of nodes described by the following structure: struct node{ char data;...

    A linked list is constructed of nodes described by the following structure: struct node{ char data; struct node *next; }; Assume a linked list containing a sentinel node is constructed from the above nodes. Write a function named "count"-prototyped as int count(struct node*sent)- that accepts a pointer to the sentinel node; counts the number of data (non-sentinel) nodes containing the character 'A'; and returns that count as the function value.

  • In this lab, using C++, you will create an abstract data type, using a doubly-linked circular...

    In this lab, using C++, you will create an abstract data type, using a doubly-linked circular structure to store the values and links. You must create it by your own and not use any existing containers. You will need a QueueNode. You can use a struct for this, as each node will not have any associated functions. It will have members for data, and the next and previous pointers. Data will be positive integers. There will be no NULL pointers....

  • 1. static int function(int n){ return n * function(n + 1); } If you call the...

    1. static int function(int n){ return n * function(n + 1); } If you call the method function(2), the expected output is 3. True False 2. public void push(int new_data) { Node new_Node = new Node(new_data); new_Node.next = head; new_Node.prev = null; if (head != null) head.prev = new_Node; head = new_Node; } The code snippet depicts stack implementation True False 3. A ________ list is a linked data structure that consists of a set of sequentially linked records called...

  • C++ assignment about doubly linked list

    You are required to write the following functions using this class: class Doubly_linked_list // Use a class Doubly_linked_list to represent an object {     public:     // constructor initialize the nextPtr     Doubly_linked_list()     {         prevPtr = 0; // point to null at the beginning         nextPtr = 0; // point to null at the beginning     }     // get a number     int GetNum()     {         return number;     }     // set a number     void SetNum(int num)     {         number = num;     }     // get the prev pointer     Doubly_linked_list ...

  • Question 2 (3 points) Given the following singly linked list (a list with four nodes), what...

    Question 2 (3 points) Given the following singly linked list (a list with four nodes), what will be the value stored at the last node when the following operations are executed? head->1111-151->11011->1211 Node curr = head; while(curr next !=null) { curr.item = curritem-head. item; curr = cur next; اسرة Node newNode = new Node(8): curr.next = newNode: 23 O 12 OS O21 Question 3 (3 points) Given a recursive method as shown below, what is the return value for P(5)...

  • In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class...

    In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class (50 pts): Create node with public properties: Block type block and block ptr next. Create a linked list class that uses the node you generated without an add or delete method with a head and optional tail and counter. Make a driver that generates a node to test your implementation. Part 2 Add Method (30 pts): Create an add method in your linked list...

  • C++ Create a class that implements a sorted, doubly-linked list: Start with a copy of the...

    C++ Create a class that implements a sorted, doubly-linked list: Start with a copy of the sortedList class. Call your new class doublyLinkedList. Convert the baseline code into a doubly linkedlist, and thoroughly test all existing operations (make sure to check all edge conditions), and then implement the new operations below. The class should have the following additional class methods: • A reverse method: this method will reverse the order of the doubly linked list. This method takes no parameters,...

  • 1)Given a singly linked list contains four nodes and simply show as 4->3->2->1, where the head...

    1)Given a singly linked list contains four nodes and simply show as 4->3->2->1, where the head reference refers to the first node contains an Integer with value 4. If Node curr = head; curr= curr.next; are applied to this list, what is the number you can find in the first node? 2) Given a singly linked list contains 6 nodes, which is simply shown as 1->2->3->4->5->6. Assume head refers to the first node (contains 1) on the list. How many...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT