Wait a second!
More handpicked essays just for you.
More handpicked essays just for you.
Data structure and algorithms flashcards
Don’t take our word for it - see why 10 million students trust us with their essay needs.
Recommended: Data structure and algorithms flashcards
Class Notes: Data Structures and Algorithms
Summer-C Semester 1999 - M WRF 2nd Period CSE/E119, Section 7344
Homework #1 -- Solutions (in blue type)
Note: There have been many questions about this homework assignment. Thus, clarifications are posted below in red type. When you answer these questions, bear in mind that each one only counts four points out of 1000 total points for the course. Thus, each one should have a concise answer. No need to write a dissertation.
* Question 1. Suppose you want to find the maximum of a sequence or vector a of n distinct integers. Write an algorithm to do this in O(n) time, for any sequence of n distinct integers.
max = very large negative number
input(a)
for i = 1 to n do
if a[i] > max
then max = a[i]
endfor
output(max)
* Question 2. You could assume that you know the maximum value of a before you search for it. That is, if a has values in the interval [0,101], then the maximum would be 101. The best case (least work) in the preceding algorithm would occur when the maximum of the n-element sequence is the first element of the sequence. Where is the maximum located for the (a) worst case, and (b) average case? Support each answer with a proof, not just an example.
Alternatively, you could assume that the maximum was not known beforehand, and a)-b), above might be easier...Either assumption is o.k.
o Case 1: Maximum unknown a priori -- You have to search through the entire array to find the maximum. Thus, there is no worst case or best case if you consider the work as comparisons (dominant cost) only.
o Case 2: Maximum known a priori -- This becomes a linear search problem (find the maximum).
As I read through this source, I did not find any information that would help me write my essay, however it was very interesting
* Question 2. Given the sequence S = {-9, 2, 4, 6, 30, -10, 1, 5, 8, 7},
* (less than 10 pages, less than 20 pages, or more than 20 pages). You may assume that the
Please type your answers to the following questions in a Word document and submit it here.
4. Choose the option that produces the most benefits for all those affected by the decision after calculating the difference between the good and bad effects.
* Question 1. Assume that an n-element array (vector) a contains distinct integers arranged in no particular order. Write an algorithm to find the value and location of (a) the mean of a and (b) the value v in a closest to the mean. Note: If v equals the mean, then v is the value closest to the mean.
* Question 1. Write pseudocode (not Java code) for Prim's algorithm that we discussed in class. Beside each step, write the number of external I/O, memory I/O, incrementation, comparison, and other types of operations employed.
Stephens, R., 2013. Essential Algorithms A practical approach to computer algorithms. 1st ed. Indiana: John Wiley & Sons, Inc.
Sorting algorithms are designed to be fast, and efficient. To be able to sort a list of data as quickly as possible, using as little memory as possible. To measure or classify an algorithm according to these two criteria, we measure the algorithm’s computational complexity. The computational complexity of a sorting algorithm is it’s worst, average and best behavior. Sorting algorithms are generally classified by their computational complexity of element comparisons, against the size of the list.
* Question 1. Write pseudocode and a diagram that shows how to implement the merge part of the merge-sort algorithm using two stacks (one for each subsequence), and be sure to use the correct ADT operations for stacks. Do not write Java code, or pseudocode for merge-sort.
Cutter, P. and Schultz, K. 2004. Assignments to Use Next Week: Tutorial Presentation. J. of Computing Sciences in Colleges 20(1), Oct. 2004, p. 114.
This is basically a problem where we can check an easy possible solution, but that does not mean that is the most optimal solution. In order to find the best solution to the problem all the possibilities have to be considered and calculated.
Sorting takes an important role within the computer applications. Efficient sorting is an very interesting problem in computer science. Nowadays, there are many sorting algorithms that are being employed in sensible life as well as in computation (Md. Khairullah 2013). Sorting problem has enticed a great deal of research, in view of efficient sorting is important to optimize the employment of different algorithms. Sorting algorithms are prevalent in introductory computer science class, wherever the abundance of algorithm for the matter provides a delicate introduction to a variety of core algorithm concep...
value or values providing the “best” output will be referred to as the optimal solution for
Linear programming is applied in various fields to improve the quality of decision making by providing optimal solution