List Practice Quiz
In a doubly linked list with dummy head and tail reference, which method has a time efficiency of O(1)?
all of the above
In a singly linked list with a dummy head reference, which method has a time efficiency of O(1)?
clear
consider a singly linked list with only a dummy head node. Which statements correctly adds a newnode to the end of the list?
currentNode=head; while(currentNode.next!=tail) currentNode=currentNode.next currentNode.next=newNode newNode.next=tail
In an ArrayList, given a valid index which is is in the middle of the list of elements, which of the following will remove the element at the given index?
int i = index;for(; i < size; i++){array[i] = array[i+1]-1;}array[i] = null;
Consider a doubly linked list with dummy head and tail nodes ( they just mark the beginning and ending of the list and do not contain data items).Which code segment correctly adds a new node to the end of the list:
newNode.previous = tail.previous newNode.next= tail tail.previous.next = newNode tail.previous= newNode
Which statement correctly removes a node n from a doubly linked list:
previous_node=n.previous next_node=n.next previous_node.next = next_node next_node.previous = previous_node
Consider a doubly linked list with dummy head and tail nodes ( they just mark the beginning and ending of the list and do not contain data items).Which code segment correctly removes the last node (the node before tail) from the list:
tail.previous.previous.next=tail tail.previous= tail.previous.previous nodeToRemove.next = null nodeToRemove.previous = null
What are the two common ways to implement a list?
using arrays and a chain of linked nodes
To locate a node that is near the end of the list within a singly linked list that contains only a head node, we must
start at the first node and traverse the chain
Within an ArrayList, you must traverse the list to get an element at a specified index?
False
You must know how much memory to allocate before creating a linked implementation of a list.
False
Match each data type to its access method
Match each data type to its access method Arrays Random Access Lists Sequential Hash Tables Random access Trees Sequential Access Stack Last In First Out (LIFO) Queue First In First Out (FIFO)
(Select all that apply) Which of the following statement(s) are true about doubly linked list?
Nodes must contain references to the node before and after it in the list., You can move in two directions between nodes.,
Given a LinkedList with only a head node, what is the runtime for adding an element to the end of the list?
O(1)
In a doubly linked-based implementation of list with a tail reference, what is the performance of adding an entry at the end of the list?
O(1)
Which statements are true about the array data structures in Java?
The arrays are statically sized. If there is a need to add more items that the array's capacity, then a new array with a bigger size needs to be created and the items must be copied from the old array to the new array., A block of contiguous memory is used to store the array items
Given an ArrayList, which code segment correctly resizes the array while maintaining its elements? (The array variable is called array).
int newCapacity = 2 * array.lengthT[] newArray = (T[]) new Object[newCapacity]for(int i = 0; i < array.length; i++){newArray[i] = array[i];}array = newArray;
Which statement correctly adds a node n between n1 and n2 in a doubly linked list where n1 comes before n2?
n.next = n2 n.previous=n1 n1.next=n n2.previous=n