CSC 331 Review Game 1. Teams Katie, Mark, Alex Z, Dan B., Zane Dan C, Alex D, Dawn, Marshall, Zack Colby, Benjamin, Lisa, Riley, Andrew Catharine, Ryan,

Slides:



Advertisements
Similar presentations
Algorithms Analysis Lecture 6 Quicksort. Quick Sort Divide and Conquer.
Advertisements

CSE 3101: Introduction to the Design and Analysis of Algorithms
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
Introduction to Algorithms
Introduction to Algorithms Jiafen Liu Sept
Median Finding, Order Statistics & Quick Sort
Divide-and-Conquer The most-well known algorithm design strategy:
1 Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
CSC 331: Algorithm Analysis Divide-and-Conquer Algorithms.
Chapter 4: Divide and Conquer Master Theorem, Mergesort, Quicksort, Binary Search, Binary Trees The Design and Analysis of Algorithms.
COSC 3100 Transform and Conquer
Quicksort CS 3358 Data Structures. Sorting II/ Slide 2 Introduction Fastest known sorting algorithm in practice * Average case: O(N log N) * Worst case:
Analysis of Algorithms CS 477/677 Randomizing Quicksort Instructor: George Bebis (Appendix C.2, Appendix C.3) (Chapter 5, Chapter 7)
25 May Quick Sort (11.2) CSE 2011 Winter 2011.
Chapter 7: Sorting Algorithms
Lecture 7COMPSCI.220.FS.T Algorithm MergeSort John von Neumann ( 1945 ! ): a recursive divide- and-conquer approach Three basic steps: –If the.
Updated QuickSort Problem From a given set of n integers, find the missing integer from 0 to n using O(n) queries of type: “what is bit[j]
1 Sorting Problem: Given a sequence of elements, find a permutation such that the resulting sequence is sorted in some order. We have already seen: –Insertion.
Introduction to Algorithms Rabie A. Ramadan rabieramadan.org 4 Some of the sides are exported from different sources.
Quicksort Divide-and-Conquer. Quicksort Algorithm Given an array S of n elements (e.g., integers): If array only contains one element, return it. Else.
Fundamentals of Algorithms MCS - 2 Lecture # 16. Quick Sort.
CS 253: Algorithms Chapter 7 Mergesort Quicksort Credit: Dr. George Bebis.
1 SORTING Dan Barrish-Flood. 2 heapsort made file “3-Sorting-Intro-Heapsort.ppt”
Sorting Heapsort Quick review of basic sorting methods Lower bounds for comparison-based methods Non-comparison based sorting.
CSC 2300 Data Structures & Algorithms March 27, 2007 Chapter 7. Sorting.
More sorting algorithms: Heap sort & Radix sort. Heap Data Structure and Heap Sort (Chapter 7.6)
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
2 -1 Analysis of algorithms Best case: easiest Worst case Average case: hardest.
CPSC 411, Fall 2008: Set 2 1 CPSC 411 Design and Analysis of Algorithms Set 2: Sorting Lower Bound Prof. Jennifer Welch Fall 2008.
Analysis of Algorithms CS 477/677 Midterm Exam Review Instructor: George Bebis.
TTIT33 Algorithms and Optimization – Dalg Lecture 2 HT TTIT33 Algorithms and optimization Lecture 2 Algorithms Sorting [GT] 3.1.2, 11 [LD] ,
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Linear Time Selection These lecture slides are adapted from CLRS 10.3.
Sorting Lower Bound Andreas Klappenecker based on slides by Prof. Welch 1.
CSC 2300 Data Structures & Algorithms March 20, 2007 Chapter 7. Sorting.
Selection1. 2 The Selection Problem Given an integer k and n elements x 1, x 2, …, x n, taken from a total order, find the k-th smallest element in this.
Chapter 7 (Part 2) Sorting Algorithms Merge Sort.
Mergesort and Quicksort Chapter 8 Kruse and Ryba.
Sorting II/ Slide 1 Lecture 24 May 15, 2011 l merge-sorting l quick-sorting.
CSE 373 Data Structures Lecture 19
Sorting (Part II: Divide and Conquer) CSE 373 Data Structures Lecture 14.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 15.
Exam 2 Review. Teams Dan C, Z, Hugh, Zane, Alexis Mark, Jamie, Ryan, Alex H, Andrew Katie, Emily, Riley, Rohan, Alex D Dawn, Patrick, Jacapo, Catharine,
335 Review Game 1. Teams Zack, Jamie, Alex D, Marshall Colby, Riley, Alex Z, Fritz Lawrence, Paul, Gavan, Ben Catharine, Matt, Andrew, Alexis Spencer,
1 Time Analysis Analyzing an algorithm = estimating the resources it requires. Time How long will it take to execute? Impossible to find exact value Depends.
CSC 335 Review Game Exam 2. Teams Andrew, Marshall, Riley, Z Emily, Paul, Dawn, Lisa Gavan, Catharine, David, Alex D Michelle, Matt, Rohan, Jamie Ben,
CSC 213 Lecture 12: Quick Sort & Radix/Bucket Sort.
Order Statistics The ith order statistic in a set of n elements is the ith smallest element The minimum is thus the 1st order statistic The maximum is.
HKOI 2006 Intermediate Training Searching and Sorting 1/4/2006.
Merge Sort. What Is Sorting? To arrange a collection of items in some specified order. Numerical order Lexicographical order Input: sequence of numbers.
Quicksort, Mergesort, and Heapsort. Quicksort Fastest known sorting algorithm in practice  Caveats: not stable  Vulnerable to certain attacks Average.
Order Statistics. Order statistics Given an input of n values and an integer i, we wish to find the i’th largest value. There are i-1 elements smaller.
Sorting Fun1 Chapter 4: Sorting     29  9.
Sorting. Pseudocode of Insertion Sort Insertion Sort To sort array A[0..n-1], sort A[0..n-2] recursively and then insert A[n-1] in its proper place among.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 26 Sorting.
1 Sorting Algorithms Sections 7.1 to Comparison-Based Sorting Input – 2,3,1,15,11,23,1 Output – 1,1,2,3,11,15,23 Class ‘Animals’ – Sort Objects.
Sorting CSIT 402 Data Structures II. 2 Sorting (Ascending Order) Input ›an array A of data records ›a key value in each data record ›a comparison function.
Order Statistics(Selection Problem)
Quicksort CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
CSC 201 Analysis and Design of Algorithms Lecture 05: Analysis of time Complexity of Sorting Algorithms Dr.Surasak Mungsing
Lecture 6 Sorting II Divide-and-Conquer Algorithms.
CS6045: Advanced Algorithms Sorting Algorithms. Sorting So Far Insertion sort: –Easy to code –Fast on small inputs (less than ~50 elements) –Fast on nearly-sorted.
Randomized Quicksort (8.4.2/7.4.2) Randomized Quicksort –i = Random(p, r) –swap A[p]  A[i] –partition A(p, r) Average analysis = Expected runtime –solving.
Exam 2 Review. Teams David P, Sebastian, Nathan P, Harrison Scott, Josh, Patrick, Peter Michael, Alexia, Betsey, Keith Ty, Casey, Jesi, Lexa Maddie, Nathan.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 26 Sorting.
Chapter 7 Sorting Spring 14
Medians and Order Statistics
CSE 326: Data Structures Sorting
CS 583 Analysis of Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 26 Midterm 2 Review
Algorithms CSCI 235, Spring 2019 Lecture 17 Quick Sort II
Presentation transcript:

CSC 331 Review Game 1

Teams Katie, Mark, Alex Z, Dan B., Zane Dan C, Alex D, Dawn, Marshall, Zack Colby, Benjamin, Lisa, Riley, Andrew Catharine, Ryan, Jerry, Z, Lawrence Michelle, Jacapo, Rohan, Alexis, Jamie Patrick, Matt, Emily, Alex H, Hugh

Individual Round

1. Θ, Ω, or O? log 10 n 2 = ___(log 2 n)

2. Θ, Ω, or O? n! = ___(2 n )

3. Θ, Ω, or O? lgn = ___(√n)

4. What’s the best running time? Given an array of n sorted Strings, find the first String that would occur after the word “Happy”.

5. What’s the best running time? Given an array of n numbers that are NOT sorted and an integer k, find the kth smallest number in the array.

6. What is the running time? Alg first() is linear MYSTERY(A[1..n]) for i = 1 to n first(A[1..n])

7. What is the running time? Alg first() is linear MYSTERY(A[1..n]) for i = 1 to 10 first(A[1..n])

8. What is the running time? Alg first() is linear Alg second() is θ(nlgn) MYSTERY(A[1..n]) second(A[1..n]) for i = 1 to n for i = 1 to n/2 first(A[1..n])

9. What does the algorithm do? MYSTERY(A[left..right]) if (left=right) return 1; x = MYSTERY(A[left..right-1]) return x+1

10. What is the Recurrence Relation? MYSTERY(A[left..right]) if (left =right) return 1; x = MYSTERY(A[left..right-1]) return x+1

11. What does ENIGMA(8) print? ENIGMA(integer n): if n = 1 PRINT 1 else: ENIGMA(n/2) PRINT n

12. What is the recurrence relation? ENIGMA(integer n): if n = 1 PRINT 1 else: ENIGMA(n/2) PRINT n

13. What does the algorithm do? SECRET(A[1..n], k) if k = 1 return A[1] else return SECRET(A[2..n],k-1)

14. What is the recurrence relation? SECRET(A[1..n], k) if k = 1 return A[1] else return SECRET(A[2..n],k-1)

15. Solve using Master’s T(n)= 2T(n/2) + n

16. Solve using Master’s T(n)= 3T(n/2) + n 2

17. What does it mean to partition your data?

18. A sort whose main operation is finding whether or not 2 elements are, or = is called…

19. What does it mean for a sort to be stable?

20. What does it mean for a sort to be in-place?

21. What is the worst-case running time for Quicksort? When does it happen?

22. Give a time when you would prefer Insertion sort over Randomized Quicksort.

23. Which sort has its best case when it is in reverse order?

24. Quicksort’s recurrence relation is T(n) = 2T(n/2) + n Where did that last n come from?

25. What algorithm do I use? I want to find the median of a set of 100,000,000 numbers

26. What algorithm do I use? I’m trying to find the record for “John Doe” from a set of records sorted by name.

27. What algorithm do I use? I’m trying to quickly sort 2 million 10-digit numbers. I have plenty of space but want to save time.

28. What is a heap?

29. I have a heap with n nodes. What is its depth?

30. What is the running time for heapsort?

All-Play

What is the running time? InputTime 1,0002,000 2,0005,000 3,00010,000 4,00017,000

Alg A has running time of 2n+5. Alg B has a running time of n 2. For what values of n should you use Alg A and for what values should you use Alg B?

Solve: T(n) = 2T(n-2)+1

Write pseudocode for a divide-and-conquer algorithm for finding the number of negatives in an array.

Write an algorithm An array A[1..n] has a majority element if one element occurs in more than half of the entries. Design an O(nlgn) algorithm to decide if the array has a majority element and if so, what the element is. You cannot sort the array, or ask if A[i]>A[j], since comparisons are not supported on the array type. (For example, if the array were of GIF files.) You can, however, ask if A[i] = A[j].