Data Structures from Cormen, Leiserson, Rivest & Stein.

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

Queues and Linked Lists
Data Structure HKOI training /4/2010 So Pak Yeung.
Data Structures Lecture 13: QUEUES Azhar Maqsood NUST Institute of Information Technology (NIIT)
Alford Academy Business Education and Computing1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Stack and Queues.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Data Structures & Algorithms
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
10.Elementary data structures Hsu, Lih-Hsing. Computer Theory Lab. Chapter 11P Stacks and queues Stacks and queues are dynamic set in which element.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Appendix B.
Copyright © The McGraw-Hill Companies, Inc
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.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 2 Image Slides.
CHAPTER 3 : STACKS 3.1 Understand Stacks 3.2 Implement the operation of stack By : Suzila Yusof.
Chapter 8 Traffic-Analysis Techniques. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-1.
Data Structures - Queues
Stack and Queue.
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
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.
Elementary Data Structures Data Structures and Algorithms A. G. Malamos.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 4 Prepared by İnanç TAHRALI.
 STACK STACK  BASIC STACK OPERATIONS BASIC STACK OPERATIONS  PUSH ALGORITHM PUSH ALGORITHM  POP ALGORITHM POP ALGORITHM  EVALUATING A POSTFIX EXPRESSION.
Cosc237/data structures1 Data Types Every data type has two characteristics: 1.Domain - set of all possible values 2.set of allowable operations Built-in.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Stacks And Queues Chapter 18.
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.
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.
Heaps and basic data structures David Kauchak cs161 Summer 2009.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Linear Data Structures
Chapter 10 Elementary data structures Lee, Hsiu-Hui Ack: This presentation is based on the lecture slides from Hsu, Lih-Hsing, as well as various materials.
Computer Engineering Rabie A. Ramadan Lecture 6.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Lecture 21 Data Structures, Algorithms and Complexity Stacks and Queues GRIFFITH COLLEGE DUBLIN.
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 2: Getting Started (slides enhanced by N. Adlai A. DePano)
Chapter 13 Transportation Demand Analysis. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display
CS6045: Advanced Algorithms Data Structures. Dynamic Sets Next few lectures will focus on data structures rather than straight algorithms In particular,
Elementary data structures
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
G64ADS Advanced Data Structures
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.
Chapter 12 – Data Structures
Chapter 15 Lists Objectives
Stacks and Queues.
CS 583 Analysis of Algorithms
Elementary Data Structures
Basic Data Types Queues
Principles of Computing – UFCFA3-30-1
Algorithms Part III. Data Structures
Introduction to Algorithms Second Edition by
אחסון (אירגון) מידע DATA DATA DATA Link Link Link … …
Introduction to Algorithms Second Edition by
Data Structures - Review
Dynamic Sets (III, Introduction)
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
CS6045: Advanced Algorithms
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
Data Structures - Review
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
Presentation transcript:

Data Structures from Cormen, Leiserson, Rivest & Stein

Sets Fundamental to CS Dynamis Sets: manipulated by algorithms, and can grow, shrink, change over time. Operations on sets: –SEARCH(S,k), returns a pointer to k location or NIL –INSERT(S,k) –DELETE(S,k)

Dynamic sets operations (contd) –MINIMUM(S) –MAXIMUM(S) –SUCCESSOR(S,x) –PREDECESSOR(S,x) Most operations return pointers to some location

Stacks and Queues Dynamic sets in which the element removed from the set in the DELETE operation is pre-specified. LIFO – last in first out – in stacks FIFO – first in first out – in queue Stacks - folklore names: PUSH – INSERT POP - DELETE

Stacks We can implement a stack of almost n elements with an array S[1..n]. top[S] – indexes the most recently inserted element. The stack consists of S[1],…S[top[S]] elements, S[1] is the element at the bottom of the stack, and S[top[S]] is the element at the top of the stack.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Stack operations When top[S]=0 the stack is empty Stack “errors”: Underflow – when an empty stack is popped Overflow - If top[S]>n

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Queues ENQUEUE – INSERT to a queue DEQUEUE – Delete from a queue Queues have a head and a tail Inserting at the tail Deleting at the head head[Q] – points to the head tail[Q]-the location to insert a new element

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.