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 copy constructor for PQType.
Implement a nonlinked representation of an AVL tree (see Chapter 8 for details regarding nonlinked tree representations).
Show the smallest Red-Black tree such that when a new node is inserted it violates property 4 of Red-Black trees, as discussed in Section 10.2 (if a node is labeled red, then its two child nodes must
Use the Three-Question Method to verify the ValueInList function described in this chapter.
Implement Red-Black tree insertion as described in this chapter.Note that you will need to include parent pointers and the Color type in the TreeNode struct and implement the ReStructure function
1. Show how the values in the array in Exercise 1 would have to be rearranged to satisfy the heap property. 2. Show how the array would look with four values in the sorted portion after
1. Show how the values in the array in Exercise 1 would be arranged immediately before the execution of the function Merge in the original (nonrecursive) call to MergeSort. 2. Show how the values in
Describe the graph pictured here, using the formal graph notation.V(StateGraph) =E(StateGraph) = Vermont Oregon Texas New York Alaska Hawaii California
For each of the following, describe at least two different abstractions for different viewers (see Figure 1.1).1. A dress2. An aspirin3. A carrot4. A key5. A saxophone6. A piece of wood Analysis
Use the linked lists contained in the array pictured in Figure 6.19 to answer the following questions: 1. What elements are in the list pointed to by list1? 2. What elements are in the list pointed
1. What does the level of a binary search tree mean in relation to its searching efficiency? 2. What is the maximum number of levels that a binary search tree with 100 nodes can have? 3. What is the
Which of these formulas gives the maximum total number of nodes in a tree that has N levels? (Remember that the root is Level 0.) 1. N - 1 N 2.2 N 3.2 - 1 N+1 4.2
Which of these formulas gives the maximum number of nodes in the Nth level of a binary tree? 1. N N 2.2 N+1 3.2 N 4.2 - 1
How many ancestors does a node in the Nth level of a binary search tree have?
1. How many different binary trees can be made from three nodes that contain the key values 1, 2, and 3? 2. How many different binary search trees can be made from three nodes that contain the key
Draw all possible binary trees that have four leaves where all nonleaf nodes have two children.
The TreeType class used a queue as an auxiliary storage structure for iterating through the elements in the tree. Discuss the relative merits of using a dynamically allocated array-based queue versus
1. What are the ancestors of node P? 2. What are the descendants of node K? 3. What is the maximum possible number of nodes in the tree at the level of node W? 4. What is the maximum possible
Show what the tree would look like after each of the following changes. (Use the original tree to answer each part.) 1. Add node C. 2. Add node Z. 3. Add node X. 4. Delete node M. 5. Delete node
Show the order in which the nodes in the tree are processed by 1. an inorder traversal of the tree. 2.a postorder traversal of the tree. 3.a preorder traversal of the tree. B tree D K J M N Q P R T W
Draw the binary search tree whose elements are inserted in the following order:50 72 96 94 107 26 12 11 9 2 10 25 51 16 17 95
1. What is the height of the tree? 2. What nodes are on Level 3? 3. Which levels have the maximum number of nodes that they could contain? 4. What is the maximum height of a binary search tree
1. Trace the path that would be followed in searching for a node containing 61. 2. Trace the path that would be followed in searching for a node containing 28. 11 22 23 tree 47 29 49 30 56 59 61 69
Show the order in which the nodes in the tree are processed by 1. an inorder traversal of the tree. 2. a postorder traversal of the tree. 3. a preorder traversal of the tree. 11 22 23 tree 47 29 49
Show how the tree would look after the deletion of 29, 59, and 47. 11 22 23 tree 47 29 49 30 56 59 61 69 62 64
Show how the (original) tree would look after the insertion of nodes containing 63, 77, 76, 48, 9, and 10 (in that order). 11 22 23 tree 47 29 49 30 56 59 61 69 62 64
True or false? 1. Invoking the delete function in this chapter might create a tree with more levels than the original tree had. 2. A preorder traversal processes the nodes in a tree in the exact
If you wanted to traverse a tree, writing all the elements to a file, and then, the next time you ran the program, rebuild the tree by reading and inserting, would an inorder traversal be
1. A total of 100 integer elements are chosen at random and inserted into a sorted linked list and a binary search tree.Describe the efficiency of searching for an element in each structure, in terms
The key of each node in a binary search tree is a short character string. 1. Show how such a tree would look after the following words were inserted (in the order indicated): monkey canary donkey
Write a function called PtrToSuccessor that finds a node with the smallest key value in a tree, unlinks it from the tree, and returns a pointer to the unlinked node.
Modify the DeleteNode function so that it uses the immediate successor (rather than the predecessor) of the value to be deleted in the case of deleting a node with two children. You should call the
Use the Three-Question Method from Chapter 7 to verify the recursive function Insert.
Use the Three-Question Method to verify the recursive function Delete.
Write IsFull and IsEmpty for the iterative version of class TreeType.
Add a TreeType member function Ancestors that prints the ancestors of a given node whose info member contains value. Do not print value. 1. Write the declaration. 2. Write the iterative
Write a recursive version of the function Ancestors described in Exercise 26.Exercise 26.Add a TreeType member function Ancestors that prints the ancestors of a given node whose info member contains
Write a recursive version of Ancestors (see Exercise 27) that prints out the ancestors in reverse order (first the parent, then the grandparent, and so on).Exercise 27Add a TreeType member function
Add a Boolean member function IsBST to the class TreeType that determines whether a binary tree is a binary search tree.comments. 2. Write a recursive implementation of this function.
Extend the Binary Search Tree ADT to include the member function LeafCount that returns the number of leaf nodes in the tree.
Extend the Binary Search Tree ADT to include the member function SingleParentCount that returns the number of nodes in the tree that have only one child.
Write a client function that returns a count of the nodes that contain a value less than the parameter value.
Extend the Binary Search Tree ADT to include a Boolean function SimilarTrees that receives pointers to two binary trees and determines whether the shapes of the trees are the same. (The nodes do not
The TreeType member function MirrorImage creates and returns a mirror image of the tree. 1. Write the declaration of the function MirrorImage.Include adequate comments. 2. Write the body of the
Write a client function MakeTree that creates a binary search tree from the elements in a sorted list of integers. You cannot traverse the list inserting the elements in order, as that would produce
Write a client Boolean function MatchingItems that determines whether a binary search tree and a sequential list contain the same values.
If an item is to be inserted whose key value is less than the key value in node 1, but greater than the key value in node 5, where would it be inserted?The numbers on the nodes are labels so that we
If node 1 is to be deleted, the value in which node could be used to replace it?The numbers on the nodes are labels so that we can talk about the nodes; they are not key values within the nodes. 4 2
The numbers on the nodes are labels so that we can talk about the nodes; they are not key values within the nodes.4 2 7 5 1 6 8 3 is a traversal of the tree in which order? 4 2 5 1 9 3 8
1 2 4 5 7 3 6 8 is a traversal of the tree in which order?The numbers on the nodes are labels so that we can talk about the nodes; they are not key values within the nodes. 4 2 5 1 9 3 8
In Chapter 6, we discussed how to store a linked list in an array of nodes using index values as pointers and managing our list of free nodes. We can use these same techniques to store the nodes of a
Implement the Binary Search Tree ADT as a template class.
1. Which of the following trees are complete? 2. Which of the following trees are full? 12 tree 16 tree 20 19 14 40 tree 4 9 27 46 50 26 65 5 42 32 40 8 50 20 12 tree 44 19 tree tree 8 48 1 46 2 45
The elements in a binary tree are to be stored in an array, as described in the chapter. Each element is a nonnegative int value. 1. What value can you use as the dummy value, if the binary tree is
The elements in a complete binary tree are to be stored in an array, as described in the chapter. Each element is a nonnegative int value. Show the contents of the array, given the following tree.
Given the following array, draw the binary tree that can be created from its elements. The elements are arranged in the array as discussed in the chapter. tree.elements [0] [1] [2] [3] [4] [5] [6]
A binary tree is stored in an array called treeNodes, which is indexed from 0 to 99, as described in the chapter. The tree contains 85 elements. Mark each of the following statements as True or
A priority queue containing characters is implemented as a heap stored in an array. The precondition states that this priority queue cannot contain duplicate elements. Currently, the priority queue
A minimum heap has the following order property: The value of each element is less than or equal to the value of each of its children. What changes must be made in the heap operations given in this
1. Write a nonrecursive version of ReheapDown. 2. Write a nonrecursive version of ReheapUp. 3. Describe the nonrecursive versions of these operations in terms of Big-O notation.
A priority queue is implemented as a heap:1. Show how the heap would look after this series of operations: 2. What would the values of x, y, and z be after the series of operations in part (a)? 25
A priority queue is implemented as a linked list, sorted from largest to smallest element. 1. How would the definition of PQType change? 2. Write the Enqueue operation using this implementation. 3.
A priority queue is implemented as a binary search tree. 1. How would the definition of PQType change? 2. Write the Enqueue operation using this implementation. 3. Write the Dequeue operation using
A priority queue is implemented as a sequential array-based list.The highest-priority item is in the first array position, the secondhighest-priority item is in the second array position, and so on.
A stack is implemented using a priority queue. Each element is time-stamped as it is put into the stack. (The time stamp is a number between 0 and INT_MAX. Each time an element is pushed onto the
A FIFO queue is implemented using a priority queue. Each element is time-stamped as it is put into the queue. (The time stamp is a number between 0 and INT_MAX. Each time an element is enqueued, it
A priority queue of strings is implemented using a heap. The heap contains the following elements: 1. What feature of these strings is used to determine their priority in the priority queue? 2. Show
True or False? A full binary tree has all the leaf nodes on the same level, and every nonleaf node has one or two children.
True or False? A heap is built using pointer variables.
True or False? A heap must be a complete binary tree.
True or False? When a binary tree is stored in an array using implicit links, it is much easier to access the parent of a node than when the tree is stored using explicit links.
True or False? When a complete binary tree is stored in an array using implicit links, the leaves are in the nodes indexed by numElements/2 through numElements.
True or False? A heap can be a full binary tree.
Provide a list of ten elements in insertion order leading to a binary tree that is an example of a degenerate tree with O(N) search performance after all elements are inserted. Explain why this
Explain the difference between binary search trees and selfbalancing binary search trees.
Define the term balance factor as it relates to AVL trees.
Draw an AVL tree whose elements are the letters A–Z. Label each node with its balance factor. Draw a second non-AVL tree whose elements are from A–Z. Label each node with its balance factor and
Draw the binary search tree whose elements are inserted in the following order: 17 11 22 5 13 19 20 Is the resulting tree an AVL tree? Explain why or why not.
Which of the supported operations on an AVL tree ADT could result in an unbalanced tree? Show an example of a tree before and after these operations are applied and explain why it leads to an
Add the elements 7 and 8 to the balanced AVL tree in Figure 10.2e.Is the tree still balanced? If not, identify the unbalanced node and which rotation operation should be applied. Redraw the tree,
Add the elements 1 and 0 to the balanced AVL tree in Figure 10.2e.Is the tree still balanced? If not, identify the unbalanced node and which rotation operation should be applied. Redraw the tree,
Extend the AVL tree implementation discussed in this chapter to support node deletion. In particular, modify the DeleteItem method of the TreeType class and the helper function Delete (originally
The implementation of AVL trees described in this chapter introduced two helper methods, Difference and Height, to compute the balance factor of a given node. Another approach would be to store the
Consider the following elements in insertion order for each of the trees T :T : 50 40 60 30 41 55 67 51 57 63 70 69 74 T : 50 40 60 30 41 55 67 51 57 63 70 T : 50 40 60 30 45 55 67 25 33 63 70 Draw
Consider the following elements: 5 10 15 20 25 30 35 40 45 50 55 60 1. Insert each element into an initially empty AVL tree.Draw the tree at each insertion step and indicate any rotation operations
Define the black-height of a Red-Black tree. Draw a valid Red-Black tree of at least 15 nodes, with properly colored nodes, and indicate the black-height of its root node.
Reimplement the binary search tree implementation from Chapter 8 to include parent pointers. This will require changes to all methods and functions that add, remove, or manipulate nodes.
Could you implement Red-Black trees without explicit parent pointers? Describe an alternate approach to implementing Red-Black trees without parent pointers. What is the tradeoff in doing so?
For each of the following tree ADTs, suggest an example application that may benefit from the structure and properties of that tree. 1. Binary search tree 2. AVL tree 3. Red-Black tree 4. B-tree
Draw a B-tree of order 3 and height 3 where each node is full.
Show an example of an insertion into the tree from question 20 that causes a split. Draw the B-tree after the split operation is applied.
Draw a B-tree of order 4 and height 3 containing the fewest elements. Show an example of a split that would be applied by inserting the fewest number of elements.
Distinguish between set representations that are implicit and those that are explicit.
Finish designing the algorithms for the explicit set representation.
Finish designing the algorithms for the implicit set representation.
True or False? The explicit representation of a set uses a bit vector.
True or False? The implicit representation of a set uses the list ADT.
True or False? Set operations using the explicit representation use Boolean operations.
True or False? The explicit representation of a set uses the list ADT.
True or False? The Big-O complexity of implicitly represented binary set operations is the same for SortedList and UnsortedList.
Showing 1 - 100
of 818
1
2
3
4
5
6
7
8
9