New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
computer science
programming language pragmatics
C++ Plus Data Structures 6th Edition Nell Dale, Chip Weems, Tim Richards - Solutions
Why did we type cast dividend and divisor in the function Divide?
The solution to the Case Study did not consider negative fractions. 1. How should a negative fraction be represented? 2. Which of the member functions would have to be changed to represent negative fractions? What changes would be involved? 3. Rewrite the test plan to test for negative fractions.
One of the member functions in the Case Study needs an additional test. Which function is it, and what should the data be?
Name four tools used in software design.
Define information hiding.
Name four types of step-wise refinement.
What is the key feature of top-down design?
What characterizes functional decomposition?
Name two visual tools used by software developers.
In reviews and inspections, what is being reviewed or inspected?
Give the basic design of a test driver.
Why is exhaustive code-coverage testing virtually impossible?
Why is exhaustive data-coverage testing virtually impossible?
Explain what we mean by “data abstraction.”
What is data encapsulation? Explain the programming goal “to protect our data abstraction through encapsulation.”
Name three perspectives from which we can view data. Using the logical data structure “a list of student academic records,” give examples of what each perspective might tell us about the data.
Consider the ADT GroceryStore. 1. At the application level, describe GroceryStore. 2. At the logical level, what grocery store operations might be defined for the customer? 3. Specify (at the logical level) the operation CheckOut. 4. Write an algorithm (at the implementation level) for the
What composite types are predefined in the C++ language?
Describe the component selectors for structs and classes at the logical level.
Describe the accessing functions for structs and classes at the implementation level.
Describe the component selectors for one-dimensional arrays at the logical level.
Describe the accessing functions for one-dimensional arrays at the implementation level.
1. Declare a one-dimensional array, name, that contains 20 characters. 2. If each character occupies one “cell” in memory, and the base address of name is 1000, what is the address of the cell referenced in the following statement? name [9] = 'A';
1. Declare a one-dimensional array type, WeatherListType, of WeatherType components, to be indexed by values of type MonthType. Declare a variable, yearlyWeather, of WeatherListType. 2. Assign the value 1.05 to the actual rainfall member of the July record in yearlyWeather. 3. If the base address
1. Declare a two-dimensional array, decadeWeather, of WeatherType components, to be indexed by values of type MonthType in the first dimension. 2. Draw a picture of decadeWeather. 3. Assign the value 26 to the avgLoTemp member of the March 2006 entry. enum MonthType {JAN, FEB, MAR, APR, MAY OCT,
1. Define a three-dimensional array at the logical level. 2. Suggest some applications for three-dimensional arrays.
Construct a member-length-offset table for StudentRecord. typedef char String[10]; struct Student Record { String firstName; String lastName; int id; float gpa; int currentHours; int totalHours; }; Student Record student; Student Record students [100];
If the base address of student is 100, what address does the compiler generate as the target of the following assignment statement? typedef char String[10]; struct Student Record { String firstName; String lastName; int id; float gpa; int currentHours; int totalHours; }; Student Record student;
How much space does the compiler set aside for students? typedef char String[10]; struct Student Record { String firstName; String lastName; int id; float gpa; int currentHours; int totalHours; }; Student Record student; Student Record students [100];
Indicate which predefined C++ types would most appropriately model each of the following (more than one may be appropriate for each): 1. a chessboard2. information about a single product in an inventorycontrol program 3. a list of famous quotations 4. the casualty figures (number of deaths per
What C++ construct is used to represent ADTs?
Explain the difference between a C++ struct and class.
How is the client prevented from directly accessing the details of an instance of a class?
1. The details of a private member can be seen by the user of a class. (True or False?) 2. The details of a private member may be accessed by a client program. (True or False?)
Why is it good practice to put a class declaration in one file and the implementation in another?
Name three ways that classes can relate to each other.
Distinguish between composition and inheritance.
Distinguish between a base class and a derived class.
Does a derived class have access to the private data members of the base class?
Does a derived class have access to the public member functions of the base class?
1. Write the specification for an ADT SquareMatrix. (A square matrix can be represented by a two-dimensional array with N rows and N columns.) You may assume a maximum size of 50 rows and columns. Include the following operations: 2. Convert your specification to a C++ class declaration. 3.
Date Type keeps only the integer representation of the month, day, and year. When a month is wanted in string form, the string is calculated. An alternate approach would be to add a string field to the date and calculate and store the string representation in the Initialize function. Which methods
What changes would be necessary if the number of days in the month were carried as a data field in class DateType rather than being looked up when necessary? Would this change make the use of a switch statement to find the number of days in the month more attractive? Write the code for this switch
Compare and contrast the implementation of class Date Type used in the Case Study and the solution proposed in Exercises 29 and 30. These two approaches represent the classic trade-off between space and algorithm complexity. Please comment.Exercise 29.Date Type keeps only the integer representation
These two approaches represent the classic trade-off between space and algorithm complexity. Please comment.Exercises 29DateType keeps only the integer representation of the month, day, and year. When a month is wanted in string form, the string is calculated. An alternate approach would be to add
The order of sorting an array of N items using one of the better sorting algorithms such as Quicksort. 1. O(1) 2. O(logN) 3. O(N) 4.O(N logN) 5. O(N*N) 6. O(N*N*N)
The order of sorting an array of N items using one of the slower sorting algorithms such as SelectionSort. 1. O(1) 2. O(logN) 3. O(N) 4. O(N logN) 5. O(N*N) 6. O(N*N*N)
The order of an algorithm that decrements every element in a three-dimensional table of N rows. 1. O(1) 2. O(logN) 3. O(N) 4. O(N logN) 5. O(N*N) 6. O(N*N*N)
The order of an algorithm that increments every element in a twodimensional table of N rows. 1. O(1) 2. O(logN) 3. O(N) 4. O(N logN) 5. O(N*N) 6. O(N*N*N)
The order of comparing three items. 1. O(1) 2. O(logN) 3. O(N) 4. O(N logN) 5. O(N*N) 6. O(N*N*N)
True or False? O(N) is called linear time.
True or False? O(N) is called log time.
True or False? O(N*N) is called quadratic time.
True or False? O(1) is called constant time.
The Unsorted List ADT is to be extended with a Boolean member function, IsThere, which takes as a parameter an item of type ItemType and determines whether there is an element with this key in the list. 1. Write the specifications for this function. 2. Write the prototype for this function. 3.
Rather than enhancing the Unsorted List ADTs by adding a member function IsThere, you decide to write a client function to do the same task. 1. Write the specifications for this function. 2. Write the function definition. 3. Write a paragraph comparing the client function and the member function
An Unsorted Type ADT is to be extended by the addition of function SplitLists, which has the following specifications: 1. Implement SplitLists as an array-based member function of the Unsorted List ADT. 2. Implement SplitLists as a linked member function of the Unsorted List ADT.
Implement SplitLists described in Exercise 3 as a client function.An Unsorted Type ADT is to be extended by the addition of function SplitLists, which has the following specifications: Exercise 3 1. Implement SplitLists as an array-based member function of the Unsorted List ADT. 2. Implement
The specifications for the Unsorted List ADT state that the item to be deleted is in the list. 1. Rewrite the specification for DeleteItem so that the list is unchanged if the item to be deleted is not in the list. 2. Implement DeleteItem as specified in (a) using an array-based implementation. 3.
Redo Exercise 5(b) and 5(d), using a linked implementation.Exercise 5b. Rewrite the specification for Delete Item so that all copies of the item to be deleted are removed if they exist.d. Implement DeleteItem as specified in (c) using an array-based implementation.
7. 1. Explain the difference between an array-based and a linked representation of a list. 2. Give an example of a problem for which an array-based list would be the better solution. 3. Give an example of a problem for which a linked list would be the better solution.
True or False? If you answer False, correct the statement. 1. An array is a random-access structure. 2. A sequential list is a random-access structure. 3. A linked list is a random-access structure. 4. A sequential list is always stored in a statically allocated structure.
Give the values of the following expressions: 1. ptr1->info 2. ptr2->next->info 3. listData->next->next->info
Are the following expressions true or false? 1. listdata->next == ptr1 2. ptr1->next->info == 60 3. ptr2->next == NULL 4. listData->info == 25
Decide whether the syntax of each of the following statements is valid or invalid. If it is valid, mark it OK; if it is invalid, explain what is wrong. 1. listData->next = ptr1->next; 2. listData->next = *(ptr2->next); 3. *listData = ptr2; 4. ptr2 = ptr1->next->info; 5. ptr1->info = ptr2->info; 6.
Write one statement to do each of the following: 1. Make listData point to the node containing 45. 2. Make ptr2 point to the last node in the list. 3. Make listData point to an empty list. 4. Set the info member of the node containing 45 to 60.
An Unsorted List ADT is to be extended by the addition of a member function Head, which has the following precondition and postcondition:Precondition: list has been initialized and is not empty.Postcondition: return value is the last item inserted in the list. 1. Will this addition be easy to
An Unsorted List ADT is to be extended by the addition of function Tail, which has the following precondition and postcondition:Precondition: list has been initialized and is not empty.Postcondition: return value is a new list with the last item inserted in the list removed. 1. Will this addition
DeleteItem does not maintain the order of insertions because the algorithm swaps the last item into the position of the one being deleted and then decrements length. Would there be any advantage to having DeleteItem maintain the insertion order?Justify your answer. Statements int value; value =
Give a Big-O estimate of the run time for the functions you wrote in Exercises 5 and 6.Exercise 5The specifications for the Unsorted List ADT state that the item to be deleted is in the list. 1. Rewrite the specification for DeleteItem so that the list is unchanged if the item to be deleted is not
17. 1. Change the specifications for the array-based Unsorted List ADT so that PutItem throws an exception if the list is full. 2. Implement the revised specifications in (a). Statements int value; value = 500; char* charPtr; char string[10] = "Good luck"; charPtr = string; // Exercise 13 cout < <
Based on the following declarations, tell whether each statement below is syntactically legal (yes) or illegal (no). int* p; int*q; int* r; int a; int b; int c; int* p; int* q: int* r; int a; int b; int c; a. p = new int; b. q* = new int; C. a= new int; d. e. p = r; q = b; Yes /no f. g. h. r = C =
The following program has careless errors on several lines. Find and correct the errors and show the output where requested. #include int main () { } int* ptr: int* temp; int x; ptr = new int; *ptr = 4; *temp = *ptr; cout < < ptr X = 9; *temp = X; cout < < *ptr < < *temp; < < temp; ptr= new int;
Read the code segment and fill in blank #20. 1. NULL 2. True 3. false 4. listData 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: : DeleteItem(ItemType item) // Pre: Item is in list { } NodeType*
Read the code segment and fill in blank #21. 1. true 2. !found 3. false 4. moreToSearch 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: :DeleteItem(ItemType item) // Pre: Item is in list { } NodeType*
Read the code segment and fill in blank #22. 1. item. Compared To (listData->info) 2. item. Compared To (location->next) 3. item.ComparedTo(location->info) 4. item. Compared To (location) 5. answer not shown 4 Class UnsortedType { public: //all the prototypes go here. private: int length;
Read the code segment and fill in blank #23. 1. item 2. *location.next 3. (*location).next 4. predLoc 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: : DeleteItem(ItemType item) // Pre: Item is in list
Read the code segment and fill in blank #24. 1. false 2. true 3. predLoc == NULL 4. location != NULL 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: : DeleteItem(ItemType item) // Pre: Item is in list
Read the code segment and fill in blank #25. 1. preLoc 2. location 3. predLoc->next 4. location->next 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: : DeleteItem(ItemType item) // Pre: Item is
Read the code segment and fill in blank #26. 1. predLoc == NULL 2. location == NULL 3. predLoc == location 4. predLoc->next == NULL 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: :
Read the code segment and fill in blank #27. 1. predLoc 2. location 3. location->next 4. listData 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: : DeleteItem(ItemType item) // Pre: Item is in list
Read the code segment and fill in blank #28. 1. listData 2. predLoc->next 3. location->next 4. newNode->next 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int length; Node Type* listData; }; void UnsortedType: : DeleteItem(ItemType item) // Pre:
The Sorted List ADT is to be extended with a Boolean member function, Is There, which takes as a parameter an item of type Item Type and determines whether there is an element with this key in the list. 1. Write the specifications for this function. 2. Write the prototype for this function. 3.
Redo Exercise 1 (c) using a linked implementation.Exercise 1 (c) c. Write the array-based function definition using the binary search algorithm.
Rather than enhancing the Sorted List ADTs by adding a member function IsThere, you decide to write a client function to do the same task. 1. Write the specifications for this function. 2. Write the function definition. 3. Were you able to use the binary search algorithm?Explain your answer. 4.
Write a client function that merges two instances of the Sorted List ADT using the following specification. MergeLists(SortedType list1, SortedType list2, SortedType& result) 1. Write the prototype for MergeLists. 2. Write the function definition, using an array-based implementation. 3. Write
Rewrite Exercise 4, making MergeLists an array-based member function of the Sorted List ADT.Exercise 4Write a client function that merges two instances of the Sorted List ADT using the following specification. MergeLists(SortedType list1, SortedType list2, SortedType& result) 1. Write the
Rewrite Exercise 5, making MergeLists a linked member function of the Sorted List ADT.Exercise 5Rewrite Exercise 4, making MergeLists an array-based member function of the Sorted List ADT.Exercise 4Write a client function that merges two instances of the Sorted List ADT using the following
The specifications for the Sorted List ADT state that the item to be deleted is in the list. 1. Rewrite the specification for DeleteItem so that the list is unchanged if the item to be deleted is not in the list. 2. Implement DeleteItem as specified in (a) using an array-based implementation. 3.
A Sorted List ADT is to be extended by the addition of function SplitLists, which has the following specifications:SplitLists(SortedType list, ItemType item, SortedType& list1, SortedType& list2) 1. Implement SplitLists as a member function of the array-based Sorted List ADT. 2. Implement
A Sorted List ADT is to be extended by the addition of a member function Head, which has the following precondition and postcondition: 1. Will this addition be easy to implement in the arraybased SortedType? Explain. 2. Will this addition be easy to implement in linked SortedType? Explain.
A List ADT is to be extended by the addition of function Tail, which has the following precondition and postcondition: 1. Will this addition be easy to implement in the arraybased sortedType? Explain. 2. Will this addition be easy to implement in linked sortedType? Explain. Precondition:
1. Change the specifications for the Sorted List ADT so that PutItem throws an exception if the list is full. 2. Implement the revised specifications in (a) using an array-based implementation. 3. Implement the revised specifications in (a) using a linked implementation.
Write a class based on class UnsortedType as a bounded linked implementation. Provide a parameterized constructor that takes the maximum number of items as a parameter. If function PutItem is called when the list if full, throw an exception.
Write a class based on class SortedType as a bounded linked implementation. Provide a parameterized constructor that takes the maximum number of items as a parameter. If function PutItem is called when the list if full, throw an exception.
Write a class based on class UnsortedType as an unbounded array-based implementation. If the dynamically allocated array is full, create an array double the size and move the elements into it.
Write a class based on class SortedType as an unbounded arraybased implementation. If the dynamically allocated array is full, create an array double the size and move the elements into it.
What are the major steps in performing object-oriented design?
In the object-oriented design of an airline passenger reservation program, suppose that “airplane” has been identified as one object and “airplane seat” has been identified as another object. Focusing specifically on the airplane object, how does it relate to the airplane seat object?
The OOP phrase “instance variable” is equivalent to what C++ construct?
Showing 200 - 300
of 817
1
2
3
4
5
6
7
8
9
Step by Step Answers