Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Algorithm Design and Analysis

Directions: Please complete each of the following exercises. Please read the instructions carefully.

For all "short programming assignments," include source code files in your submission.

1. The following refer to symbol table implementations.

a. What is the benefit of using a key-indexed array implementation?
b. Give a circumstance under which a key-indexed array implementation is inappropriate.

2. Short programming assignment. Implement the array-based symbol table from program 12.5, adding a remove operation.

3. In the following sorted file we are searching for J. Show the values that would be checked at each step for both a binary search and an interpolation search. Show all calculations.

A A B E F H J M N N N N O P P P P P R R R R T T T Z Z Z Z Z Z Z

4. The following refer to binary search trees.

a. Draw the binary search tree that results when the keys I N S E R T M D (in that order) are inserted into an initially empty tree.
b. Explain why searching and insertion may still require N operations in the worst case for binary search trees.

5. The following refer to indexed implementations of symbols tables.

a. What is the advantage of an indexed implementation when table items are large?
b. When is an indexed implementation inappropriate?

6. Using the algorithm represented in Programs 12.13 and 12.12, show the BST that results from inserting D into the following:

7. The following refer to methods of providing guaranteed performance for search trees.

a. Explain how the algorithm in Program 13.1 results in a balanced tree.
b. Explain the difference between randomized, amortized, and optimized approaches to gauranteed performance.
c. Why does a randomized BST require that each node store the count of nodes in the subtree?

8. The following refer to splay BSTs.

a. What is the difference between a splay BST and an ordinary BST?
b. Draw the splay BST that results when you insert the items I N S E R T M D into an initially empty tree.

9. Convert the following 2-3-4 tree into a red-black tree:

10. The following refer to skip lists.

a. Explain the trade-offs resulting from increasing and decreasing the parameter t.
b. Draw the skip list that results from inserting the keys I N S E R T M into an initially empty list, assuming that randX returns the sequence 1 1 2 1 3 2 3.

 

Program 12.12 Rotations in BST's

These twin routines perform the rotation operation on a BST. A right rotation makes the old root the right subtree of the new root (the old left subtree of the root); a left rotation makes the old root the left subtree of the new root (the old right subtree of the root). For implementations where a count field is maintained in the nodes (for example, to support select, as we will see in Section 14.9), we need also to exchange the count fields in the nodes involved in the rotation.

void rotR(link& h)

{ link x = h->1; h->1 = x->r; x->r = h; h = x; }

void rotL(link& h)

{ link x = h->r; h->r = x->1; x->1 = h; h = x; }

Program 12.13 Root insertion in BSTs

With the rotation functions in Program i z. z 2, a recursive function that inserts a new node at the root of a BST is immediate: Insert the new item at the root in the appropriate subtree, then perform the appropriate rotation to bring it to the root of the main tree.

private:

void insertT(link& h, Item x)

{ if (h == 0) { h = new node(x); return;

if (x.key() < h->item.key())

{ insertT(h->l, x); rotR(h); }

else { insertT(h->r, x); rotL(h); }

}

public:

void insert(Item item)

{ insertT(head, item); }

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91794730
  • Price:- $90

Priced at Now at $90, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Explain data information and knowledge with examples make

Explain data, information, and knowledge with examples. Make sure to clearly identify the differences between the terms.

Suppose users share a 3 mbps link also suppose each user

Suppose users share a 3 Mbps link. Also suppose each user requires 150 kbps when transmitting, but each user transmits only 10 percent of the time. When circuit switching is used, how many users can be supported? For the ...

Roberto is the network administrator for an international

Roberto is the network administrator for an international law firm with offices and customers in North America, South America, Africa, and the Middle East. The lawyers frequently contact each other via e-mail, use the In ...

Suppose i am designing a personnel database for a

Suppose I am designing a personnel database for a university. The university has three types of personnel: students, staff, and faculty. Here are the characteristics of the three groups: -All three groups have a name and ...

Question suppose we have a message m 0101011010100001 to

Question : Suppose we have a message m = 0101011010100001 to be transmitted across a network and to protect it from errors, we use the CRC generator polynomial P(x) = x 7 +x 6 +x 2 +x. Answer the following: (a) What is t ...

Recall that the cpu execution time of a program is given by

Recall that the CPU execution time of a program is given by CPU time = IC times CPI times T. Suppose two different processors P 1 and P 2 execute the same number of instructions for a given benchmark. If P 1 is a 2 Ghz p ...

Sub classassume super class and methods defined in question

Sub Class Assume Super Class and methods defined in question VIII Assume a Sub class named RunSomeSuper Write the Begin method Construct an instance of SomeSuper with parms of your choosing Just the Begin method, not the ...

Question 1conduct research to determine three types of

Question: 1. Conduct research to determine three types of computer crime. Please provide a detailed description for all crimes, and share an example of where an organization was impacted by each of the types. 2. Elaborat ...

Birth weights of full-term babies in a certain area are

Birth weights of full-term babies in a certain area are normally distributed with mean 7.13 pounds and standard deviation 1.29 pounds. A newborn weighing 5.5 pounds or less is a low-weight baby. What is the probability t ...

What are the similarities and differences of hierachical

What are the similarities and differences of hierachical, Network, and Object Oriented Database Models.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As