Linked Data Structures: Chapter 9, Slide 1 Linked data structures - versatile data structures to model complex real world situations and entities. List,

Slides:



Advertisements
Similar presentations
SYMBOL TABLES &CODE GENERATION FOR EXECUTABLES. SYMBOL TABLES Compilers that produce an executable (or the representation of an executable in object module.
Advertisements

Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
Binary Trees CSC 220. Your Observations (so far data structures) Array –Unordered Add, delete, search –Ordered Linked List –??
Dynamic allocation and deallocation of memory: Chapter 4, Slide 1.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Main Index Contents 11 Main Index Contents Week 6 – Binary Trees.
CS 201 Data Structures and Algorithms Chapter 4: Trees (BST) Text: Read Weiss, §4.3 1Izmir University of Economics.
Introduction to Trees. Tree example Consider this program structure diagram as itself a data structure. main readinprintprocess sortlookup.
Modern Information Retrieval
CPSC 231 Organizing Files for Performance (D.H.) 1 LEARNING OBJECTIVES Data compression. Reclaiming space in files. Compaction. Searching. Sorting, Keysorting.
FALL 2004CENG 351 Data Management and File Structures1 External Sorting Reference: Chapter 8.
FALL 2006CENG 351 Data Management and File Structures1 External Sorting.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Important Problem Types and Fundamental Data Structures
Binary Trees Chapter 6.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
CHP - 9 File Structures. INTRODUCTION In some of the previous chapters, we have discussed representations of and operations on data structures. These.
IntroductionIntroduction  Definition of B-trees  Properties  Specialization  Examples  2-3 trees  Insertion of B-tree  Remove items from B-tree.
CHAPTER 71 TREE. Binary Tree A binary tree T is a finite set of one or more nodes such that: (a) T is empty or (b) There is a specially designated node.
1 Trees Tree nomenclature Implementation strategies Traversals –Depth-first –Breadth-first Implementing binary search trees.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
Computers Data Representation Chapter 3, SA. Data Representation and Processing Data and information processors must be able to: Recognize external data.
CS Data Structures Chapter 5 Trees. Chapter 5 Trees: Outline  Introduction  Representation Of Trees  Binary Trees  Binary Tree Traversals 
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.
Variables and Objects, pointers and addresses: Chapter 3, Slide 1 variables and data objects are data containers with names the value of the variable is.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
Data Strcutures.
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 Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
TECH Computer Science Dynamic Sets and Searching Analysis Technique  Amortized Analysis // average cost of each operation in the worst case Dynamic Sets.
Chapter 21 Binary Heap.
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
1 Joe Meehean.  Problem arrange comparable items in list into sorted order  Most sorting algorithms involve comparing item values  We assume items.
Chapter 9 Abstract Data Types and Algorithms Nell Dale John Lewis.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 26 Sorting.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
Data Structures Types of Data Structure Data Structure Operations Examples Choosing Data Structures Data Structures in Alice.
Chapter 5: Hashing Part I - Hash Tables. Hashing  What is Hashing?  Direct Access Tables  Hash Tables 2.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
1 5. Abstract Data Structures & Algorithms 5.1 Data Structure Fundamentals.
Review 1 Queue Operations on Queues A Dequeue Operation An Enqueue Operation Array Implementation Link list Implementation Examples.
CPSC 252 Binary Heaps Page 1 Binary Heaps A complete binary tree is a binary tree that satisfies the following properties: - every level, except possibly.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Lecture 10COMPSCI.220.FS.T Binary Search Tree BST converts a static binary search into a dynamic binary search allowing to efficiently insert and.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
Data Structure and Algorithms
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Amortized Analysis and Heaps Intro David Kauchak cs302 Spring 2013.
Chapter 9 Abstract Data Types and Algorithms Nell Dale John Lewis.
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 26 Sorting.
Chapter 12 – Data Structures
12 C Data Structures.
COSC160: Data Structures Binary Trees
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Lecture 22 Binary Search Trees Chapter 10 of textbook
Hashing Exercises.
abstract containers sequence/linear (1 to 1) hierarchical (1 to many)
A Robust Data Structure
CENG 351 Data Management and File Structures
Chapter 20: Binary Trees.
File System Implementation
Important Problem Types and Fundamental Data Structures
LINEAR DATA STRUCTURES
Presentation transcript:

Linked Data Structures: Chapter 9, Slide 1 Linked data structures - versatile data structures to model complex real world situations and entities. List, stacks, trees, graphs etc. just to mention some. Consider a simple binary search tree for characters: Analyze chapter9_1 program:chapter9_1 Average time complexity to search for an item is O(n log n) Organization: Binary tree, left child has value less than the parent, the right child has value greater than the parent.

Chapter 9, Slide 2 J E K B DA NULL Depth first traversal will produce alphabetically ordered sequence: A B D E J K

Chapter 9, Slide 3 The nature of “links” -- usually pointers, but any reference will do: Analyze chapter9_2 program:chapter9_2 The references are array indexes (arrays are modeled on memory!). This will work fine for a tree with up to 100 nodes. A natural way to serialize a binary tree. Not necessarily are linked data structures created on the heap only: Analyze chapter9_3 program that is a recursive descent parser for a list of characters separated by commas and builds a binary search tree on the stack. chapter9_3 Though, it is not very practical. Most commonly, linked data structures are linked by pointers and are build on the heap.

Chapter 9, Slide 4 Pointer-based linked data structures are “flexible”, which is mostly good, however it is bad for “moving” the structure elsewhere in memory, or “transmitting” it over a communication channel, or “recording” it to auxiliary memory. compaction: we say that a linked data structure is compacted if it occupies a contiguous segment of memory and all pointers (addresses) are relative to the beginning of that segment. serialization: we say that a linked data structure is serialized if it occupies several contiguous segments of memory and all pointers (addresses) are relative to the beginning of that segment where the pointer is stored. Thus compaction is the extreme form of serialization. A serialized structure can easily by “moved” in memory just by “moving” the whole segment(s), “transmitted” byte by byte over a communication channel, or “recorded” to auxiliary memory and later restored.

Chapter 9, Slide 5 Illustration of serialization+allocation from arena: chapter9_4 program. chapter9_4 The “relativized” addresses are a pair of short integers, the first is segment+1 and the second is offset. Let us now visualize the arena after each stage of the process. First “building” the tree:

Chapter 9, Slide 6

Chapter 9, Slide 7

Chapter 9, Slide 8 The tree is build, now we start the relativization process:

Chapter 9, Slide 9 We deliberately designed the structure/class NODE so that it has size of 12 bytes, but 3 bytes are wasted on padding:

Chapter 9, Slide 10 We can compact the nodes with no space wasted: But then we cannot use p->lch or p->rch, we must have our custom-made access functions: analyze chapter9_5 program.chapter9_5

Chapter 9, Slide 11 After relativization: End of slides for chapter 9