Chapter 8: Data Abstractions

Slides:



Advertisements
Similar presentations
COSC2007 Data Structures II Chapter 10 Trees I. 2 Topics Terminology.
Advertisements

Data structure is concerned with the various ways that data files can be organized and assembled. The structures of data files will strongly influence.
Binary Trees CSC 220. Your Observations (so far data structures) Array –Unordered Add, delete, search –Ordered Linked List –??
Connecting with Computer Science, 2e
Data Structures: Trees i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
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.
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
Binary Trees Chapter 6.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Grade 12 Computer Studies HG
Chapter 8 Data Abstractions. 2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing Data Structures 8.3 A Short Case Study 8.4.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
1 Data Abstractions Shyh-Kang Jeng Department of Electrical Engineering/ Graduate Institute of Communication Engineering National Taiwan University.
Chapter 8 Data Abstractions Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Connecting with Computer Science 2 Objectives Learn what a data structure is and how it is used Learn about single and multidimensional arrays and how.
Lists ADT (brief intro):  Abstract Data Type  A DESCRIPTION of a data type  The data type can be anything: lists, sets, trees, stacks, etc.  What.
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
Chapter 8: Data Abstractions Senem Kumova Metin. 8-2 Chapter 8: Data Abstractions 8.1 Basic Data Structures – Arrays – Lists, Stacks, Queues – Trees 8.2.
Connecting with Computer Science, 2e Chapter 8 Data Structures.
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.
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.
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
Chapter 9 Abstract Data Types and Algorithms Nell Dale John Lewis.
9-1 Abstract Data Types Abstract data type A data type whose properties (data and operations) are specified independently of any particular implementation.
Overview of Course Java Review 1. This Course Covers, using Java Abstract data types Design, what you want them to do (OOD) Techniques, used in implementation.
Chapter 8 Data Abstractions. © 2005 Pearson Addison-Wesley. All rights reserved 8-2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
12/8/2015CS Introduction to Information Engineering1 Data Structure 12/8/2015 Che-Rung Lee.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
Data Structure and Algorithms
Chapter 9 Abstract Data Types and Algorithms Nell Dale John Lewis.
Chapter 11 Indexing And Hashing (1) Yonsei University 1 st Semester, 2016 Sanghyun Park.
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
ADT description Implementations
Data Structure By Amee Trivedi.
Chapter 12 – Data Structures
Class Review.
Data Structure Interview Question and Answers
12 C Data Structures.
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Problems with Linked List (as we’ve seen so far…)
Cinda Heeren / Geoffrey Tien
Introduction to Data Structure
i206: Lecture 13: Recursion, continued Trees
8.1 Tree Terminology and Applications
structures and their relationships." - Linus Torvalds
COSC2100: Data Structures and Algorithms
Trees and Binary Trees.
Chapter 8: Data Abstractions
Further Data Structures
Introduction to Data Structures
Chapter 11 Indexing And Hashing (1)
Trees.
Pointers & Dynamic Data Structures
Important Problem Types and Fundamental Data Structures
OPIM 915 Fall 2010 Data Structures 23-38,
structures and their relationships." - Linus Torvalds
Chapter 8: Data Abstractions
Presentation transcript:

Chapter 8: Data Abstractions

Chapter 8: Data Abstractions Data Structure Fundamentals Implementing Data Structures A Short Case Study Customized Data Types Classes and Objects Pointers in Machine Language

Basic Data Structures Homogeneous array Heterogeneous array List Tree Stack Queue Tree

Lists, stacks, and queues

Terminology for Lists List: A collection of data whose entries are arranged sequentially Head: The beginning of the list Tail: The end of the list

Terminology for Stacks Stack: A list in which entries are removed and inserted only at the head LIFO: Last-in-first-out Top: The head of list (stack) Bottom or base: The tail of list (stack) Pop: To remove the entry at the top Push: To insert an entry at the top

Terminology for Queues Queue: A list in which entries are removed at the head and are inserted at the tail FIFO: First-in-first-out

An example of an organization chart (A tree structure)

Terminology for a Tree Tree: A collection of data whose entries have a hierarchical organization Node: An entry in a tree Root node: The node at the top Terminal or leaf node: A node at the bottom

Terminology for a Tree (continued) Parent: The node immediately above a specified node Child: A node immediately below a specified node Ancestor: Parent, parent of parent, etc. Descendent: Child, child of child, etc. Siblings: Nodes sharing a common parent

Terminology for a Tree (continued) Binary tree: A tree in which every node has at most two children Depth: The number of nodes in longest path from root to leaf

Tree terminology

Additional Concepts Static Data Structures: Size and shape of data structure does not change Dynamic Data Structures: Size and shape of data structure can change Pointers: Used to locate data

Novels arranged by title but linked according to authorship

Storing Arrays Homogeneous arrays Heterogeneous arrays Row-major order versus column major order Address polynomial Heterogeneous arrays Components can be stored one after the other in a contiguous block Components can be stored in separate locations identified by pointers

The array of temperature readings stored in memory starting at address x

A two-dimensional array with four rows and five columns stored in row major order

Storing the heterogeneous array Employee

Storing Lists Contiguous list: List stored in a homogeneous array Linked list: List in which each entries are linked by pointers Head pointer: Pointer to first entry in list NIL pointer: A “non-pointer” value used to indicate end of list

Names stored in memory as a contiguous list

The structure of a linked list

Deleting an entry from a linked list

Inserting an entry into a linked list

Storing Stacks and Queues Stacks usually stored as contiguous lists Queues usually stored as Circular Queues Stored in a contiguous block in which the first entry is considered to follow the last entry Prevents a queue from crawling out of its allotted storage space

A stack in memory

A queue implementation with head and tail pointers

Storing Binary Trees Linked structure Each node = data cells + two child pointers Accessed via a pointer to root node Contiguous array structure (Heap) A[1] = root node A[2],A[3] = children of A[1] A[4],A[5],A[6],A[7] = children of A[2] and A[3]

A circular queue containing the letters P through V

The structure of a node in a binary tree

The conceptual and actual organization of a binary tree using a linked storage system

A tree stored without pointers

A sparse, unbalanced tree shown in its conceptual form and as it would be stored without pointers

Manipulating Data Structures Ideally, a data structure should be manipulated solely by pre-defined procedures. Example: A stack typically needs at least push and pop procedures. The data structure along with these procedures constitutes a complete abstract tool.

A procedure for printing a linked list

Case Study Problem: Construct an abstract tool consisting of a list of names in alphabetical order along with the operations search, print, and insert.

The letters A through M arranged in an ordered tree

The binary search as it would appear if the list were implemented as a linked binary tree

searching for the letter J in a binary search tree

Printing a search tree in alphabetical order

A procedure for printing the data in a binary tree

Inserting the entry M into the list B, E, G, H, J, K, N, P stored as a tree

User-defined Data Type A template for a heterogeneous structure Example: define type EmployeeType to be {char Name[25]; int Age; real SkillRating; }

Abstract Data Type A user-defined data type with procedures for access and manipulation Example: define type StackType to be {int StackEntries[20]; int StackPointer = 0; procedure push(value) {StackEntries[StackPointer] ← value; StackPointer ¬ StackPointer + 1; } procedure pop . . .

Class An abstract data type with extra features Characteristics can be inherited Contents can be encapsulated Constructor methods to initialize new objects

A stack of integers implemented in Java and C#

Pointers in Machine Language Immediate addressing: Instruction contains the data to be accessed Direct addressing: Instruction contains the address of the data to be accessed Indirect addressing: Instruction contains the location of the address of the data to be accessed

Our first attempt at expanding the machine language in Appendix C to take advantage of pointers

Loading a register from a memory cell that is located by means of a pointer stored in a register