All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
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
Ask a Question
Search
Search
Sign In
Register
study help
computer science
programming language pragmatics
Questions and Answers of
Programming Language Pragmatics
The OOP phrase “message passing” is equivalent to what C++ construct?
Define responsibility and distinguish between an action responsibility and a knowledge responsibility.
What are the three ways that two classes can relate to one another?
How can you avoid including a header file multiple times?
Indicate whether a stack would be a suitable data structure for each of the following applications.1. A program to evaluate arithmetic expressions according to the specific order of operators 2. A
Describe the accessing protocol of a stack at the abstract level.
Show what is written by the following segments of code, given that item1, item2, and item3 are int variables. 1. StackType stack; item1 = 1; item2 = 0; item3 = 4; stack.Push(item2);
The stack is implemented as a class containing an array of items, a data member indicating the index of the last item put on the stack(top), and two Boolean data members, underFlow and overFlow. The
The stack is implemented as a class containing an array of items, a data member indicating the index of the last item put on the stack(top), and two Boolean data members, underFlow and overFlow. The
The stack is implemented as a class containing an array of items, a data member indicating the index of the last item put on the stack(top), and two Boolean data members, underFlow and overFlow. The
The stack is implemented as a class containing an array of items, a data member indicating the index of the last item put on the stack(top), and two Boolean data members, underFlow and overFlow. The
Write a segment of code to perform each of the following operations. You may call any of the member functions of StackType. The details of the stack type are encapsulated; you may use only the stack
(Multiple choice) The statement(setting the top element equal to the second element) in a client program of the stack class 1. would cause a syntax error at compile time.2. would cause a run-time
(Multiple choice) The statementsin the client program 1. would cause a syntax error at compile time.2. would cause a run-time error.3. would be legal, but would violate the encapsulation of the
Given the following specification of the Top operation:ItemType TopAssume Top is not a stack operation and Pop returns the item removed. Write this function as client code, using operations from the
Two stacks of positive integers are needed, one containing elements with values less than or equal to 1,000 and the other containing elements with values larger than 1,000. The total number of
A stack of integer elements is implemented as an array. The index of the top element is kept in position 0 in the array, and the stack elements are stored in stack[1].. stack[stack[0]}.1. How does
Using one or more stacks, write a code segment to read a string of characters and determine whether it forms a palindrome. A palindrome is a sequence of characters that reads the same both forward
Write the body for a function that replaces each copy of an item in a stack with another item. Use the following specification. (This function is in the client program.)ReplaceItem(StackType&
In each plastic container of Pez candy, the colors are stored in random order. Your little brother likes only the yellow ones, so he painstakingly takes out all the candies, one by one, eats the
The specifications for the Stack ADT have been changed. The class representing the stack must now check for overflow and underflow and set an error flag (a parameter) to true if either occurs.1.
Implement the following specification for a client Boolean function that returns true if two stacks are identical and false otherwise.Boolean Identical(StackType stack1, StackType stack2)You may use
Is a count-controlled loop going from 1 through 5. At each iteration, the loop counter is either printed or put on a stack depending on the result of the Boolean function RanFun(). (The behavior of
Is a count-controlled loop going from 1 through 5. At each iteration, the loop counter is either printed or put on a stack depending on the result of the Boolean function RanFun(). (The behavior of
Describe the accessing protocol of a queue at the abstract level.
Show what is written by the following segments of code, given that item1, item2, and item3 are int variables.1.2. Que Type queue; item1 = 1; item2 = 0; item3 = 4; queue. Enqueue (item2); queue.
The specifications for the Queue ADT have been changed. The class representing the queue must now check for overflow and underflow and set an error flag (a parameter) to true if either occurs.1.
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue(rear), a data member indicating the index of the location before
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue(rear), a data member indicating the index of the location before
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue(rear), a data member indicating the index of the location before
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue(rear), a data member indicating the index of the location before
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue(rear), a data member indicating the index of the location before
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue(rear), a data member indicating the index of the location before
Write a segment of code to perform each of the following operations. You may call any of the member functions of QueType. The details of the queue are encapsulated; you may use only the queue
(Multiple choice) The statement(setting one element equal to the next element) in a client program of the queue class 1. would cause a syntax error at compile time.2. would cause a run-time error.3.
(Multiple choice) The statementsin the client program 1. would cause a syntax error at compile time.2. would cause a run-time error.3. would be legal, but would violate the encapsulation of the
Given the following specification of a Front operation:1. Write this function as client code, using operations from the QueType class. (Remember—the client code has no access to the private members
Write the body for a function that replaces each copy of an item in a queue with another item. Use the following specification. (This function is in the client program.)You may use any of the member
Indicate whether each of the following applications would be suitable for a queue.1. An ailing company wants to evaluate employee records so as to lay off some workers on the basis of service
Implement the following specification for a Boolean function in the client program that returns true if two queues are identical and false otherwise.You may use any of the member functions of
Implement the following specification for an integer function in the client program that returns the number of items in a queue.The queue is unchanged. int GetLength(QueType queue) Function:
One queue implementation discussed in this chapter dedicated an unused cell before the front of the queue to distinguish between a full queue and an empty queue. Write another queue implementation
Write a queue application that determines if two files are the same.
Discuss the difference between the MakeEmpty operation in the specification and a class constructor.The following code segment (used for Exercises 41 and 42) is a count-controlled loop going from 1
The following output is possible using a queue: 1 2 3 4 5 1. True 2. False 3. Not enough information to determine
The following output is possible using a queue: 1 3 5 4 2 1. True 2. False 3. Not enough information to determine
Change the code for the program Balanced on page 283 so that the calls to Push, Pop, and Top are embedded within a try clause. The catch clause should print an appropriate error message and halt.
Define and implement a counted stack, which inherits from StackType.
Create UML diagrams for the ADTs implemented in this chapter.
Dummy nodes are used to simplify list processing by eliminating some “special case.” 1. What special case is eliminated by a header node in a linear linked list? 2. What special case is
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
Can you derive a DLList type from the SpecializedList class that has a member function called PutItem that inserts the item into its proper place in the list? If so, derive the class and implement
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 Copy member function of the Stack ADT, assuming that self is copied into the stack named in the parameter list.
Using the circular doubly linked list shown here, give the expression corresponding to each of the following descriptions:(For example, the expression for the info member of Node 1, referenced from
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
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? 1. You want to search a
What is the Big-O measure for initializing the free list in the arraybased linked implementation? For the GetNode and FreeNode functions?
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. 1. Show how the array would look
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.
Rewrite SortedType (array-based) using templates.
Rewrite SortedType (linked) using templates.
Rewrite StackType (linked) using templates.
Rewrite QueType (linked) using templates.
Replace the ComparedTo function in an array-based UnsortedList by assuming that member functions of the ItemType class overload the relational operators.
Create the Unified Modeling Language (UML) diagrams for class LargeInt.
True or False? A doubly linked list has two pointers in each node.
True or False? A header node is a placeholder node at the beginning of a list, which is used to simplify list processing.
True or False? A trailer node is not syntactically different from the other nodes in the list.
True or False? A trailer node is not logically different from the other nodes in the list.
True or False? A trailer node is a placeholder node at the end of a list, which is used to simplify list processing.
True or False? A programmer, using inheritance to specialize a class X, needs access to the source code for X’s implementation.
True or False? In C++, a derived class’s constructor is executed after its base class constructor is executed.
True or False? For a C++ derived class to override an inherited member function, the base class is required to declare the function to be virtual.
Explain what is meant by the following: 1. base case 2. general (or recursive) case 3. run-time stack 4. binding time 5. tail recursion
True or false? If false, correct the statement. Recursive functions: 1. often have fewer local variables than the equivalent nonrecursive routines. 2. generally use while or for statements as their
Describe the Three-Question Method of verifying recursive routines in relation to an inductive proof.
Which data structure would you most likely see in a nonrecursive implementation of a recursive algorithm?
Using the recursive function RevPrint as a model, write the recursive function PrintList, which traverses the elements in the list in forward order. Does one of these routines constitute a better use
Identify the following: 1. the base case or cases of the function Puzzle 2. the general case or cases of the function Puzzle
Show what would be written by the following calls to the recursive function Puzzle: 1. cout int Puzzle(int base, int limit) { } if (base > limit) return -1; else if (base == limit) return 1; else
Given the following function:1. Is there a constraint on the values that can be passed as a parameter for this function to answer the Smaller-Caller Question? 2. Is Func(7) a good call? If so, what
Put comments on the following routines to identify the base and general cases and explain what each routine does. 1. 2. int Power (int base, int exponent) { } if (exponent == 0) return 1; } else
1. Fill in the blanks to complete the following recursive function: 2. Which is the base case and which is the general case? 3. Show how you would call this function to sum all the elements in an
You must assign the grades for a programming class. The class is studying recursion, and students have been given this simple assignment: Write a recursive function SumSquares that takes a pointer to
The Fibonacci sequence is the series of integersSee the pattern? Each element in the series is the sum of the preceding two items. There is a recursive formula for calculating the nth number of the
The following defines a function that calculates an approximation of the square root of a number, starting with an approximate answer (approx), within the specified tolerance (tol).1. What
A sequential search member function of SortedType has the following prototype: void SortedType::Search(int value, bool& found); 1. Write the function definition as a recursive search, assuming a
We want to count the number of possible paths to move from row 1, column 1 to row N, column N in a two-dimensional grid. Steps are restricted to going up or to the right, but not diagonally. The
Given the following function: 1. What problems come up in verifying this function? 2. How many recursive calls are made by the following initial calls? int Ulam(int num) { } if (num < 2) return 1;
Explain the relationship between dynamic storage allocation and recursion.
What do we mean by binding time, and what does it have to do with recursion?
Given the following values in list:Show the contents of the run-time stack during the execution of this call to BinarySearch: list .length .info 10 2 [0] 6 [1] 9 [2] 14 [3] 23 [4] 65 [5] 92 [6] 699
The parameter to the following two recursive routines is a pointer to a singly linked list of numbers, whose elements are unique (no duplicates) and unsorted. Each node in the list contains two
True or false? If false, correct the statement. A recursive solution should be used when: 1. computing time is critical. 2. the nonrecursive solution would be longer and more difficult to write. 3.
Showing 300 - 400
of 818
1
2
3
4
5
6
7
8
9