SlideServe
Menu
Préférences
© SlideServe · v2026

CSCE 310: Data Structures Algorithms

thu avatar
6 diapositives · 361 Views · Feb 26, 2012

Design and Analysis of Algorithms

CSCE 310: Data Structures Algorithms - slide 1
01 / 6CSCE 310: Data Structures Algorithms
1 / 17

Télécharger la présentation

CSCE 310: Data Structures Algorithms
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation

    1. Design and Analysis of Algorithms – Chapter 4 1 CSCE 310: Data Structures & Algorithms

    2. Design and Analysis of Algorithms – Chapter 4 2 Divide and conquer examples Closest-pair problem Presentation Slides by Tsvika Klein Convex-hull problem Presentation slides by João Comba

    3. Design and Analysis of Algorithms – Chapter 4 3 QuickHull Algorithm Inspired by Quicksort, it compute Convex Hull: Assume points are sorted by x-coordinate values Identify extreme points P1 and P2 (part of hull) Compute upper hull (Lower hull computation is similar): find point Pmax that is farthest away from line P1P2 compute the hull of the points to the left of line P1Pmax compute the hull of the points to the left of line PmaxP2

    4. Design and Analysis of Algorithms – Chapter 4 4 Efficiency of QuickHull algorithm Finding point farthest away from line P1P2 can be done in linear time This gives same efficiency as quicksort: Worst case: T( n2) Average case: T( n log n) If points are not initially sorted by x-coordinate value, this can be accomplished in T( n log n) — no increase in asymptotic efficiency class Other algorithms for convex hull: Graham’s scan DCHull also in T( n log n)

    5. In-Class Exercise 1 A k-way merge operation. Suppose you have k sorted arrays, each with n elements, and you want to combine them into a single sorted array of kn elements. A) Here’s one strategy: Using the merge procedure from Section 4.1, merge the first two arrays, then merge in the third, then merge in the fourth, and so on. What is the time complexity of this algorithm, in terms of k and n? B) Give a more efficient solution to this problem, using divide-and-conquer. Design and Analysis of Algorithms – Chapter 4 5

    6. In-Class Exercise 2 An array A[1 … n] is said to have a majority element if more than half of its entries are the same. Given an array, the task is to design an efficient algorithm to tell whether the array has a majority element, and, if so, to find that element. The elements of the array are not necessarily from some ordered domain like the integers, and so there can be no comparisons of the form “is A[i] > A[j]?”. (Think of the array elements as GIF files, say.) However you can answer questions of the form: “is A[i] = A[j]?” in constant time. Design and Analysis of Algorithms – Chapter 4 6

    7. Reading List Chapter 5.1 5.2, 5.3 & 5.4 Design and Analysis of Algorithms – Chapter 4 7