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
Implement the Map ADT using the binary search tree as discussed in the chapter.
Why did we define the Map ADT to not allow duplicate key values?
What does the MapADT return when an item is found?
For the Map ADT, ItemType contains a key and a value. When performing a Find operation on a map, we pass it an ItemType object. What should the value field of that object contain?
True or False? When performing a Find operation on a map, if the item is found, the key in the returned ItemType object is the same as what was passed into the function.
True or False? When performing a Find operation on a map, if the item is not present, then the value in the returned ItemType object is the same as what was passed into the function.
How do we tell if a Find operation on a map was successful?
When performing a Store operation on a map, if the item is already present, the map is not changed. If you want to change the value associated with that item’s key, how would you do so?
How could a map be used to implement the Set ADT?
Change the implementation of the Map ADT’s Find operation as discussed in this chapter, so that item is a reference parameter and Find returns a bool result, indicating whether the key was found.
Store the values in a hash table with 20 positions, using the division method of hashing and the linear probing method of resolving collisions.66 47 87 90 126 140 145 153 177 285 393 395 467 566 620
Store the values in a hash table with 20 positions, using rehashing as the method of collision resolution. Use key % tableSize as the hash function, and (key + 3) % tableSize as the rehash
Store the values in a hash table with ten buckets, each containing three slots. If a bucket is full, use the next (sequential) bucket that contains a free slot.66 47 87 90 126 140 145 153 177 285 393
Store the values in a hash table that uses the hash function key % 10 to determine into which of ten chains to put the value.66 47 87 90 126 140 145 153 177 285 393 395 467 566 620 735
Fill in the following table, showing the number of comparisons needed to find each value using the hashing representations given in Exercises 19–22.Exercises 19–22.19. Store the values in a hash
True or False? Correct any false statements.1. When a hash function is used to determine the placement of elements in an array, the order in which the elements are added does not affect the resulting
Choose the answer that correctly completes the following sentence: The number of comparisons required to find an element in a hash table with N buckets, of which M are full,1. is always 1.2. is
Show the contents of the array 2. SelectionSort 3. InsertionSort 43 [0] 7 [1] 10 [2] 23 [3] 18. [4] 4 [5] 19 [6] 5 [7] 66 [8] 14 [9]
Given the arraytell which sorting algorithm would produce the following results after four iterations: 26 [0] 24 [1] 3 [2] 17 [3] 25 [4] 24 [5] 13 [6] 60 [7] 47 [8] [9]
How many comparisons would be needed to sort an array containing 100 elements using ShortBubble 1. in the worst case? 2. in the best case?
A sorting function is called to sort a list of 100 integers that have been read from a file. If all 100 values are zero, what would the execution requirements (in terms of Big-O notation) be if the
How many comparisons would be needed to sort an array containing 100 elements using SelectionSort if the original array values were already sorted? 1. 10,000 2. 9,900 3. 4,950 4. 99 5. None of
A merge sort is used to sort an array of 1,000 test scores in descending order. Which of the following statements is true? 1. The sort is fastest if the original test scores are sorted from smallest
A list is sorted from smallest to largest when a sort algorithm is called. Which of the following sorts would take the longest time to execute, and which would take the shortest time? 1. QuickSort,
1. In what cases, if any, is the bubble sort O(N)? 2. In what cases, if any, is the selection sort O(log N)? 3. In what cases, if any, is quick sort O(N )?
A very large array of elements is to be sorted. The program will be run on a personal computer with limited memory. Which sort would be a better choice: a heap sort or a merge sort? Why?
Use the Three-Question Method to verify MergeSort.
True or false? Correct the false statements. 1. MergeSort requires more space to execute than HeapSort. 2. QuickSort (using the first element as the split value) is better for nearly sorted data than
Which of the following is true about QuickSort? 1. A recursive version executes faster than a nonrecursive version. 2. A recursive version has fewer lines of code than a nonrecursive version. 3. A
What is meant by the statement “Programmer time is an efficiency consideration”? Give an example of a situation in which programmer time is used to justify the choice of an algorithm(possibly at
Identify one or more correct answers: Reordering an array of pointers to list elements, rather than sorting the elements themselves, is a good idea when 1. the number of elements is very large. 2.
Go through the sorting algorithms coded in this chapter and determine which ones are stable as coded. If there are unstable algorithms (other than HeapSort), make them stable.
Give arguments for and against using functions (such as Swap) to encapsulate frequently used code in a sorting routine.
Write a version of the bubble sort algorithm that sorts a list of integers in descending order.
We said that HeapSort is inherently unstable. Explain why.
Sooey County is about to have its annual Big Pig Contest. Because the sheriff’s son, Wilbur, is majoring in computer science, the county hires him to computerize the Big Pig judging. Each pig’s
State University needs a listing of the overall SAT percentiles of the 14,226 students it has accepted in the past year. The data are in a text file, with one line per student. That line contains the
Which sorting algorithm would you not use under the following conditions? 1. The sort must be stable. 2. Data are in descending order by key. 3. Data are in ascending order by key. 4. Space is very
Determine the Big-O measure for SelectionSort based on the number of elements moved rather than the number of comparisons 1. for the best case. 2. for the worst case.
Determine the Big-O measure for BubbleSort based on the number of elements moved rather than the number of comparisons 1. for the best case. 2. for the worst case.
Determine the Big-O measure for QuickSort based on the number of elements moved rather than the number of comparisons 1. for the best case. 2. for the worst case.
Determine the Big-O measure for MergeSort based on the number of elements moved rather than the number of comparisons 1. for the best case. 2. for the worst case.
How would you modify the radix sort algorithm to sort the list in descending order?
The radix sort algorithm uses an array of queues. Would an array of stacks work just as well?
On the Web, the Sorts.in file contains a minimal test plan for the sorting algorithms we have studied. Design a more comprehensive test plan and apply it using SortDr.cpp.
Run the parallel merge sort on your own computer, trying various chunk sizes, to see how much speed-up you can obtain from the available parallelism.
The C++ thread library provides a function that returns the number of threads that the hardware is capable of running. Modify the parallel merge sort so that the user specifies a minimum chunk size.
Comparing the results of your experiments in Exercise 31 with the performance obtained from the approach in Exercise 32, does using a thread count that is greater than the number available from the
One approach to using parallelism with the radix sort is to divide the array into separate sections and have a separate thread examine each section, taking each value in turn and calling enqueue to
Another way to add parallelism to the radix sort would be to turn the process around and have a thread for each queue. Each thread reads the entire array, looking for the values that should be
Draw a picture of EmployeeGraph. EmployeeGraph V(EmployeeGraph) E(EmployeeGraph) = (V, E) {Susan, Darlene, Mike, Fred, John, Sander, Lance, Jean, Brent, Fran} = = {(Susan, Darlene), (Fred, Brent),
Draw EmployeeGraph, implemented as an adjacency matrix.Store the vertex values in alphabetical order. EmployeeGraph V(EmployeeGraph) E(EmployeeGraph) = (V, E) {Susan, Darlene, Mike, Fred, John,
Using the adjacency matrix for EmployeeGraph from Exercise 12, describe the path from Susan to Lance 1. using a breadth- first strategy. 2. using a depth-first strategy. Exercise 12Extend the
Which one of the following phrases best describes the relationship represented by the edges between the vertices in EmployeeGraph? 1. “works for” 2. “is the supervisor of” 3. “is senior
Draw a picture of ZooGraph. ZooGraph V(ZooGraph) E(ZooGraph) = (V, E) = {dog, cat, animal, vertebrate, oyster, shellfish, invertebrate, crab, poodle, monkey, banana, dalmatian, dachshund} =
Draw the adjacency matrix for ZooGraph. Store the vertices in alphabetical order. ZooGraph V(ZooGraph) E(ZooGraph) = (V, E) = {dog, cat, animal, vertebrate, oyster, shellfish, invertebrate, crab,
To tell if one element in ZooGraph has relation X to another element, you look for a path between them. Show whether the following statements are true, using the picture or adjacency matrix. 1.
Which of the following phrases best describes relation X in Exercise 7? 1. “has a” 2. “is an example of” 3. “is a generalization of” 4. “eats”Exercise 7 To tell if one element in
1. Is there a path from Oregon to any other state in the graph? 2. Is there a path from Hawaii to every other state in the graph? 3. From which states in the graph is there a path to Hawaii?
1. Show the adjacency matrix that would describe the edges in the graph. Store the vertices in alphabetical order. 2. Show the array-of-pointers adjacency lists that would describe the edges in the
Extend the class GraphType in this chapter to include a Boolean EdgeExists operation, which determines whether two vertices are connected by an edge. 1. Write the declaration of this function.
Extend the class GraphType in this chapter to include a DeleteEdge operation, which deletes a given edge. 1. Write the declaration of this function. Include adequate comments. 2. Using the adjacency
Extend the class GraphType in this chapter to include a DeleteVertex operation, which deletes a vertex from the graph.Deleting a vertex from a graph is more complicated than deleting an edge. Discuss
The DepthFirstSearch operation can be implemented without a stack by using recursion. 1. Name the base cases. Name the general cases. 2. Write the algorithm for a recursive depth-first search.
Why did we not include traversal operations in GraphType?
Did you notice that we did not include a copy constructor for GraphType? Discuss the issues involved in implementing this copy constructor.
True or False? A binary tree is a type of graph.
True or False? A stack is a type of graph.
True or False? A graph vertex cannot have an edge that connects to itself.
True or False? In an undirected graph, if there is a path from vertex A to vertex B, there is a path from B to A.
True or False? An array representing an adjacency matrix has as many elements as there are edges in the graph.
How many edges are in a complete undirected graph with N vertices?
How many edges are in a complete directed graph with N vertices?
If a graph has 100 vertices and 1,000 edges, what fraction of the array representing its adjacency matrix is filled with NULL_EDGE values?
Explain what we mean by “software engineering.”
Which of these statements is always true? 1. All of the program requirements must be completely defined before design begins. 2. All of the program design must be complete before any coding
Name three computer hardware tools that you have used.
Name two software tools that you have used in developing computer programs.
Explain what we mean by “ideaware.”
Explain why software might need to be modified 1. in the design phase. 2. in the coding phase. 3. in the testing phase. 4. in the maintenance phase.
Software quality goal 4 says, “Quality software is completed on time and within budget.” 1. Explain some of the consequences of not meeting this goal for a student preparing a class programming
Functional decomposition is based on a hierarchy of ____________________, and object-oriented design is based on a hierarchy of ____________________.
What is the difference between an object and an object class? Give some examples.
Make a list of potential objects from the description of the ATM scenario given in this chapter.
Have you ever written a programming assignment with an error in the specifications? If so, at what point did you catch the error?How damaging was the error to your design and code?
Explain why the cost of fixing an error is higher the later in the software cycle that the error is detected.
Explain how an expert understanding of your programming language can reduce the amount of time you spend debugging.
Give an example of a run-time error that might occur as the result of a programmer making too many assumptions.
Define “robustness.” How can programmers make their programs more robust by taking a defensive approach?
The following program has three separate errors, each of which would cause an infinite loop. As a member of the inspection team, you could save the programmer a lot of testing time by finding the
Is there any way a single programmer (for example, a student working alone on a programming assignment) can benefit from some of the ideas behind the inspection process?
When is it appropriate to start planning a program’s testing? 1. During design or even earlier 2. While coding 3. As soon as the coding is complete
Differentiate between unit testing and integration testing.
Explain the advantages and disadvantages of the following debugging techniques: 1. Inserting output statements that may be turned off by commenting them out 2. Using a Boolean flag to turn debugging
Describe a realistic goal-oriented approach to data-coverage testing of the function specified below: FindElement(list, targetltem, index, found) Search list for targetItem. Elements of list are in
A program is to read a numeric score (0 to 100) and display an appropriate letter grade (A, B, C, D, or F). 1. What is the functional domain of this program? 2.Is exhaustive data coverage possible
Explain how paths and branches relate to code coverage in testing.Can we attempt 100% path coverage?
Differentiate between “top-down” and “bottom-up” integration testing.
Explain the phrase “life-cycle verification.”
Write the corrected version of the function Divide.
Showing 100 - 200
of 818
1
2
3
4
5
6
7
8
9