Galaxy United, Inc.2012 Income StatementNet sales $614,100Less: Cost of goods sold 521,400Less: Depreciation 11,200Earnings before interest and taxes 81,500Less: Interest paid 10,100Taxable income...
Recent Questions
Fresh off the excitement of the 2012 London Olympic Games, youdecide that you want your firm to take advantage of the profits tobe made for the 2016 games in Rio de Jeneiro. To do so you plan toopen...
1. Let S be a sequence of n integers. Describe a method for printing out all the pairs of inversions in S in O(n+k) time, where k is the number of such inversions.2. Let S be a random permutation of...
1. Given a sequence S of n elements, on which a total order relation is defined, describe an efficient method for determining whether there are two equal elements in S. What is the running time of...
1. Given an array A of n integers in the range [0,n2 −1], describe a simple method for sorting A in O(n) time.2. Let S1,S2,…,Sk be k different sequences whose elements have integer keys in the...
1. Show that any comparison-based sorting algorithm can be made to be stable without affecting its asymptotic running time.2. Suppose we are given two sequences A and B of n elements, possibly...
Consider the voting problem from Exercise C-12.35, but now suppose the integers 1 to k are used to identify k Exercise C-12.35Suppose we are given an n-element sequence S such that each element in S...
Consider the voting problem from Exercise C-12.35, but now suppose that we know the number k Exercise C-12.35Suppose we are given an n-element sequence S such that each element in S represents a...
Suppose we are given an n-element sequence S such that each element in S represents a different vote for president, where each vote is given as an integer representing a particular candidate, yet...
Our high-level description of quick-sort describes partitioning the elements into three sets L, E, and G, having keys less than, equal to, or greater than the pivot, respectively. However, our...
1. Let A and B be two sequences of n integers each. Given an integer m, describe an O(nlogn)-time algorithm for determining if there is an integer a in A and an integer b in B such that m = a+b.2....
Another way to analyze randomized quick-sort is to use a recurrence equation. In this case, we let T(n) denote the expected running time of randomized quicksort, and we observe that, because of the...
1. Implement a bottom-up merge-sort for a collection of items by placing each item in its own queue, and then repeatedly merging pairs of queues until all items are sorted within a single queue.2....
Augment the PositionalList class (see Section 7.3) to support a method named merge with the following behavior. If A and B are PositionalList instances whose elements are sorted, the syntax...
Linda claims to have an algorithm that takes an input sequence S and produces an output sequence T that is a sorting of the n elements in S.a. Give an algorithm, isSorted, that tests in O(n) time if...
1. Describe and analyze an efficient method for removing all duplicates from a collection A of n elements.2. Augment the PositionalList class (see Section 7.3) to support a method named sort that...
1. What is the best algorithm for sorting each of the following: general comparable objects, long character strings, 32-bit integers, double-precision floating-point numbers, and bytes? Justify your...
1. Given a sequence S of n values, each equal to 0 or 1, describe an in-place method for sorting S.2. Give an example input that requires merge-sort and heap-sort to take O(nlogn) time to sort, but...
1. Suppose S is a sequence of n values, each equal to 0 or 1. How long will it take to sort S with the merge-sort algorithm? What about quick-sort?2. Suppose S is a sequence of n values, each equal...
Describe a radix-sort method for lexicographically sorting a sequence S of triplets (k,l,m), where k, l, and m are integers in the range [0,N − 1], for N ≥ 2. How could this scheme be extended to...
Consider a version of deterministic quick-sort where we pick as our pivot the median of the d last elements in the input sequence of n elements, for a fixed, constant odd number d ≥ 3. What is the...
1. Jonathan has a comparison-based sorting algorithm that sorts the first k elements of a sequence of size n in O(n)time. Give a big-Oh characterization of the biggest that k can be.2. Is the...
If the conditional at line 14 of our quickSortInPlace implementation of Code Fragment 12.6 were changed to use condition left
1. Show that the best-case running time of quick-sort on a sequence of size n with distinct elements is Ω(nlogn).2. If the outermost while loop of our implementation of quickSortInPlace (line 9 of...
Suppose the method quickSortInPlace is executed on a sequence with duplicate elements. Prove that the algorithm still correctly sorts the input sequence. What happens in the partition step when...
Consider a modification of the deterministic version of the quick-sort algorithm where we choose the element at index ⌊n/2⌋ as our pivot. Describe the kind of sequence that would cause this version...
1. Give pseudocode descriptions for the retainAll and removeAll methods of the set ADT, assuming we use sorted sequences to implement sets.2. Suppose we modify the deterministic version of the...
Suppose we are given two n-element sorted sequences A and B each with distinct elements, but potentially some elements that are in both sequences. Describe an O(n)-time method for computing a...
An algorithm that sorts key-value entries by key is said to be straggling if any time two entries ei and ej have equal keys, but ei appears before ej in the input, then the algorithm places ei after...
Is our linked-list-based implementation of merge-sort (Code Fragment 12.3) stable? Explain why or why not.Fragment 12.3
1. Following our analysis of randomized quick-sort in Section 12.2.1, show that the probability that a given input element x belongs to more than 2logn subproblems in size group i is at most 1/n2.2....
1. Show that the running time of the merge-sort algorithm on an n-element sequence is O(nlogn), even when n is not a power of 22. Is our array-based implementation of merge-sort given in Section...
Write a program that performs a simple n-body simulation, called “Jumping Leprechauns.” This simulation involves n leprechauns, numbered 1 to n. It maintains a gold value gi for each leprechaun i,...
The mergeable heap ADT is an extension of the priority queue ADT consisting of operations insert(k, v), min( ), removeMin( ), and merge(h), where the merge(h) operations performs a union of the...
Prepare an implementation of splay trees that uses top-down splaying as described in Exercise C-11.52. Perform extensive experimental studies to compare its performance to the standard bottom-up...
In describing multisets and multimaps in Section 10.5.3, we describe a general approach for adapting a traditional map by storing all duplicates within a secondary container as a value in the map....
1. Perform an experimental study to compare the speed of our AVL tree, splay tree, and red-black tree implementations for various sequences of operations.2. Implement the Sorted Map ADT using a...
1. Reimplement the TreeMap class using null references in place of explicit sentinels for the leaves of a tree.2. Modify the TreeMap implementation to support location-aware entries. Provide methods...
1. Consider a variation of splay trees, called half-splay trees, where splaying a node at depth d stops as soon as the node reaches depth ⌊d/2⌋. Perform an amortized analysis of half-splay trees.2....
The standard splaying step requires two passes, one downward pass to find the node x to splay, followed by an upward pass to splay the node x. Describe a method for splaying and searching for x in...
Recent Comments