1 / 10

Phones off Signs out Picnic on Friday 

Phones off Signs out Picnic on Friday . Preliminaries. Attendance sheets I remembered! HW1 due tonight progress report Stage 1 due on Friday progress report. Today. Finish off discussion Bag’s iterator class For-each loop: syntactic sugar Software design issues

roman
Download Presentation

Phones off Signs out Picnic on Friday 

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Phones off Signs out Picnic on Friday 

  2. Preliminaries • Attendance sheets • I remembered! • HW1 due tonight • progress report • Stage 1 due on Friday • progress report

  3. Today • Finish off discussion Bag’s iterator class • For-each loop: syntactic sugar • Software design issues • In context of list definition • Recursion • In context of list definition

  4. Lists • We’ve seen an array-based implementation of a Collection, the Bag. • ArrayList is very much the same. • We’ll take a short tour of the code

  5. 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

  6. 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

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

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

  9. 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”.

More Related