Mid-Term Flashcards
(82 cards)
What is an activation record?
An object that represents a method invocation
What is a doubly linked list?
A linked list in which each mode has references to both the next node and the previous node in the list.
What is a linked list?
A linked structure in which one object refers to the next, creating a linear ordering.
What is a linked structure?
A data structure that uses object reference variables to create links between objects.
What is a node?
A class that represents a single element in a linked structure.
What is a program stack?
A stack of activation records used to keep track of method invocations during program execution.
What is a sentinel node?
A node at the front or end of a linked list that serves as a marker and does not represent an element in the list.
How do object references help us define data structures?
An object reference can be used as a link from one object to another. A group of linked objects can form a data structure, such as a linked list, on which a collection can be based.
Compare and contrast a linked list and an array.
A linked list has no capacity limitations, whereas an array does. However, arrays provide direct access to elements using indexes, whereas a linked list must be traversed one element at a time to reach a particular point in the list.
What special case exists when managing linked lists?
The primary special case in linked-list processing occurs when dealing with the first element in the list. A special reference variable is maintained that specifies the first element in the list. If that element is deleted, or if a new element is added in front of it, the FRONT reference must be carefully maintained.
Why should a linked list node be separate from the element stored on the list?
It is unreasonable to assume that every object that we may want to put in a collection can be designed to cooperate with the collection implementation. Furthermore, the implementation details are supposed to be kept distinct from the user of the collection, including the elements that the user chooses to add to the collection.
What do the “LinkedStack<T>" and "ArrayStack<T>" classes have in common?</T></T>
These classes implement the “StackADT<T>" interface. This means that they both represent a stack collection, providing the necessary operations needed to us a stack. Although they both have distinct approaches to managing the collection, they are functionally interchangeable from the user's point of view.</T>
What would be the time complexity of the push operation if we chose to push at the end of the list instead of the front?
O(n)
What is the difference between a doubly linked list and a singly linked list?
A singly linked list maintains a reference to the first element in the list and then a “next” reference from each node to the following node in the list. A doubly linked list maintains two references: “front” and “rear”. Each node in the doubly linked list stores both a “next” and a “previous” reference.
What impact would the use of sentinel nodes or dummy nodes have on a doubly linked list implementation?
It would take two dummy records in a doubly linked list, one at the front and one at the rear, to eliminate the special cases when dealing with the first and last nodes.
What are the advantages of using a linked implementation as opposed to an array implementation?
A linked implementation allocates space only as it is needed and has a theoretical limit on the size of the hardware.
what are the advantages of using an array implementation as opposed to a linked implementation?
An array implementation uses less space per object since it only has to store the object and not an extra pointer. However, the array implementation will allocate much more space than it needs initially.
what are the advantages of the “java.util.Stack” implementation of a stack?
It’s implementation is an extension of the “Vector” class, it can keep track of the positions of elements in the stack using an index and thus does not require each node to store and additional pointer. This implementation also allocates space only as it is needed, like the linked list implementation.
What is the potential problem with the “java.util.Stack”?
It’s implementation is an extension of the “Vector” class and thus inherits a large number of operations that violate the basic assumption of a stack.
What is a Caesar cipher?
A simple message encoding technique in which letters are shifted along the alphabet by a constant amount.
What is a circular array?
An array that is treated as circular, meaning that incrementing the last index value in the array wraps around back to the first element.
What does a dequeue do?
Removes an element from the front of the queue.
What does an enqueue do?
Adds and element to the rear of the queue.
What if FIFO?
First In First Out, a description of a collection in which the first element added will be the first element removed.