1) d. because during the runtime of the program we are actually looking at what is that actual running time and the space required by the program.
2) c. because worst case is the input during which will take the most time average will talk about the average running time and best will tell the least running time.
3) d. log(n) will be slowest after which log(n)^2 and then n and then n^2
4) a.
b. O(n)
c.
d.
5) a. For i = n, j will run for n-1, i=n-1 j will run for n-2 and so on till 1. So the total number of iterations will be 1+2+3+4+...+n-1, which sum will be (n-1)*(n)/2 = .
b. Although i is going from 1 to n^2 but still only n iterations are working in i, n iterations for j and variable number of instruction ranging from 0 to n for k. So the total number of iterations will sum to .
What does a run-time analysis usually countS pts a. The number of arithmetic and other operations...
1) (10 pts) What are the worst case run times of each of the following operations? Make sure to list your answer in terms of the appropriate variables in the prompt. Note that on occasion, some of the run times won't be dependent on some of the variables listed in the prompt. (a) Inserting an item to the front of a linked list of n elements. (b) Sorting n integers using Quick Sort. (c) Merging a sorted list of a...
1) A Java program that implements an insertion sort algorithm. (InsertionSort.java): Must include the proper comments in the code. 2) A report in pdf. It contains: a) the pseudocode of the insertion sort algorithm and assertions between lines of the algorithm. b) As insertion sort has a nested-loop of two layers, you need to put one assertion in each loop. c) a proof of the partial correctness of the algorithm using mathematical induction c.1) prove the correctness of the two...
Refer to the following program sample to answer the parts (a-i) below. Keep in mind that low and high are both indices of array A. /1 Assume that A is a sorted array containing N integers // Assume that x is a variable of type int int low= 0; // Line 1 int high- N; // Line 2 while (low- high) I/ Line 3 m- (lowthigh)/2; // Line 4 (This is integer division) if (A [m]<) I/Line 5 then low-...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...
Chapter overview 1. Reasons for international trade Resources reasons Economic reasons Other reasons 2. Difference between international trade and domestic trade More complex context More difficult and risky Higher management skills required 3. Basic concept s relating to international trade Visible trade & invisible trade Favorable trade & unfavorable trade General trade system & special trade system Volume of international trade & quantum of international trade Commodity composition of international trade Geographical composition of international trade Degree / ratio of...