Computers and Technology
Computers and Technology, 08.12.2020 05:10, shimohsen

Let us consider an array a[1...n] with integer values (both positive and negative). Choose three different sorting methods to sort increasingly the array. Which sorting method is the fastest (from the three chosen methods)? Analyze the complexity (problem size, dominant operation and complexity) of the three algorithms in order to prove your answer. (1p) Now that your array a[1...n] is sorted increasingly, consider a value v and using an algorithm with complexity 0(lgn), determine the position where this value can be inserted such that the array remains increasingly sorted. Prove the total correctness of your algorithm (use an invariant). (1p)

Consider another increasingly sorted array b[1...m]. So now you have a[1...n] and b[1...m] with elements not necessarily distinct.

a. Construct a strictly increasingly sorted array with the distinct elements from a and b. Analyze the complexity (problem size, dominant operation and complexity) of your algorithm. (0.5p)

b. Propose an algorithm with linear complexity to determine the set with common elements of the two arrays a and b. Analyze the complexity (problem size, dominant operation and complexity) of your algorithm. (0.5p)

Indications:

All the algorithms will be written in pseudocode.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:50, shadow29916
What is a rush associated with alcohol?
Answers: 1
image
Computers and Technology, 22.06.2019 21:30, aesthetickait
How do you take a green screen out of the video while editing?
Answers: 2
image
Computers and Technology, 23.06.2019 19:00, amayax77
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
image
Computers and Technology, 23.06.2019 19:40, Latoyajenjins1789
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system. currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system. currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system. currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
Do you know the correct answer?
Let us consider an array a[1...n] with integer values (both positive and negative). Choose three dif...

Questions in other subjects:

Konu
Mathematics, 23.10.2021 04:50