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.

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

Stacks, Queues, and Linked Lists
ADVANCED DATA STRUCTURES AND ALGORITHM ANALYSIS Chapter 3 Lists, Stacks, and Queues.
Stacks  a data structure which stores data in a Last-in First-out manner (LIFO)  has a pointer called TOP  can be implemented by either Array or Linked.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Advanced Data Structures
Trees Chapter 8.
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Fall 2007CS 2251 Iterators and Tree Traversals. Fall 2007CS 2252 Binary Trees In a binary tree, each node has at most two subtrees A set of nodes T is.
CS 206 Introduction to Computer Science II 03 / 20 / 2009 Instructor: Michael Eckmann.
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.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Heaps & Priority Queues Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L12 (Chapter 20) Lists, Stacks,
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Dr. Andrew Wallace PhD BEng(hons) EurIng
Stacks CS-240 & CS-341 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed.
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.
Important Problem Types and Fundamental Data Structures
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Trees. Tree Terminology Chapter 8: Trees 2 A tree consists of a collection of elements or nodes, with each node linked to its successors The node at the.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Review 1 Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example.
COMP 103 Priority Queues, Partially Ordered Trees and Heaps.
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.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
For Monday Read Weiss, chapter 7, sections 1-3. Homework –Weiss, chapter 4, exercise 6. Make sure you include parentheses where appropriate.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
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’
Recursive Data Structures and Grammars  Themes  Recursive Description of Data Structures  Grammars and Parsing  Recursive Definitions of Properties.
Data Structures: Advanced Damian Gordon. Advanced Data Structure We’ll look at: – Linked Lists – Trees – Stacks – Queues.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Stacks And Queues Chapter 18.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
Chapter 12 Abstract Data Type. Understand the concept of an abstract data type (ADT). Understand the concept of a linear list as well as its operations.
CS223 Advanced Data Structures and Algorithms 1 Priority Queue and Binary Heap Neil Tang 02/09/2010.
Heaps & Priority Queues
1 Trees General Trees  Nonrecursive definition: a tree consists of a set of nodes and a set of directed edges that connect pairs of nodes.
Give Eg:? Queues. Introduction DEFINITION: A Queue is an ordered collection of element in which insertions are made at one end and deletions are made.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
COSC 2P03 Week 21 Stacks – review A Last-In First-Out (LIFO) structure Basic Operations: –push : insert data item onto top of stack –pop : remove data.
DATA STRUCURES II CSC QUIZ 1. What is Data Structure ? 2. Mention the classifications of data structure giving example of each. 3. Briefly explain.
Chapter 12 Abstract Data Type.
Data Structure By Amee Trivedi.
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
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Chapter 15 Lists Objectives
Stacks and Queues.
Source: Muangsin / Weiss
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Lesson Objectives Aims
ITEC 2620M Introduction to Data Structures
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
Binary Tree Traversals
Priority Queues & Heaps
Important Problem Types and Fundamental Data Structures
Presentation transcript:

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 3.String

Examples of data structures 1.Stack 2.Queue 3.Linked List 4.Tree 5.Hash Table 6.Priority Queue 7.Heap 8.Binary Search Tree

Stack A stack is a data structure into which items may be inserted and from which items may be deleted at one end, called the top of the stack. That is, a data structure in which access is restricted to the most recently inserted item. A stack is a LIFO structure – last in first out.

Operations on Stacks 1.push – add an element to the top of the stack 2.pop – read and remove an element from the top of the stack 3.top – read the top element (without removing it) 4.isEmpty – returns true if no element in the stack 5.isFull – returns true if the stack can hold no more elements 6.Destroy – get rid of stack

Queue A queue is a data structure from which items may be deleted at one end (called the front of the queue) and into which items may be inserted at the other end (called the rear of the queue). That is, a data structure which restricts access to the least recently inserted item. A queue is a FIFO structure – first in first out

Operations -- Queue 1.enqueue – add an element at the rear of the queue 2.dequeue – read and remove an element from the front of the queue. 3.getFront – read (without removing) the element in front of the queue. 4.isEmpty – returns true if there is no element in the queue 5.isFull – returns true if the queue can hold no more elements 6.destroy – get rid of the queue

Linked List A linked list is collection of items in which items have a position. That is, a collection of nodes that hold data and pointers to the next node (and possibly to the previous node) in the list.

Operations – Linked list 1.Add an element 2.Remove an element 3.Find an element 4.Check for an empty list 5.Destroy the list

Tree A tree consists of a set of nodes and a set of edges that connect pairs of nodes such that 1. One node is distinguished as the root. 2.Every node c, except the root, is connected by an edge from exactly one other node p. p is c’s parent and c is one of p’s children. 3.A unique path traverses from the root to each node.

Tree Operations 1.Insert element 2.Remove element 3.Find element (Search) 4.Traverse – move through the tree and visit each node 5.Check if the tree is empty

Binary Tree A binary tree is a tree such that each node has at most two children. A binary search tree is a binary tree that has its data values arranged as follows: each node in the tree contains a value that is larger than each value in its left subtree and smaller than each value in its right subtree.

Hash Table A data structure that allows very fast find, add, and delete operations (most of the time). Hash Function - converts a data value into an index.

Priority Queue A priority queue is like a queue, but elements are deleted in order of priority Uses: –Emergency room –Main Frame Job Control payroll would be assigned a higher priority than some other jobs –Event-driven simulation –Printer Queue