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
data structures algorithms
Questions and Answers of
Data Structures Algorithms
Given a special list, whose node have extra pointer random which point to some other node in linked list. Create another list that is copy of the given list. Also, make sure that random pointer is
Reverse the infix expression. 5^E+D*) C^B+A ( Step 2. Make Every '(' as ')' and every ')' as '(' 5^E+D*(C^B+A) Step 3. Convert an expression to postfix form. Step 4. Reverse the expression.
In given K input streams of number in sorted order. You need to make a single output stream, which contains all the elements of the K streams in sorted order. The input streams support ReadNumber()
How will you sort 1 PB numbers? 1 PB = 1000 TB.
Any other improvement can be done on question 3 solution if the number of CPU cores is eight.Question 3In given K sorted Lists of fixed length M. Also, given a final output list of length M*K. Give
In given rotated-sorted list of N integers. (The array was sorted then it was rotated some arbitrary number of times.) If all the elements in the array were unique, find the index of some value.
Merge two sorted Lists into a single sorted list.Use merge method of Merge-Sort.
In given list of n elements, write an algorithm to find three elements in an array whose sum is a given value. Try to do this problem using a brute force approach. Then try to apply the sorting
True or falsea. 5n + 10 n2 = O(n2) b. n log n + 4 n = O(n) c. log(n2) + 4 log(log n) = O(logn) d. 12 n1/2 + 3 = O(n2) e. 3n + 11 n2 + n20 = O(2n)
What is the best-case runtime complexity of searching an Array?
What is the average-case runtime complexity of searching an Array?
Given array of positive numbers, you need to find the maximum sum under constraint that no two elements should be adjacent.
Let us suppose the interviewer ask you to give a best sorting algorithm. Some interviewee will directly jump to Quick-Sort O(nlogn). Oops, mistake! You need to ask many questions before beginning to
In given K sorted Lists of fixed length M. Also, given a final output list of length M*K. Give an efficient algorithm to merge all the arrays into the final list, without using any extra space. you
Given an array of English characters, sort the array in linear time.
Write a short Python function that takes a string s, representing a sentence, and returns a copy of the string with all punctuation removed. For example, if given the string "Let s try, Mike.", this
Write a short program that takes as input three integers, a, b, and c, from the console and determines if they can be used in a correct arithmetic formula (in the given order), like “a+b = c,”
Write a Python program that can take a positive integer greater than 2 as input and write out the number of times one must repeatedly divide this number by 2 before getting a value less than 2.
Write a Python program that can “make change.” Your program should take two numbers as input, one that is a monetary amount charged and the other that is a monetary amount given. It should then
Write a Python program that can simulate a simple calculator, using the console as the exclusive input and output device. That is, each input to the calculator, be it a number, like 12.34 or 1034, or
Write a Python program that simulates a handheld calculator. Your program should process input from the Python console representing buttons that are “pushed,” and then output the contents of the
A common punishment for school children is to write out a sentence multiple times. Write a Python stand-alone program that will write out the following sentence one hundred times: “I will never
The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided n, the number of people in the room, is more than 23. This property is
Write a Python program that inputs a list of words, separated by whitespace, and outputs how many times each word appears in the list. You need not worry about efficiency at this point, however, as
Give an example of a software application in which adaptability can mean the difference between a prolonged lifetime of sales and bankruptcy.
Write a Python class, Flower, that has three instance variables of type strint, and float, that respectively represent the name of the flower, its number of petals, and its price. Your class must
If the parameter to the make payment method of the CreditCard class were a negative number, that would have the effect of raising the balance on the account. Revise the implementation so that it
Suppose you are on the design team for a new e-book reader. What are the primary classes and methods that the Python software for your reader will need? You should include an inheritance diagram for
Write a Python class that extends the Progression class so that each value in the progression is the square root of the previous value. (Note that you can no longer represent each value with an
Write a Python program that inputs a polynomial in standard algebraic notation and outputs the first derivative of that polynomial.
Write a Python program that inputs a document and then outputs a barchart plot of the frequencies of each alphabet character that appears in that document.
Write a set of Python classes that can simulate an Internet application in which one party, Alice, is periodically creating a set of packets that she wants to send to Bob. An Internet process is
Write a Python program to simulate an ecosystem containing two types of creatures, bears and fish. The ecosystem consists of a river, which is modeled as a relatively large list. Each element of the
Write a simulator, as in the previous project, but add a Boolean gender field and a floating-point strength field to each animal, using an Animal class as a base class. If two animals of the same
Write a Python program that simulates a system that supports the functions of an e-book reader. You should include methods for users of your system to “buy” new books, view their list of
Develop an inheritance hierarchy based upon a Polygon class that has abstract methods area( ) and perimeter( ). Implement classes Triangle, Quadrilateral, Pentagon, Hexagon, and Octagon that extend
Perform an experimental analysis of the three algorithms prefix_average1, prefix_average2, and prefix_average3, from Section 3.3.3. Visualize their running times as a function of the input size with
Describe a recursive function for computing the nth Harmonic number, Hn = Σni=1 1/i.
Describe how the built-in sum function can be combined with Python’s comprehension syntax to compute the sum of all numbers in an n×n data set, represented as a list of lists.
The shuffle method, supported by the random module, takes a Python list and rearranges it so that every possible ordering is equally likely. Implement your own version of such a function. You may
Perform experiments to evaluate the efficiency of the remove method of Python’s list class, as we did for insert on page 205. Use known values so that all removals occur either at the beginning,
Suppose an initially empty queue Q has executed a total of 32 enqueue operations, 10 first operations, and 15 dequeue operations, 5 of which raised Empty errors that were caught and ignored. What is
What values are returned during the following sequence of deque ADT operations, on initially empty deque? add first(4), add last(8), add last(9), add first(5), back(), delete first( ), delete last(
Our implementation of shortest path lengths in Code Fragment 14.13 relies on use of “infinity” as a numeric value, to represent the distance bound for vertices that are not (yet) known to be
An old MST method, called Bar ˚uvka’s algorithm, works as follows on a graph G having n vertices and m edges with distinct weights:Let T be a subgraph of G initially containing just the vertices
Describe the meaning of the graphical conventions used in Figure 14.9 illustrating a DFS traversal. What do the line thicknesses signify? What do the arrows signify? How about dashed lines?
There are eight small islands in a lake, and the state wants to build seven bridges to connect them so that each island can be reached from any other one via one or more bridges. The cost of
Can edge list E be omitted from the adjacency list representation while still achieving the time bounds given in Table 14.3? Why or why not?
In order to verify that all of its nontree edges are back edges, redraw the graph from Figure 14.8b so that the DFS tree edges are drawn with solid lines and oriented downward, as in a standard
In the previous exercise, we assume that the underlying list is initially empty. Redo that exercise, this time preallocating an underlying list with length equal to the stack’s maximum capacity.
To implement the iter method of the PositionalList class, we relied on the convenience of Python’s generator syntax and the yield statement. Give an alternative implementation of iter by designing
Answer the following questions so as to justify Proposition 8.8.a. What is the minimum number of external nodes for a proper binary tree with height h? Justify your answer.b. What is the maximum
Modify our in-place quick-sort implementation of Code Fragment 12.6 to be a randomized version of the algorithm, as discussed in Section 12.3.1.
Draw an adjacency matrix representation of the undirected graph shown in Figure 14.1.
Draw an adjacency list representation of the undirected graph shown in Figure 14.1.
Repeat Exercise R-14.7 for the adjacency list representation, as described in the chapter.Exercise R-14.7Give pseudo-code for performing the operation insert edge(u,v,x) in O(1) time using the
Can edge list E be omitted from the adjacency matrix representation while still achieving the time bounds given in Table 14.1? Why or why not?
In some applications, such as in computer vision, an input set of two-dimensional points can be assumed to be given as pairs of integers, rather than arbitrary real numbers. Suppose, then, that you
Consider the substring pattern matching problem for a length-m pattern, P, and a length-n text, T, where one of the characters in P is a symbol, “?,” which is not in the alphabet for the text.
Describe how to compute shiftHash(h(X[i..i+m−1]), X, i) for the hash function, h(X[i..i + m − 1]) = X[i] + ··· + X[i + m − 1], where each character is viewed as an integer in the range [0, c
Show the existence of additive inverses in Zp, that is, prove that for each x ∈ Zp, there is a y ∈ Zp, such that x + y mod p = 0.
What is 960 mod 77?
Show that 5 is a multiplicative generator of the positive numbers in Z17.
Give a linear programming formulation to find the minimum spanning tree of a graph. Recall that a spanning tree T of a graph G is a connected acyclic subgraph of G that contains every vertex of G.
What is the dual of the following linear program? maximize: z = x1 + 2x2 subject to: xi + x2 < 5 6x1 – 3.x2 < 3 5x1 < 24 6x2 < 9 X1, x2 >0
Give a linear programming formulation for the all-pairs shortest-path problem.
Formulate the dual of the linear program for the maximum flow problem.
Give an objective function for the feasible region shown in Figure 26.9, such that there are an infinite number of optimal solutions, none of which have x = 0 or y = 0. What is the value of the
The maximum independent set (MIS) of a graph G = (V,E) is the largest set of vertices S ⊆ V such that for any two vertices u, v ∈ S, (u, v) ∈/ E; that is, no pair of vertices in S are
For each vertex, (3, 9) and (8, 6), of the feasible region shown in Figure 26.9, give an objective function that has that vertex as the optimal solution. Figure 26.9 y (3, 9) (0, 9) (8, 6) (8,
Prove that if there exists a point that is feasible in both a linear program and its dual, then that point is the optimal solution in both linear programs.
Give a set of linear programming constraints that result in the feasible region shown in Figure 26.9. Figure 26.9. y (3, 9) (0, 9) (8, 6) (8, 0) Figure 26.9: A feasible region.
Show that if we allow linear programs to have strict inequalities, then there exists a linear program which is neither infeasible nor unbounded, but nevertheless does not have an optimal solution
Suppose you are part of a trade expedition and there are 15 people in your party (including yourself). Your final destination lies across the desert, and so you must hire out camels to carry all of
If P is a linear program, let P∗ denote the dual of P, and let Pk∗ denote k application of the dual function. For example P2∗ = (P∗)∗ is the dual of the dual of P. Show that for any
Suppose there are four power plants, which use coal, nuclear, wind, and oil, and four cities, Flat Top Mountain, Zephyrville, Cherenkov, and Iridescent Islands. The power plants and cities are
Given a linear program in slack form such that the basic solution is feasible, give an algorithm to find a vertex of the feasible region by optimizing the slack form.
For each of the regions shown in Figure 26.8, give an LP for which that region is the feasible region, or explain why no such linear program exists. Figure 26.8 X2 X2 6. 6. 6. 4 2 2 4 (a) (b)
A small retail chain has three warehouses and four retail stores. Each warehouse stores a certain amount of goods, and each retail store has a demand for a certain amount of goods. In addition, for
When the simplex method was introduced, we assumed that the basic solution of the slack form was a feasible solution. Describe an algorithm that given an arbitrary slack form and a vertex on the
Solve the linear program of Exercise R-26.4, for α = 1, using the simplex method. Show the result of each pivot. Data FroExercise R-26.4,In the following linear program, the objective function
A perfect pizza maximizes how great it tastes and meets your recommended daily allowance (RDA) for the three macronutrients carbohydrates, fats, and protein. Suppose that your diet should consist of
Give a linear program in three variables for which the feasible region is a tetrahedron.
In the following linear program, the objective function has a parameter, α. What values of α result in a program with no unique solution? maximize: z = ax1 + x2 subject to: 3x1 + 5x2 < 77 7x1
A political candidate has hired you to advise them on how to best spend their advertising budget. The candidate wants a combination of print, radio, and television ads that maximize total impact,
Prove that the set of feasible solutions to a linear program with a nonempty feasible region is convex.
Suppose that instead of maximizing hits per minute, constraints, a web server company wants to minimize cost while maintaining a rack of standard and cuttingedge servers that can handle at least
Suppose that you are preparing for the upcoming Zombie Apocalypse. The Centers for Disease Control and Prevention recommend that any Zombie Apocalypse Survival Kit should contain at least the
Prove that if there exists more than one optimal solution to a linear program, then there must be infinitely many optimal solutions.
Prove that there exists a linear program in two variables with exactly one feasible solution.
Recall at the beginning of the chapter we gave a linear program to help a web server company decide what server models it should purchase. Suppose that the standard server model has been replaced by
What is the exact number of recursive calls made to compute the convolution of the vectors [6, 2, 3, 5, 2, 5, 8, 3, 2, 6] and [4, 2, 3, 2, 7, 3, 3, 9], using recursive definitions of the FFT and
In financial and scientific data analysis applications, such as in spotting trends in stocks, we are often interested in making sense of noisy or highly fluctuating data. One method to achieve this
Compute the product of the binary numbers (01101000)2 and (10001011)2 using the algorithm given in the book.
Compute the discrete Fourier transform of the vector [5, 4, 3, 2] using arithmetic modulo 17 = 24 + 1. Use the fact that 5 is a generator for the positive elements in Z17.
Consider a further generalization of the pattern matching problem from the previous exercise, where we allow the pattern, P, to contain instances of a special “wild card” or “don’t care”
Use the convolution theorem to compute the product of the polynomials p(x) = 3x2 + 4x + 2 and q(x)=2x3 + 3x2 + 5x + 3, using arithmetic in Z17. You may use the fact that 5 is a generator for the
Consider a generalization of the pattern matching problem from the previous exercise, where we allow the pattern P and text T to be strings defined over an arbitrary alphabet, Σ. Show that you can
Describe a method for computing the coefficients of the polynomial, P(x)=(x + 1)n, in O(n) time.
Use the FFT and inverse FFT to compute the convolution of a = [1, 2, 3, 4] and b = [4, 3, 2, 1], using arithmetic in Z17. Use the fact that 5 is a generator for the positive elements of Z17, and show
Showing 100 - 200
of 819
1
2
3
4
5
6
7
8
9