Agenda  See schedule  HW5 (mini-programming project) due Next Wed. 16th  Quiz 6 (double quiz- 50 minutes) will be Next Mon. 14th.

Slides:



Advertisements
Similar presentations
Stacks and Queues. Not really data structures – More of an enforcement of policy – Can be implemented using an array or linked list – Can store just about.
Advertisements

Computer Science 112 Fundamentals of Programming II Overview of Collections.
COL 106 Shweta Agrawal and Amit Kumar
ADVANCED DATA STRUCTURES AND ALGORITHM ANALYSIS Chapter 3 Lists, Stacks, and Queues.
Introduction to C Programming CE Lecture 12 Circular Queue and Priority Queue Data Structures.
Today’s Agenda  Stacks  Queues  Priority Queues CS2336: Computer Science II.
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 4.
Data Structures, Search and Sort Algorithms Kar-Hai Chu
The Heap ADT In this section of notes you will learn about a new abstract data type, the heap, as well how heaps can be used.
Binary Heap viewed as an array viewed as a binary tree Left(i) = 2*i Right(i) = 2*i + 1 Parent(i) = i.
Binary Heaps CSE 373 Data Structures Lecture 11. 2/5/03Binary Heaps - Lecture 112 Readings Reading ›Sections
CS102 – Data Structures Lists, Stacks, Queues, Trees, Hash Collections Framework David Davenport Spring 2002.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Midterm Exam Two Tuesday, November 25 st In class cumulative.
Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
Dr. Andrew Wallace PhD BEng(hons) EurIng
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
Data Structures - Queues
Foundation of Computing Systems Lecture 6 Trees: Part III.
Compiled by: Dr. Mohammad Alhawarat BST, Priority Queue, Heaps - Heapsort CHAPTER 07.
PRIORITY QUEUES (HEAPS). Queues are a standard mechanism for ordering tasks on a first-come, first-served basis However, some tasks may be more important.
Introduction to Data Structures Fall 2008 Dr. David A. Gaitros
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
ECE 103 Engineering Programming Chapter 61 Abstract Data Types Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
data ordered along paths from root to leaf
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Review for Final Exam – cs411/511 Definitions (5 questions, 2 points each) Algorithm Analysis (3 questions, 3 points each) General Questions (3 questions,
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
CSE205 Review Session SAMUEL & JESSA. Recursion WHAT IS RECURSION?  Recursion is a tool a programmer can use to invoke a function call on itself. 
Queues, Stacks and Heaps. Queue List structure using the FIFO process Nodes are removed form the front and added to the back ABDC FrontBack.
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Kevin Quinn Fall 2015.
8 January Heap Sort CSE 2011 Winter Heap Sort Consider a priority queue with n items implemented by means of a heap  the space used is.
Heaps and basic data structures David Kauchak cs161 Summer 2009.
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: Tel 3049.
Lecture 2 Basic Data Structures and Recursion Review.
Stack and Queues Part 2. Priority Queues Priority Queues (cont’) A priority queue is a more specialized data structure than a stack or a queue. However,
Data-structure-palooza Checkout DataStructures from SVN.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
1 The Standard Template Library The STL is a collection of Container classes These are class templates for containers. A container is an object that stores.
Introduction to Data Structure and Algorithms
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
CSE373: Data Structures & Algorithms Priority Queues
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Fundamentals of Programming II Overview of Collections
Heaps (8.3) CSE 2011 Winter May 2018.
Chapter 15 Lists Objectives
Programming Abstractions
Source: Muangsin / Weiss
Stacks Linked Lists Queues Heaps Hashes
structures and their relationships." - Linus Torvalds
Fundamentals of Python: From First Programs Through Data Structures
Priority Queues.
Priority Queues.
ITEC 2620M Introduction to Data Structures
Priority Queues (Chapter 6.6):
Dynamic Sets (III, Introduction)
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Fundamentals of Python: From First Programs Through Data Structures
Priority Queues (Chapter 6):
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

Agenda  See schedule  HW5 (mini-programming project) due Next Wed. 16th  Quiz 6 (double quiz- 50 minutes) will be Next Mon. 14th

Chapter 3  Data Structures –Stacks & Queues –Array vs. Linked Lists –Resizable arrays –Binary Search leads to Binary Trees –Priority Queues lead to Binary Heaps

Stacks & Queues  Stacks –FILO (First In – Last Out) –O(1) push –O(1) pop –Ensuring efficient push and pop means that iteration may not be possible.

Stacks & Queues  Queues –FIFO (First In – First Out) –O(1) push or enqueue –O(1) pop or dequeue –Ensuring efficient push and pop means that iteration may not be possible.

Stacks & Queues  Queue q;  Stack s1, s2;  q.push(1)  s1.push(2)  s2.push(3)  q.push(s2.pop())  q.push(4)  s2.push(5)  s1.push(6)  s2.push(q.pop());  s1.push(s2.pop());  s2.pop()  s1.push(s2.pop());

Arrays vs. Linked Lists Arrays  Constant-time access of k th item  Binary search can be implemented on sorted arrays  O(n) insertion  O(n) deletion  O(n) merging and resizing Linked List  O(n)-time to access k th item on average  Binary search can NOT be implemented on sorted linked lists  O(1) insertion  O(1) deletion  O(1) merging

Resizable Arrays  Given an array with a capacity of M  Insert N 1 items  What if N 1 > M?  Resize array to N 1 (stupid)  Resize array to 2*N 1 (smart)  Why?

Resizable Arrays i InsertionsCopies 10 m 11 i Total 1 2 m 12 m 3 i m 13 m 4 mi mmmm mmmm i mi Sum

Resizable Arrays i InsCopies 1 m 11 i Total i m 13 m 4 mi i i Sum

Binary Trees  Tries to combine binary search with the advantages of linked lists. ArrayLinked ListBinary Tree Raw InsertO(n)O(1) Raw DeleteO(n)O(1) Find/SearchO(log n)O(n)O(log n)

Binary Trees  Insertion = Find + Raw Insert –O(log n) + O(1) = O(log n)  Deletion = Find + Raw Delete + Find Replacement –O(log n) + O(1) + O(log n) = O(log n)

Binary Heaps  Arise from priority queues –Enqueue should be as efficient as possible –Dequeue will always remove the minimum/maximum item.

Binary Heap Binary HeapBinary Tree InsertionO(1)O(log n) Delete/Remove Min or Max O(log n) Find/SearchO(n)O(log n)