1. Homepage
  2. Homework
  3. CS 430 – Fall 2022 Introduction to Algorithms - Sorting Algorithm
This question has been solved

CS 430 – Fall 2022 Introduction to Algorithms - Sorting Algorithm

Engage in a Conversation
CS 430Introduction to Algorithms美国AmericaSorting AlgorithmIllinois Institute of TechnologyIIT

CS 430 – Fall 2022 INTRODUCTION TO ALGORITHMS HOMEWORK #1
DUE SEP. 12 (Monday, the end of day)
CourseNana.COM

• Teamwork is NOT allowed.
• Submit the PDF version of the assignment to the Blackboard.
Late submissions will be accepted through Sep. 15 with a credit deduction. • All solutions should be explained.
CourseNana.COM


CourseNana.COM

1. (5 points)
1a) Use pseudocode to specify a brute-force algorithm that determines when given as input a sequence of
n positive integers whether there are two distinct terms of the sequence that have as sum a third term. The algorithm should loop through all triples of terms of the sequence, checking whether the sum of the first two terms equals the third. (2pts) CourseNana.COM

1b) Give a big-O estimate for the complexity of the brute-force algorithm from part (a). (1pt)
1c) Devise a more efficient algorithm for solving the problem that first sorts the input sequence and then checks
CourseNana.COM

for each pair of terms whether their sum is in the sequence.(1pt) CourseNana.COM

1d) Give a big-O estimate for the complexity of this algorithm. Is it more efficient than the brute-force algorithm? (1pt) CourseNana.COM

2. (2 points) Use the definition of big O to prove or disprove. 2a) Is 2^(n+1) O(2^n) (1pt) CourseNana.COM

2b) Is 2^(2n) O(2^n)(1pt) 3. (1point) CourseNana.COM


CourseNana.COM

4. (2points)
Some sorting algorithms are NOT stable (duplicate keys relative order is preserved after sorting). However if every key in A[i] is changed to A[i]*n + i - 1 (assume 1<=i<=n ) then all the new elements are distinct (and therefore stability is no longer a concern). After sorting,
what transformation will restore the keys back to their original values? What is the effect on the runtime of any of the sorting algorithms if you add this transformation before executing the sort and un-transformation after the sort? CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
CS 430代写,Introduction to Algorithms代写,美国代写,America代写,Sorting Algorithm代写,Illinois Institute of Technology代写,IIT代写,CS 430代编,Introduction to Algorithms代编,美国代编,America代编,Sorting Algorithm代编,Illinois Institute of Technology代编,IIT代编,CS 430代考,Introduction to Algorithms代考,美国代考,America代考,Sorting Algorithm代考,Illinois Institute of Technology代考,IIT代考,CS 430help,Introduction to Algorithmshelp,美国help,Americahelp,Sorting Algorithmhelp,Illinois Institute of Technologyhelp,IIThelp,CS 430作业代写,Introduction to Algorithms作业代写,美国作业代写,America作业代写,Sorting Algorithm作业代写,Illinois Institute of Technology作业代写,IIT作业代写,CS 430编程代写,Introduction to Algorithms编程代写,美国编程代写,America编程代写,Sorting Algorithm编程代写,Illinois Institute of Technology编程代写,IIT编程代写,CS 430programming help,Introduction to Algorithmsprogramming help,美国programming help,Americaprogramming help,Sorting Algorithmprogramming help,Illinois Institute of Technologyprogramming help,IITprogramming help,CS 430assignment help,Introduction to Algorithmsassignment help,美国assignment help,Americaassignment help,Sorting Algorithmassignment help,Illinois Institute of Technologyassignment help,IITassignment help,CS 430solution,Introduction to Algorithmssolution,美国solution,Americasolution,Sorting Algorithmsolution,Illinois Institute of Technologysolution,IITsolution,