Tutorial 4 – List ADT. List ADT List: –A collection of homogeneous items ordered in linear fashion, e.g. List of names, phone numbers, integers, etc List.

Slides:



Advertisements
Similar presentations
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
Advertisements

Lists CS 3358.
Linked Lists.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Linked Lists Course Lecture Slides 23 July 2010 A list is only as strong.
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
CSC 212 – Data Structures Lecture 22: PositionList.
CS Data Structures II Review COSC 2006 April 14, 2017
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
Circular Arrays Neat trick: use a circular array to insert and remove items from a queue in constant time The idea of a circular array is that the end.
1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.
Queue using an array. .head.tail Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they.
Data Structures Topic #3. Today’s Agenda Ordered List ADTs –What are they –Discuss two different interpretations of an “ordered list” –Are manipulated.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
Summary of lectures (1 to 11)
Rossella Lau Lecture 4, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 4: C++ and list  Usage of Vector and List  C++
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Variations of Linked Lists CS 308 – Data Structures.
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.
Tutorial 5 Linked List Variations, Stack, & Queue.
Review for Midterm Chapter 1-9 CSc 212 Data Structures.
Linked Lists list elements are stored, in memory, in an arbitrary order explicit information (called a link) is used to go from one element to the next.
Design and Analysis of Algorithms CSC201 Shahid Hussain 1.
Tutorial 4 Linked List, Stack, & Queue. Linked List: Revision The concept of ADT List ADT List using Array –Pro & cons  Discussed in T02Q3 and today.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Dynamic Array. An Array-Based Implementation - Summary Good things:  Fast, random access of elements  Very memory efficient, very little memory is required.
Week 4 - Monday.  What did we talk about last time?  Queues  Implementing queues with circular arrays.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
The List ADT A sequence of zero or more elements A 1, A 2, A 3, … A N-1 N: length of the list A 1 : first element A N-1 : last element A i : position i.
1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Programming Abstractions Cynthia Lee CS106X. Topics:  Priority Queue › Linked List implementation › Heap data structure implementation  TODAY’S TOPICS.
Data Structures Using C++1 Chapter 5 Linked Lists.
CSC 212 Sequences & Iterators. Announcements Midterm in one week  Will cover through chapter 5 of book  Midterm will be open book, open note (but, closed.
Tutorial 3 - Linked List. Linked List: Revision The concept of ADT List ADT List using Array –Pro & cons  Discussed in T02Q3 and today in Q1! ADT List.
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
 Array is a data structure were elements are stored in consecutive memory location.in the array once the memory is allocated.it cannot be extend any more.
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.
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
Data Structure & Algorithms
CS32 Discussion Section 1B Week 3 TA: Hao Yu (Cody)
Lists List Implementations. 2 Linked List Review Recall from CMSC 201 –“A linked list is a linear collection of self- referential structures, called nodes,
 2015, Marcus Biel, Linked List Data Structure Marcus Biel, Software Craftsman
1 The Standard Template Library The STL is a collection of Container classes These are class templates for containers. A container is an object that stores.
UNIT-II Topics to be covered Singly linked list Circular linked list
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Templates Linked Lists.
Stack, Queues, and Priority Queues: Linked List Based
Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 24 to end.
Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 1 to 11.
UNIT-V ABSTRACT DATA TYPE 1.LIST 2.STACK 3.QUEUE EC6301-II-ECE-C.
CSC 172 DATA STRUCTURES. MIDTERM REVIEW MIDTERM EXAM 75 min 6 – 10 questions a lot like the quiz questions.
Unit – I Lists.
Cpt S 122 – Data Structures Abstract Data Types
Data Structure By Amee Trivedi.
UNIT – I Linked Lists.
Csc 2720 Data structure Instructor: Zhuojun Duan
Abstraction A tool (concept) to manage complexity
LINKED LISTS CSCD Linked Lists.
CMSC 341 Lecture 5 Stacks, Queues
Chapter 14: Queue and Priority Queue Implementations
11-3 LINKED LISTS A linked list is a collection of data in which each element contains the location of the next element—that is, each element contains.
CS212D: Data Structures Week 5-6 Linked List.
Figure 7.1 Some queue operations. Figure 7.1 Some queue operations.
Queues and Priority Queue Implementations
BY PROF. IRSHAD AHMAD LONE.
Presentation transcript:

Tutorial 4 – List ADT

List ADT List: –A collection of homogeneous items ordered in linear fashion, e.g. List of names, phone numbers, integers, etc List ADT –An ADT to support such data structure, with some basic operations, e.g. add(idx), get(idx), remove(idx), del_last, size, etc 2

List ADT Implementation Basically there are at least two ways: –Use Vector (i.e. array that can resize itself) Part of the implementation is discussed in Q1 & Q4 –Use Linked List Discussed in Q3 In Q2, we uses list ADT, which can be either using vector or linked list! 3

Linked List: Revision A Linked List Node has 2 parts: –Item/Value/Content –Pointers to immediate neighbors Single Linked List –Chain of linked list nodes –Traversal: start from head to tail –Usually: insert from head (ok for Stack) There are Linked List Variations –See the right hand side Best is to use STL (Slide 70-72) –A bug-free, ready-to-use Linked List Linked List with Tail Pointer –Can visit the tail very fast –Cannot delete the tail easily…  –In lecture note: not highlighted (revisited in Queue data structure later) Double Linked List (Slide 46-56) –Two pointers: forward/backward –Can go backwards –Can delete tail easily! –Extra pointer = more overhead  Circular Linked List (Slide 57-60) –Remember Tail only, Head = Tail.Next –Can visit all node from any node

Student Presentation T5: 1.Yan Xun 2.Yong Meng 3.Joseph Ling 4.Min Qi T10: 1.Song Yih 2.Lixun 3.Peidong 4.Muhammad Faizal T13: 1.Jingui 2.Chee Chung 3.Guolong 4.Ee Chan T9: 1.Lam Woon Cherk 2.Mah Chun How 3.Muhammad Daren Meisa 4.Ngoo Cheng Han T17: 1.Claudine 2.Guochen 3.Agrawal 4.Jack 5

Q1 – Additional Issues 1.Additional methods, try to implement these: A.add(idx, i) This is an overloaded methods: same name as add(i) It adds integer i in position idx, not just at the back B.del(idx) It deletes an item at position idx, not just at the back –How will you implement them in IntVector? 2.If your size() is O(n), make it O(1)! –O(n) – one single pass –O(1) – constant step(s)

Q2 – Additional Issues 1.What is the weakness of A.addPoint(Point p)? B.findNearest(Point refPt, Point& ansPt)?

Q3 – Additional Issues 1.A “better” Linked List A.How to access last node in O(1)? B.How to insert item after last node in O(1)? C.How to delete last node in O(1)?

Q4 – Additional Issues 1.How to know the runtime details of the methods in STL?

Next Week ThisWeek.Next is recess week –Use your recess week carefully! Revise up to Stack/Queue –We will discuss stack/queue in Tutorial 5 –CS1102C midterm test is ThisWeek.Next.Next Main topic will be List ADT (vector/linked list) and Stack/Queue Although C++ is not the main topic, it is usually asked as part of the solution –e.g. write C++ code to modify this Linked List, etc