1 Ordenando. 2 Sorting Input Una secuencia de numeros a 1, a 2, a 3, …, a n Output Una permutación (reorden) a’ 1, a’ 2, a’ 3, …, a’ n de la input, tal.

Slides:



Advertisements
Presentaciones similares
Los verbos estar y ser “to be”
Advertisements

EN TI MI QUERIDA PAGINA WEB PUEDO EXPRESAR MIS SENTIMIENTOS Y ACCIONES Y LA CREATIVIDAD TU LA PONES CON CADA UNA DE TUS PARTES.
Algoritmos de ordenación
I am writing is….. Other things we wrote down….. ObjectiveBell work Students will be able to apply their knowledge of the present progressive to the imperfect.
HS/HL Removal1 FUNDAMENTOS DE ELIMINACIÓN DE SUPERFICIES OCULTAS Graficación FCC.
Ordenamiento, Heapsort y Colas de prioridad
M.C. Yalu Galicia Hdez. (FCC/BUAP)
Complejidad Programación II de febrero de 2009.
Análisis de Algoritmos
Algoritmos de búsqueda
Divide y vencerás 1. Método general.
Figure: Algoritmos Conceptos básicos. Programación: 1.Establecer una secuencia de acciones que: puedan ser ejecutadas por el procesador realicen una.
Siéntate con un compañero nuevo. Circle paper This is Spanish practice at home. When you can do a circle, have a parent/guardian sign it off. We have done.
Time Expression with Hacer Grammar Essential #106.
Hoy es martes. La fecha es el 11 de febrero LA PREGUNTA: Escribe una lista de 5 cosas que ves un nuestra sala de clases. LA TAREA y OTROS ANUNCIOS:  Libro.
Bienvenidos Objetivos Agenda 1.Actividad Inicial: 10 min 2.Pre-Assessment: 20 min 3.Actividad Individual: 10 min 4.Group-Formation: 10 min 5.KWL-La ciudad:
1 Quicksort Agustín J. González ELO320: Estructura de Datos y Algoritmos 1er. Sem
Superlatives. To talk about something or someone having “the most” or “the least” characteristic or quality, use the following formulas: El La Los Las.
LOS PAISES HISPANOS Y SUS CAPITALES.
1 Ordenamiento y estadísticas de orden Agustín J. González ELO 320: Estructura de Datos y Algoritmos.
7.  El TDA Diccionario.
Analysis of Algorithms
SABES QUE – LUNES EL 13 DE OCTUBRE 2014 Escribe una pregunta (the question) y una respuesta (the answer). You will ask & answer these questions with a.
1 Ordenamiento en tiempo lineal y Estadísticas de orden Agustín J. González ELO320: Estructura de Datos y Algoritmos 1er. Sem 2002.
Algoritmos de Ordenamiento y Complejidad
HAZLO AHORA DAY # 43 Pick up handout Please have your homework out- I am going to come around and collect it Copy, Translate in english and then answer.
1 Quicksort Agustín J. González ELO320: Estructura de Datos y Algoritmos 1er. Sem
Repaso: el futuro, el futuro perfecto, el condicional, el imperfecto subjuntivo…
Arboles B (búsqueda externa)
1 B-Trees y AVL Trees. 2 AVL Trees: Topicos Balance en los Trees Chequear el Balance Insertar Single y Doble Rotaciones.
Español 1 Hoy es lunes el 10 de marzo de La Campana Escribe dónde, a tu familía, le gusta ir en español. Ejemplo: A mi primo le gusta ir a la biblioteca.
Calentamiento Write the answers to each question.
Ejemplos del Diseño de Algoritmos Paralelos (Transparencias de McGraw-Hill Modificadas)
Oscar F. Bedoya L. Fundamentos de análisis y diseño de algoritmos.
¿Qué haces en la escuela? Question words, objects, yo-go’s.
Calentamiento Turn the homework into the teal basket Write the verb from our list that corresponds with the pictures below.
Las Preguntas (the questions) Tengo una pregunta… Sí, Juan habla mucho con el profesor en clase. No, Juan no habla mucho en clase. s vo s vo Forming.
La pregunta: Marquen los países con una flecha Saquen el paquete de los mapas.
Running dictation You will work in teams
Lunes 15 de septiembre Máx. : 23° Mín. : 19° Hazlo ahora 3 min.
Calentamientos (escriban en jueves) Pasar papeles y discutir trabajos que faltan Practicar para la prueba de mañana.
Vámonos Escribe la fecha y el objetivo Hoy es 15 de septiembre del 2014 I can describe myself and others using adjectives. WARM UP: Describe la escena.
Principio aditivo o de adición o regla de suma
Lunes el 21 de marzo. Bienvenida  Repasar expectaciones.  Introducir preguntas nuevas.
ALC 49 Responde a las preguntas Hoy es lunes el 30 de enero ¿Cómo estás? 2.¿Dónde estás? 3.¿Qué estás haciendo? 4.¿De dónde eres? 5.¿Cómo eres?
Overclipping It’s very important as a trader that you understand your clip size and what positions this allows you to have. In addition it will help you.
Science Fair 2015 Feria de la Ciencia. Monday, April 20 th Night showing: 5- 7pm.
SPANISH I DAY 19. HAGA AHORA HAGA AHORA el 3 de octubre Write the following sentences then make the corrections: Yo tienes una apartamento en los suburbos.
La pregunta: ¿Cómo se dice… It’s noon It’s midnight. en Español? Hoy es viernes, es el once de octubre. La tarea: Examencito: los números y la hora miércoles,
Subjunctivo – Cláusulas Adverbiales Para la lección de hoy, necesitamos repasar cómo formar el imperfecto del subjuntivo (los ra-ras) Hablar  tú ______.
Vámonos Pick up a new passport. Then, translate this short passage into English: Un hombre viajó a Nicaragua para visitar a sus primos. Él fue por avión.
Español 1 Ms. Lewis Explorar 0 ¿Cómo se llaman las personas en tu grupo? 0 Escribe los nombres. 0 ¿Cosas buenas? 0 ¿Quién conoce a todas las personas.
Para Empezar 25 de enero Write two sentences in the past tense describing where Drake was and what he did yesterday based on the photos.
¡Bienvenidos a clase! viernes, el 30 de octubre.
Conteo de puntos de la muestra Ing. Raúl Alvarez Guale.
Time Expressions with Hacer
Campanada guidelines in your composition notebook ¿Cómo es tu familia? (10 points) Ex. Hoy es Miercoles el 27 de enero First line will start with the date.
The present progressive 1. Meaning -what you (or he, or we, or they) are doing RIGHT THIS SECOND.
1 Ordenación, Clasificación Introducción Algoritmos Complejidad.
Ingeniería en Sistemas
8.  Ordenamiento.
Complejidad Programación II de febrero de 2009.
Irregular Preterite Verbs: Ir, Ser
Heapsort Idea: dos fases: 1. Construccion del heap 2. Output del heap
Curso de Programación Estructurada
Irregular Preterite Verbs: Ir, Ser
Nelson Baloian, José A. Pino
Análisis combinatorio
Using Adjectives as Nouns
Las Preguntas (the questions) Tengo una pregunta… Sí, Juan habla mucho con el profesor en clase. No, Juan no habla mucho en clase. s vo s vo Forming.
Transcripción de la presentación:

1 Ordenando

2 Sorting Input Una secuencia de numeros a 1, a 2, a 3, …, a n Output Una permutación (reorden) a’ 1, a’ 2, a’ 3, …, a’ n de la input, tal que a’ 1 < a’ 2 < a’ 3 < …< a’ n Ejemplo Input: Output:

3 Selection Sort n-1 fases, desde 1 hasta n-1 En la fase p, hallamos el p’esimo, nº más pequeño y lo ponemos en la posición p. O(n 2 ), considerando, O(n) fases, y donde cada fase necesita O(n) para hallar el p’esimo nº más pequeño Fase Fase Fase Fase Fase 5

4 Bubble Sort n-1 fases, de 1 hasta n-1 En la fase p, escanea la lista de izq. a der. Si el nº de la posición actual es más grande que la siguiente los intercambia posicion posicion posicion posicion posicion 5

5 fase fase fase fase 5 En la fase p, el p’ésimo elemento más grande deberá estar en la posición correcta. O(n 2 )

6 Insertion sort n-1 fases, de 2 hasta n antes fase Despues fase 4

fase Despues fase 6 fase 3 fase 4 fase 5 fase Después de fase p, elementos en posiciones 1 hasta la p-1 están ordenados. O(n 2 )

8 Inversion Bubble Sort, Insertion Sort, y Selection sort usan Inversiones, es decir, en una secuencia a(1), a(2), …, a(n) con algun orden (i,j) tal que i a(j) Ejemplo: 24, 35, 12, 30 (1,3), (2,3), (2,4) Cuál es el nº de inversiones en promedio?

9 Inversion Ejemplo

10 Heapsort Algoritmos involucrados Buildheap: O(n) n -DeleteMins: n -O(log n) O(n log n) worst-case running time

Para ordenar en orden creciente?

13 Mergesort Mergesort(A:array de integers) { msort(A,0,length[A]-1); } msort(A,p,r) { If (p == r) return; q = floor((p+r)/2); msort(A,p,q); msort(A,q+1,r); merge(A,p,q,r); }

Mergesort T(1) = O(1) T(n) = O(1)+2T(n/2)+O(n) T(n) = O(n log n) T(n/2)O(1) O(n) T(n/2)

15 Analisis de Mergesort

16 Mergesort O(n log n) worst-case running time Divide-and-conquer requiere memoria adicional

17 Quicksort Divide-and-conquer O(n log n) average running time O(n 2 ) worst-case running time Es el más rápido en la practica.

T(i)O(n) O(1) T(n-i)

19 Quicksort Algorithm Suponga una entrada de elementos en una lista S. Si el # de elementos en S es 0 o 1, return S. Pincha un elemento p (el pivote) en S. Particion S-{p} en S1 = {x  S | x  p } y S2 = {x  S | x  p } Ordena S1 y S2 recursivamente Return ( S1, p, S2 )

20 Escoger Pivote El primer elemento Mala opción Un elemento al azar Median Median de la izq., der y elementos del centro.

21 Particion

22 Mejor caso- Best Case

23 Peor caso- Worst Case

24 Analisis del Worst-Case

25 Aplicacion de Quicksort: Selecting k-th smallest element quickselect: 1.If |S|=1 then k=1 and return the element in S as the answer. 2.Pick a pivot element,v  S. 3.Partition S-{v} into S 1 and S 2, as was done with quicksort 4.If k |S 1 | the kth smallest element must be in S 1. In this case return quickselect(S 1,k). If k=1+|S 1 |, then the pivot is the kth smallest element and we can return it as the answer. Otherwise, the kth smallest element is in S 2, and it is the (k-|S 1 |-1)st smallest in S 2. We make a recursive call and return quickselect(S 2, k-|S 1 |-1). Complexity: O(n) in average Application: Finding Median

26 adivinando Player 1: Pincha un nº x entre 1 y 10. Player 2: Trata de determinar x haciendo la pregunta: Es x  y ? 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5 55 6,7,8,9,10 55 8 77 6,7,8 88 5 44 1,2,3 41, ,7 76 9, 66 66 77 99 99 88 11 11 22 22 44 33 4,5 33

27 1,2,3,4,5,6 1,2,3 1,23 21 11 11 22 22 33 33 4,5,6 4,56 54 44 44 55 55 1,2,3,4,5,6 1,2,3,4 1,26 21 11 11 22 55 44 44 5,6 3,45 43 33 33 55 22 1,2,3,4,5,6 3,4,5,62 1 22 11 11 2,3,4,5,6 4 3 33 33 22 4,5,6 6 55 5,6 5 55 44 44

28 a<b<c a<c<b b<a<c b<c<a c<a<b c<b<a b<a a<b a<b<c a<c<b b<a<c b<c<a c<a<bc<b<a c<aa<c a<b<c a<c<b c<a<b a<b<ca<c<b c<bb<c b<a<c b<c<a c<b<a c<b b<c c<aa<c b<a<cb<c<a Decision Trees

29 Un árbol binario de profundidad d posee a lo más 2 d hojas. Un árbol binario con L hojas tiene profundidad a lo menos  log L 

30 Bucket Sort n=5 O(n+b) b= , 3, 3, 6, 8, 12

31 Radix Sort n =9 b =10 p =3 O(p(n+b))