You are given pointers to first and last nodes of a singly linked list which of the following

  • You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?a) Delete the first elementb) Insert a new element as a first elementc) Delete the last element of the listd) Add a new element at the end of the list

    TRUE or FALSE? Answer the following question and state the reason why: The delete operation only involves the removing of the node from the list without breaking the links created by the next node. You need an array to represent each node in a linked list. STL lists are also efficient at adding elements at their back because they have a built-in pointer to the last element in the list. A circular linked list has 2 node pointers. cout<<list.back()<<endl;  = The back member function returns a reference to the last element in the list. In a Dynamic Stack, the pointer top stays at the head after a push operation. During a Pop operation in Static Stack, the elements are being moved one step up. In a dynamic implementation of stack, the pointer top has an initial value of null. In a dynamic stack, the node that was popped is deleted. In a dynamic stack, the pointer top stays at the head after push operation. STL function top returns a reference to element at the top of the…

    1-Let the list have a head and a tail. That is, a pointer (have a marker) to both the beginning (first Node) of the list and the last Node. What process does Tail facilitate? 2-insert(int index, int element): adds this element to the index position. For example, if index is 4, it adds this element between index 3 and 4 in the list. The size of the list has increased by one. 3-append(int elem): Adds the element to the end of the list. The size of the list has increased by one. 4-get(int index): Returns the element at the index position of the list, no change in the list. 5-remove(int index): Returns the element at the index position of the list. This element is removed from the list and the list size is reduced by one. 6-findMin(): returns the index of the smallest number in the list. 7-findMax(): returns the index of the largest number in the list. 8-search(int elem): searches elem in the list. It returns -1 when you can't find elem's index when you find it. 9-ToArray(): Return an…

  • 1-Let the list have a head and a tail. That is, a pointer (have a marker) to both the beginning (first Node) of the list and the last Node. What process does Tail facilitate? 2-insert(int index, int element): adds this element to the index position. For example, if index is 4, it adds this element between index 3 and 4 in the list. The size of the list has increased by one. 3-append(int elem): Adds the element to the end of the list. The size of the list has increased by one. 4-get(int index): Returns the element at the index position of the list, no change in the list. 5-remove(int index): Returns the element at the index position of the list. This element is removed from the list and the list size is reduced by one. 6-findMin(): returns the index of the smallest number in the list. 7-findMax(): returns the index of the largest number in the list. 8-search(int elem): searches elem in the list. It returns -1 when you can't find elem's index when you find it. 9-ToArray(): Return an…

    Assume a linked list contains following integers: 5, 2, 4, 6, 8, 3, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode=head; int a=0; curNode->setNext(NULL); while(curNode!=NULL){        a+=curNode->getItem();        curNode=curNode->getNext(); } A.5 B.2 C.43 D.38

    q9) In which of the following linked list there will be no beginning and ending? a. Depends on the Problem. b. Single Linked List. c. Double Linked List. d. Circular Linked List.

  • Assume a linked list contains following integers: 2, 2, 4, 5, 8, 3, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode; curNode=new Node<int>(10,head); head=curNode; int a; while(curNode!=NULL){       a+=curNode->getItem();       curNode=curNode->getNext(); }   A.49 B.39 C.7 D.15

    Assume a linked list contains following integers: 4, 2, 6, 5, 8, 3, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode=head; int a; curNode=curNode->getNext(); head->setNext(curNode); head=head->getNext(); a=head->getItem();   A.2 B.4 C.6 D.15

    struct node{int num;node *next, *before;};start 18 27 36 45 54 63 The above-linked list is made of nodes of the type struct ex. Your task is now to Write a complete function code to a. Find the sum of all the values of the node in the linked list. b. Print the values in the linked list in reverse order. Use a temporary pointer temp for a and b. i dont need a full code just the list part

  • Assume a linked list contains following integers: 2, 2, 4, 5, 8, 3, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode=head; int a=0; while(curNode->getItem()<7){         a+=curNode->getItem();        curNode=curNode->getNext(); } A. 13 B. 5 C. 8 D. 21

    Assume a linked list contains following integers: 7, 2, 9, 5, 8, 3, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode=head; int a; while(curNode->getNext()!=NULL){ {       curNode=curNode->getNext(); } a=curNode->getItem();   A. 15 B. 7 C. 49 D. 3

    int F(node<int>&p){int c=0; while(p!=0){p=p->next; c++; } return c;} This function is a. return the number of items in the linked list b. return the number of items in a linked list and destroy the linked list c. None of these d. destroy the list and free all allocated nodes

  • arrow_back_ios

    arrow_forward_ios

    12. You are given pointers to first and last nodes of a singly linked list,which of the following operations are dependent on the length of the linkedlist?(A) Delete the first element(B) Insert a new element as a first element(C) Delete the last element of the list(D) Add a new element at the end of the listAnswer: (C)Explanation: a) Can be done in O(1) time by deleting memory and changing the

    first pointer.b) Can be done in O(1) time, see push() herec) Delete the last element requires pointer to previous of last, which can onlybe obtained by traversing the list.d) Can be done in O(1) by changing next of last and then last.13. Suppose each set is represented as a linked list with elements in arbitraryorder. Which of the following set operations is the fastest?

    Get answer to your question and much more

    Video liên quan

    Postingan terbaru

    LIHAT SEMUA