No homework this week Stage 2 starts next week. Code review Team with N members is assigned N submissions to review Discuss submissions within team Everyone.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Pointers.
Lists in Lisp and Scheme a. Lists are Lisp’s fundamental data structures, but there are others – Arrays, characters, strings, etc. – Common Lisp has moved.
ArrayLists David Kauchak cs201 Spring Extendable array Arrays store data in sequential locations in memory Elements are accessed via their index.
Quick Review of Apr 10 material B+-Tree File Organization –similar to B+-tree index –leaf nodes store records, not pointers to records stored in an original.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
Data Structures: A Pseudocode Approach with C
Introduction to Trees. Tree example Consider this program structure diagram as itself a data structure. main readinprintprocess sortlookup.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
CPSC 322 Introduction to Artificial Intelligence September 27, 2004.
Preliminaries Attendance sheets –I remembered! HW1 due tonight –progress report Stage 1 due on Friday –progress report.
A list = a Linear Recursive Structure (LRS or LRStruct) What is a list? 1.the empty list is a list 2.a pair whose tail is a list is itself a list This.
Preliminaries Attendance sheets –I remembered! Survey links –HW1 time survey –Anonymous feedback survey HW discussion (4PM, Commons 9)
Preliminaries Stage 1 due tonight by 9:00 PM HW1 discussion (4PM, Commons 9) –may try for next week? HW2 available later today, due Monday by 9:00 PM.
Data Structures Hash Tables
Lists We’ve seen an array-based list implementation, the ArrayList. Advantage of an array-based implementation: –fast access to a specific index –typically.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Lists We’ve seen an array-based list implementation, the ArrayList.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part B Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
1 Data Structures Data Structures Topic #2. 2 Today’s Agenda Data Abstraction –Given what we talked about last time, we need to step through an example.
Data Structures Topic #3. Today’s Agenda Ordered List ADTs –What are they –Discuss two different interpretations of an “ordered list” –Are manipulated.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
CSC 212 – Data Structures Lecture 13: Linked Lists.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
Architecture styles Pipes and filters Object-oriented design Implicit invocation Layering Repositories.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
CS212: DATA STRUCTURES Lecture 1: Introduction. What is this course is about ?  Data structures : conceptual and concrete ways to organize data for efficient.
Week 3 – Wednesday.  What did we talk about last time?  ADTs  List implementation with a dynamic array.
TECH Computer Science Dynamic Sets and Searching Analysis Technique  Amortized Analysis // average cost of each operation in the worst case Dynamic Sets.
CSE 143 Lecture 6 Linked Lists slides created by Ethan Apter
Data structures Abstract data types Java classes for Data structures and ADTs.
Singly Linked Lists Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University 1.
Hashing Sections 10.2 – 10.3 CS 302 Dr. George Bebis.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 9.
Object Oriented Software Development
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
WEEK 1 Hashing CE222 Dr. Senem Kumova Metin
Dynamic Array. An Array-Based Implementation - Summary Good things:  Fast, random access of elements  Very memory efficient, very little memory is required.
CS535 Programming Languages Chapter - 10 Functional Programming With Lists.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Lecture - 10 on Data Structures. 6:05:57 PM Prepared by, Jesmin Akhter, Lecturer, IIT,JU.
Copyright © 0 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java From Control Structures through Data Structures by Tony.
Patterns for Decoupling Data Structures and Algorithms or How visitors can help you grow! Stephen Wong, Oberlin College Dung “Zung” Nguyen, Pepperdine.
Patterns for Decoupling Data Structures and Algorithms Dung “Zung” Nguyen Pepperdine University / University of Houston Stephen Wong Oberlin College
Indexing Database Management Systems. Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files File Organization 2.
Linked Lists. Introduction In linked list each item is embedded in a link Each item has two parts – Data – Pointer to the next item in the list Insert,
CS 241 Discussion Section (2/9/2012). MP2 continued Implement malloc, free, calloc and realloc Reuse free memory – Sequential fit – Segregated fit.
CS 241 Discussion Section (12/1/2011). Tradeoffs When do you: – Expand Increase total memory usage – Split Make smaller chunks (avoid internal fragmentation)
Question of the Day  What three letter word completes the first word and starts the second one: DON???CAR.
Amortized Analysis and Heaps Intro David Kauchak cs302 Spring 2013.
Data Structures and Algorithm Analysis Dr. Ken Cosh Linked Lists.
Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 1 to 11.
CS212: Data Structures and Algorithms Lecture # 4 Linked List.
Indexing and hashing.
CSCI-255 LinkedList.
Linked Lists Chapter 6 Section 6.4 – 6.6
Data Structure Interview Question and Answers
Data Structure and Algorithms
Lists in Lisp and Scheme
Lecture 2 of Computer Science II
CSCI 3333 Data Structures Linked Lists.
Arrays and Linked Lists
Hashing Sections 10.2 – 10.3 Lecture 26 CS302 Data Structures
Amortized Analysis and Heaps Intro
Lecture-Hashing.
Lecture 3 – Data collection List ADT
Presentation transcript:

No homework this week Stage 2 starts next week

Code review Team with N members is assigned N submissions to review Discuss submissions within team Everyone on team writes up one review Write-ups are done on an individual basis Due on Monday Stage 2 begins on Monday

Today Software design issues –In context of list definition Recursion –In context of list definition

Lists We’ve seen an array-based list implementation, the ArrayList. Advantage of an array-based implementation: –fast access to a specific index –typically less space usage than other options Disadvantage of an array-based implementation: –can be expensive to insert items –resizing is an expensive operation

Amortization Resizing of array-based data structures involves a tradeoff: –many insertions (as in our Bag) are very efficient since no allocation of space is required (an array is allocated as a big block of memory) –some insertions (as in our Bag) are very expensive since resizing must take place

Linked List A linked list is a list implementation which spreads out the cost of space allocation evenly to all insertions. Each insertion involves allocation of space

Advantages/Disadvantages Advantages –predictable cost of insertion –efficient insertion at any point in structure Disadvantages –extra space required to store links –inefficient indexing

Comparison of storage A pair has a first and a second element When pairs are used to construct lists, the first is called the “head” or the “car” the second is called the “tail”, “rest” or “cdr” the pair is called a “cons cell” or simply a “cons”.

Linked list implementations Textbook discusses a typical linked list implementation java.util.LinkedList is another typical implementation These implementations have procedural, not object-oriented, roots.

Traditional implementations provide a large number of methods – making it difficult to reuse if less functionality is desired; provide no means, beyond inheritance, to extend functionality to suit a specific situation; and adding functionality requires knowledge of internal structure of the list.

So… These implementations are inflexible, and do not exhibit good OO design. In lecture we will discuss a state-based list implementation which can be easily extended with new functionality.

Variant/Invariant decomposition Design principle which leads to cohesive and decoupled components That which is invariant is put into one component Variant properties/behaviors are factored out into separate components Compare this to what we saw with e.g. Observer pattern: –decoupling of event generation (invariant) from event handling (variant)

a list = a Linear Recursive Structure (LRS or LRStruct) What is a list? 1.the empty list is a list 2.a pair whose tail is a list is itself a list This is a recursive definition! (1) is called the base case, and (2) is called the recursive case. Note that traditional implementations do not follow this precise definition of what a list is: –many have no explicit representation of an empty list –none are recursive on the list; instead they recurse on a list node This has implications for how the structure can support extension (see Visitor support, in later slides)

States A list can therefore be in one of two states: –empty (corresponding to the base case) –non-empty (corresponding to the recursive case) The state-based implementation we will study makes this distinction explicit in the representation