









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










a doubly-linked list can use a dummy node at both the head and the tail - ANSwhere can a doubly-linked list use a dummy node adaptation - operates similar on doubly-linked list, requires searching from the list head for insertion position for singly-linked lists - ANShow does insertion sort adapt to linked lists adaption - finding the middle of the list requires searching linearly from the list head and can merge lists without additional storage - ANShow does merge sort adapt to linked lists add() method of arrayList - ANScreates a space for and add the element at the end of the arrayList an ADT that is implemented as a generic class that supports different reference types and has established methods available - ANSwhat is an ArrayList type Append or Prepend to empty singly-linked list - ANSif the list's head pointer is null, point the current list's head and tail pointers to the new node Append to a non-empty singly-linked list - ANSif the list's head pointer is not null, point the current list tail node's next pointer to the new node, then the list's tail pointer to the new making the new node the new list's tail node Append(list, x) - ANSHow is the list's append operation written?
Appending to empty doubly-linked list - ANSif the doubly-linked list's head pointer is null, then the list's head and tail pointer are set to the new node to add after Appending to non-empty doubly-linked list - ANSif the doubly-linked list's head pointer is not null, the now node's previous pointer is se to the current tail node, the current tail node's next pointer is set to the new node, then the list's tail pointer is reset to the new node making it the list's new tail node array-based list - ANSa list ADT that is implemented using an array and supports common operations like append, prepend, insertAfter, remove, and print array-based list append operation - ANSinserts a new elements at the end of the array-based list or at a specified index array-based list insertAfter operation - ANSinserts a new element after a specified index in an array-based list array-based list prepend operation - ANSinserts at the start of the array- based list array-based list removeAt operation - ANSwill remove the element at the specified index in an array-based list array-based list search operation - ANSwill return the index of the first element that matches a given key or -1 if there was not a match in the array- based list
challenge - partition requires backward traversal through the right portion of the array which singly-linked lists do not support - ANSwhy does quicksort not easily adapt to linked lists clear() operation of arrayList - ANSremoves all elements from the arrayList Collection - ANSa large group of generic objects known as elements curNode = curNode->next - ANSwhat line will set curNode to it's next node curNode->data - ANSwhat line of code is used to get node data curNode->next = newNode - ANSwhich line of code will point the curNode's next pointer to the new node so that it will be the node after the curNode? doubly-linked list - ANSa data structure for implementing a list ADT, where each node contains data(element), a pointer to the next node, and a pointer to the previous node dummy node - ANSin linked list implementation, a node with an unused data member that will always reside at the head of the node. can be called header node for a doubly-linked list the remove operation must check that if the given node is the dummy node - ANSwhat must the remove operation check when a doubly-linked list has a dummy node for a doubly-linked list, inserts a new node after the current tail node to become the list's new tail node - ANSAppend Operation of double-linked list
for a doubly-linked list, inserts the new node after a specified existing list node. curNode points to the specified node and sucNode points to curNode's next node - ANSInsertAfter operation for doubly-linked list for a doubly-linked list, inserts the new node before the list's head node and points the list's head pointer to the new node - ANSPrepend operation of doubly-linked list for a doubly-linked list, removes a specified, existing node. curNode is the pointer to the node being removed, sucNode is the curNode's next node, and predNode is the curNode's previous node - ANSRemove operation for a doubly-linked list for a singly-linked list, inserts the new node after the current tail node of the list so that the now node is now the list's new tail node - ANSAppend Operation of a singly-linked list for a singly-linked list, inserts the new node at the head of the list so that the new node becomes the list's new head node - ANSPrepend operation for singly-linked list for a singly-linked list, removes the node after a specified existing node. curNode points to the specified node and sucNode is the node after the node that the curNode's next pointer is pointing to - ANSRemoveAfter operation of singly-linked list for singly-linked lists, inserts a new node after a specified, existing node. curNode variable is used as a pointer to the specified existing node - ANSInsertAfter operation of singly-linked list for singly-linked lists, the dummy node will always be at the head of the list with the list's head pointer set to the dummy node at all times and when the list is empty the list's tail pointer will also point to the dummy node. this will
inserting in the middle of doubly-linked list - ANSif the doubly-linked list's head pointer is not null and curNode is not pointing to the tail node, the sucNode is the curNode's current next node, the new node's next node pointer is set to the sucNode, the new node's previous pointer is set to the curNode, the curNode's next pointer is reset to the new node, and the sucNode's previous pointer is reset to the new node. insertion after the tail node in a singly-linked list - ANSif a singly-linked list's head pointer is not null and the curNode is pointing to the tail node, the point the list's tail node's next pointer to the new node, and then point the list's tail pointer to the new node, making it the new tail node Insertion in the middle of singly-linked list - ANSif a singly-linked lists head pointer is not null and the curNode is not pointing to the tail node, point the new node's next pointer to the curNode's next node and point the curNode's next pointer to the new node so that it is now the node after curNode insertion into empty singly-linked list - ANSif a singly-linked list's head pointer is null, then the new node is the first node to be added and the list's head and tail pointers are set to the new node insertion sort and merge sort - ANSwhat are the most efficient and easily adapted sorting algorithms for linked list insertion sort can only insert a node after an existing one, so it will use the ListFindInsertionPosition to get the position that the given node should be inserted after in a singly-linked list. if the position returned is null then the node will be inserted at the head. - ANSHow does an insertion sort work with singly-linked lists insertion sort's inner loop will execute N/2 times - ANShow many times will the inner loop in the insertion sort execute
insertion sort's outer loop will execute N-1 times - ANShow many times will the outer loop in the insertion sort execute isEmpty() operation of arrayList - ANSreturns True if the ArrayList is empty or False if there are elements IsEmpty(list) - ANSHow is the list's isEmpty operation written? Java Collections Framework - ANSdefines interfaces and classes for common ADTs(collections) List - ANSa common ADT for holding ordered data with operations like append, remove, search, and print. Users do not need internal implementation of the list ADT. List Append Operation - ANSInserts an element at the end of the list List GetLength Operation - ANSreturns the number of elements in the list List insertAfter Operation - ANSinserts an element after a specified value List isEmpty Operation - ANSreturns True if the list has no elements List Prepend Operation - ANSInserts an element at the beginning of the list List Print Operation - ANSprints the list's elements in order List PrintReverse Operation - ANSprints the list's elements in reverse order (back to front)
method chaining - ANSthe use of more than one method in a line of code, usually to retrieve an element and then do something with it newNode->next = curNode->next - ANSwhich line of code will point the new node to the curNode's next node? newNode->next = list->head - ANSWhat line of code will point the new node's next pointer to the current head node? newNode->prev = list->tail - ANSwhich line of code points the new node's previous pointer to the tail node Node - ANSfrom the it's own class, contains the memory location where the data value of a list is stored and contains pointers(next/previous) to the node in front(previous) and/or the node in back(next) only a doubly-linked list can be reverse traversed - ANSwhich kind of list can be reverse traversed Positional List - ANSa list where elements contain pointers to the next and/or previous element in the list. Prepend to a non-empty singly-linked list - ANSif the list's head pointer is not null, point the new node's next pointer to the current head node and the list's head pointer to the new node making it the list's new head node Prepend(list, x) - ANSHow is the list's prepend operation written? Prepending to a non-empty doubly-linked list - ANSif the doubly-linked list's head pointer is not null, the new node's next pointer is set to the current list head node, the current head node's previous pointer is set to the new node,
and the list's head pointer is reset to the new node making it the new list head node Prepending to empty doubly-linked list - ANSif the doubly-linked list's had pointer is null, the list's head and tail nodes are pointed to the new node being added in front Print(list) - ANSHow is the list's print operation written? PrintReverse(list) - ANSHow is the list's printReverse operation written? remove() operation of arrayList - ANScan either remove the first instance of an element in the ArrayList or the element at specified index Remove(list, x) - ANSHow is the list's remove operation written? removing node after curNode in singly-linked list - ANSif curNode is not null, the sucNode is pointed to the node after the node being removed(curNode's next node) and curNode's next pointer is set to the sucNode. if the sucNode is null then the list's tail pointer is pointed to the curNode Removing singly-linked list's head node, special case - ANSif the curNode is null, which points to the list's head node, the sucNode is pointed to the list's head node's next node, and the list's head pointer is pointed to the sucNode but if sucNode is null, then the only node was removed and the list's head and tail pointer snow point to null reverse traversal - ANSan algorithm that traverses a list, starting with the tail node instead of the head node, and preforms an operation on each node. only supported with doubly-linked lists
the allocation size is generally doubled when the array-based list is resized - ANShow much is an array-based list resized the append, prepend, insertAfter, and remove operations will become simpler and easier to code - ANSwhat operations for a linked list are effected when a dummy node is present the average- and wort-case runtime for insertion sort is O(N squared) while the best-case runtime is O(N) - ANSwhat is the runtime for insertion sort the doubly-linked list will include a previous pointer to null in the dummy node - ANSwhat does a doubly-linked list with a dummy node have that a singly-linked list with a dummy node does not the doubly-linked list's head pointer is reset to the sucNode - ANSwhat happens if the head node is to be removed from a doubly-linked list the doubly-linked list's tail pointer is reset to the predNode - ANSwhat happens if the tail node is to be removed from a doubly-linked list the dummy nodes purpose is so that a list will always have a node for it's head and tail pointers to point at. this allows any special cases for when the list is empty in the list operations to be omitted. - ANSwhat is the purpose of a dummy node the get() method is used to look-up an element in the arrayList - ANShow are ArrayList elements accessed the head and tail pointers are null - ANSWhat are the list's head and tail pointers when it is created?
the linked list will essentially preform a traversal whose operation will attempt to match they key to a node and return the curNode that points to the matching node or null if the key is not found - ANSwhat is a search of a linked list the list interface is the most commonly used ADT because it represents a group of ordered objects - ANSwhat is the most commonly used ADT the operation to resize array-based lists has a runtime of O(N) - ANSwhat is the resize operations runtime the pointer is not pointing to any node - ANSWhat does a null value for a pointer mean? the predNode's next pointer is set to the sucNode, doubly-linked list - ANSwhat happens if the predecessor node exists when removing a node from a doubly-linked list the purpose of a doubly-linked list having a dummy node at the tail node is to always have a node for the list's tail pointer to be able to point to. this allows for the code to further simplified - ANSwhat is the purpose of a doubly- linked list having a dummy node at the tail node the remove a node from a doubly-linked list the first thing to happen is that the sucNode is set to point to the curNode's next node, and the predNode is set to point to the curNode's previous node - ANSwhat are the first two steps in removing a node from a doubly-linked list the singly-linked list's head node is removed - ANSwhat happens if the curNode is null when using the singly-linked list removeAfter operaiton