< previous page page_1113 next page >

Page 1113
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. myList.InsertTop(30);     b. myList.Insert(10);
   myList.InsertTop(20);        myList.Insert(20);
   myList.InsertTop(10);        myList.Insert(30);
   myList.Print();              myList.Print();
2. In a linked list, components are only logically next to each other, whereas in an array they are also physically next to each other. (True or False?)
3. Which of the following can be used to implement a list ADT?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. An array of the component type
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. A linked list implemented using an array of structs
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. A linked list implemented using dynamic structs and pointers
4. The following declarations for a node of a linked list are not acceptable to the C++ compiler:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
typedef T* P;
struct T
{
    float x;
    P     link;
};
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Correct the problem by inserting another declaration before the Typedef statement.
5. What is the primary benefit of dynamic data structures?
6. This chapter's OrdList class represents an ordered list ADT. To make an unordered list ADT, which of the following member functions could be removed: IsEmpty, Print, InsertTop, Insert, DeleteTop, and Delete?
7. Use the C++ code below to identify the values of the variables and Boolean comparisons that follow. The value may be undefined, or the expression may be invalid.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
struct NodeType;
typedef NodeType* NodePtr;

struct NodeType
{
    int     number;
    char    character;
    NodePtr link;
};

NodePtr currPtr = NULL;
NodePtr firstPtr = NULL;
NodePtr lastPtr = NULL;

currPtr = new NodeType;
currPtr->number = 13;
currPtr->character = z;
currPtr->link = new NodeType;
lastPtr = currPtr->link;

 
< previous page page_1113 next page >