EECS 311: Chapter 6 Notes Chris Riesbeck EECS Northwestern.

Slides:



Advertisements
Similar presentations
EECS 311: Chapter 2 Notes Chris Riesbeck EECS Northwestern.
Advertisements

Chapter 9: Graphs Shortest Paths
The Efficiency of Algorithms Chapter 4 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
EECS 311: Chapter 8 Notes Chris Riesbeck EECS Northwestern.
EECS 311: Chapter 4 Notes Chris Riesbeck EECS Northwestern.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 6- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
© 2010 Pearson Education, Inc. All rights reserved.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object, Object- Relational, and XML: Concepts, Models, Languages,
Chapter 6: Priority Queues Priority Queues Binary Heaps Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 7: Sorting Algorithms Heap Sort Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 6: Priority Queues
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Part 1 Conditionals and Loops.
Chapter 9: Graphs Spanning Trees Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Chapter 1 Introduction. Copyright © 2003 by Pearson Education, Inc.1-2.
EECS 311: Chapter 9 Notes Chris Riesbeck EECS Northwestern.
CS 146: Data Structures and Algorithms June 23 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Binomial Queues Text Read Weiss, §6.8 Binomial Queue Definition of binomial queue Definition of binary addition Building a Binomial Queue Sequence of inserts.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 6-7 John D. Carpinelli.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 4 Applications of the Derivative.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Functions.
1 Copyright © 2015, 2011 Pearson Education, Inc. Chapter 5 Integration.
1 Copyright © 2015, 2011, 2007 Pearson Education, Inc. Chapter 9-1 Exponential and Logarithmic Functions Chapter 9.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 1-5 John D. Carpinelli.
Copyright © 2015, 2008, 2011 Pearson Education, Inc. Section 5.6, Slide 1 Chapter 5 Logarithmic Functions.
Copyright © 2012, 2009, 2005, 2002 Pearson Education, Inc. Chapter 3 Decimals.
Heap Sort Uses a heap, which is a tree-based data type Steps involved: Turn the array into a heap. Delete the root from the heap and insert into the array,
Chapter 2 Opener © 2014 Pearson Education, Inc.. Figure 2.1 © 2014 Pearson Education, Inc.
Chapter 7: Sorting Algorithms Insertion Sort Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan.
Data Structures & Algorithms Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison.
Copyright © 2010 Pearson Education, Inc. All rights reserved Sec
© 2015 Pearson Education, Inc.
© 2015 Pearson Education, Inc.
Chapter 4 Opener © 2014 Pearson Education, Inc..
Chapter 11 Opener © 2014 Pearson Education, Inc..
Chapter 14 Graphs and Paths.
Lial/Hungerford/Holcomb: Mathematics with Applications 10e
Section 2.5 Graphing Techniques; Transformations
Copyright © 2008 Pearson Prentice Hall Inc.
Copyright © 2008 Pearson Prentice Hall Inc.
Copyright © 2013 Pearson Education, Inc. All rights reserved
Priority Queues (Chapter 6.6):
Copyright © 2008 Pearson Prentice Hall Inc.
Section 2.5 Graphing Techniques; Transformations
Section 1.5 Circles Copyright © 2013 Pearson Education, Inc. All rights reserved.
Copyright © 2008 Pearson Prentice Hall Inc.
Chapter 3 MATH 1325 Business Calculus Ch.3 Copyright © 2005 Pearson Education, Inc.
Chapter 2: Getting Started
Nonlinear Functions, Conic Sections, and Nonlinear Systems
Chapter 5 MATH 1325 Business Calculus Ch.5 Copyright © 2005 Pearson Education, Inc.
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Priority Queues (Chapter 6):
Section 10.5 The Dot Product
Priority Queues Binary Heaps
Copyright © 2008 Pearson Prentice Hall Inc.
Copyright © 2008 Pearson Prentice Hall Inc.
Chapter 9: Graphs Shortest Paths
Chapter 2 Part 1 Data and Expressions.
Chapter 9: Graphs Spanning Trees
Presentation transcript:

EECS 311: Chapter 6 Notes Chris Riesbeck EECS Northwestern

 Unless otherwise noted, all tables, graphs and code from Mark Allen Weiss' Data Structures and Algorithm Analysis in C++, 3 rd ed, copyright © 2006 by Pearson Education, Inc.

Building the Initial Heap  Given a set of numbers  You could insert one by one  Complexity: O(n log n)  There's a better way…  Throw all numbers into the array  Fix from the bottom up (2 nd to last row)

Building a Heap Initial setProcess node 7

Building a Heap 2 Process node 5Process node 6

Building a Heap 3 Process node 3Process node 4

Building a Heap 4 Process node 1Process node 2

Building a Heap Complexity  The worst case this way is the sum of the heights of the nodes.  That sum = 2 h+1 – h  2 h+1 is the number of nodes N  Ergo, this algorithm is O(N) to build a heap