|< Free Open Study >|
Dummy nodes are used to simplify list processing by eliminating some "special case."
What special case is eliminated by a header node in a linear linked list?
What special case is eliminated by a trailer node in a linear linked list?
Would dummy nodes be useful in implementing a linked stack? That is, would their use eliminate a special case?
Would dummy nodes be useful in implementing a linked queue with a pointer to both head and rear elements?
Would dummy nodes be useful in implementing a circular linked queue?
Implement the class constructor, destructor, and copy constructor for the circular linked list class.
If you were going to implement the FIFO Queue ADT as a circular linked list, with the external pointer accessing the "rear" node of the queue, which member functions would you need to change?
Write a member function PrintReverse that prints the elements on a list in reverse order. For instance, for the list X Y Z, list.PrintReverse() would output Z Y X. The list is implemented as a circular list with listData pointing to the first element in the list. You may assume that the list is not empty.
Can you derive a type DLList from the class SpecializedList that has a member function InsertItem that inserts the item into its proper place in the list? If so, derive the class and implement the function. If not, explain why not.
If you were to rewrite the implementation of the Sorted List ADT using a doubly linked list, would you have to change the class definition? If so, how?
Outline the changes to the member functions that would be necessary to implement the Sorted List ADT as a doubly linked list.
Write a member function Copy of the Stack ADT, assuming that the stack named in the parameter list is copied into self.
Write a member function Copy of the Stack ADT, assuming that self is copied into the stack named in the parameter list.
Using the circular doubly linked list below, give the expression corresponding to each of the following descriptions.
(For example, the expression for the info member of Node 1, referenced from pointer A, would be A->info.)
The info member of Node 1, referenced from pointer C
The info member of Node 2, referenced from pointer B
The next member of Node 2, referenced from pointer A
The next member of Node 4, referenced from pointer C
Node 1, referenced from pointer B
The back member of Node 4, referenced from pointer C
The back member of Node 1, referenced from pointer A
The text edited by a line editor is represented by a doubly linked list of nodes, each of which contains an 80-column line of text (type LineType). There is one external pointer (type LineType*) to this list, which points to the "current" line in the text being edited. The list has a header node, which contains the string "- - - Top of File - - -" and a trailer node, which contains the string "- - - Bottom of File - - -".
Draw a sketch of this data structure.
Write the type declarations to support this data structure.
Write the class constructor, which sets up the header and trailer nodes.
Code the following operations:
Describe the operations in part (d) in terms of Big-O notation. How could you change the list to make these operations 0(1)?
Code the InsertLine operation, using the following specification:
What other member functions should be included?
Of the three variations of linked lists (circular, with header and trailer nodes, and doubly linked), which would be most appropriate for each of the following applications?
You want to search a list for a key and return the keys of the two elements that come before it and the keys of the two elements that come after it.
A text file contains integer elements, one per line, sorted from smallest to largest. You must read the values from the file and create a sorted linked list containing the values.
A list is short and frequently becomes empty. You want a list that is optimal for inserting an element into the empty list and deleting the last element from the list.
What is the Big-O measure for initializing the free list in the array-based linked implementation? For the functions GetNode and FreeNode?
Use the linked lists contained in the array pictured in Figure 6.19 to answer the following questions:
What elements are in the list pointed to by list1?
What elements are in the list pointed to by list2?
What array positions (indexes) are part of the free space list?
What would the array look like after the deletion of Nell from the first list?
What would the array look like after the insertion of Anne into the second list? Assume that before the insertion the array is as pictured in Figure 6.19.
An array of records (nodes) is used to contain a doubly linked list, with the next and back members indicating the indexes of the linked nodes in each direction.
Show how the array would look after it was initialized to an empty state, with all the nodes linked into the free-space list. (The free-space nodes have to be linked in only one direction.)
Draw a box-and-arrow picture of a doubly linked list into which the following numbers are inserted into their proper places: 17, 4, 25.
Fill in the contents of the array on the next page after the following numbers are inserted into their proper places in the doubly linked list: 17, 4, 25.
Show how the array in part (c) would look after 17 is deleted.
Discuss the changes that would be necessary if more than one digit is stored per node in the LargeInt class.
Distinguish between static and dynamic binding of functions.
|< Free Open Study >|
|Converted from CHM to HTML with chm2web Pro 2.85 (unicode)|