Compare the running times of algorithms

Assignment Help Data Structure & Algorithms
Reference no: EM131662301

Question: Repeat Exercise for four numbers. Try to design an O(N2 log N) algorithm.

Exercise: An array contains N numbers, and you want to determine whether two of the numbers sum to a given number K. For instance, if the input is 8, 4, 1, 6 and K is 10, the answer is yes (4 and 6). A number may be used twice. Do the following.

a. Give an O(N 2) algorithm to solve this problem.

b. Give an O(N log N) algorithm to solve this problem. (Hint: Sort the items first. After doing so, you can solve the problem in linear time.)

c. Code both solutions and compare the running times of your algorithms.

Reference no: EM131662301

Questions Cloud

Describe the sample demographics data collection process : Describe the sample, demographics, data collection process, setting, and the instrument, tool, or survey used in the articles
Find the two numbers : The sum of two numbers is 111. If three times the smaller number is subtracted from the larger? number, the result is 7. Find the two numbers.
Demonstrate your understanding about human rights : demonstrate your understanding, integration and synthesis of the following nine (9) terms: Human Rights; Social Protection; Risk;
Who is responsible for data governance : Who is responsible for data governance? Explain.
Compare the running times of algorithms : An array contains N numbers, and you want to determine whether two of the numbers sum to a given number K. For instance, if the input is 8, 4, 1, 6 and K is 10.
Find a model that expresses the revenue r as a function of x : The price p? (in dollars) and the quantity x sold of a certain product obey the demand equation p=-1/6x+100. Answer parts ?(a) through ?(e).
Analyze the effectiveness and efficiency of current order : Analyze the effectiveness and efficiency of current order processing system and recommend improvement by applying logistical theories and concepts.
Define clinical practice and unsatisfactory patient outcomes : The practice issue is clinical practice and unsatisfactory patient outcomes
Graph f and g on the same cartesian plane : ?(a) Graph f and g on the same Cartesian plane. Choose the correct graph below.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Draw a red-black tree

Draw a red-black tree for the following values inserted in this order. Illustrate each operation that occurs: w k o s y t p r

  Give and compare the heights of the two trees

- First insert them sequentially into a binary search tree. - Next reinsert them into an empty AVL tree, restoring the AVL property after each insertion. Show the AVL tree which results after each insertion.

  Draw three spanning trees that can be found in the graph

Draw three spanning trees that can be found in the graph in Figure. Give the breadth-first traversal of the graph in Figure, starting from vertex A.

  Calculating an arithmetic mean, median and mode

Calculate an arithmetic mean, median, and mode for up to fifty test scores. The information are contained in a text file. To determine the median, first sort the array.

  Using command line options in bash shell script

Design a script that will permit the user to enter one of several choices from the command line. The specific requirements are as follows:

  Using big-o notation state the runtime for this algorithm

1 consider searching algorithms on the following array of datanbsp22 21 9 4 16 2 10 14 20 31 26 19 17 28 8

  Relationship between security mechanisms and attacks

Draw a matrix similar that shows the relationship between security mechanisms and attacks - Show the calculations for corresponding decryption of the ciphertext to recover the original plaintext.

  Write program that implement a binary search of sorted array

Write and test a program that instantiates a function template that returns the minimum of two values. Write and test a program that instantiates a function template that implements a binary search of a sorted array of objects.

  What are the equivalence classes of this relation

Show that the reachability matrix R for an undirected graph with n vertices can be constructed in 0 ( n 2 )time.

  How do i created the pseudocode

Using the UML diagram and variable list , create Pseudocode for the program.

  Hardware platform of the target embedded systems

An embedded system is a computer system performing dedicated functions within a larger mechanical or electrical system. Embedded systems range from portable devices such as Google Glasses, to large stationary installations like traffic lights, fa..

  Benefits of dynamic over static arrays

Discuss the benefits of dynamic over-static arrays. Under what conditions will you choose dynamic arrays?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd