1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.

Slides:



Advertisements
Similar presentations
Lists CS 3358.
Advertisements

Lists and the Collection Interface Chapter 4. Chapter Objectives To become familiar with the List interface To understand how to write an array-based.
Data Structures.
M180: Data Structures & Algorithms in Java
Data Structures: A Pseudocode Approach with C
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
Processing Data in External Storage CS Data Structures Mehmet H Gunes Modified from authors’ slides.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Manajemen Basis Data Pertemuan 2 Matakuliah: M0264/Manajemen Basis Data Tahun: 2008.
Lists and the Collection Interface Chapter 4. Chapter 4: Lists and the Collection Interface2 Chapter Objectives To become familiar with the List interface.
©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Data Structure Data structure uses collection of related variables that can be accessed.
Fall 2007CS 2251 Lists and the Collection Interface Chapter 4.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
Summary of lectures (1 to 11)
Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
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.
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
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.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Prepared By Ms.R.K.Dharme Head Computer Department.
Lists. Container Classes Many applications in Computer Science require the storage of information for collections of entities e.g. a student registration.
Lists 1. Introduction Data: A finite sequence of data items. Operations: Construction: Create an empty list Empty: Check if list is empty Insert: Add.
A first look an ADTs Solving a problem involves processing data, and an important part of the solution is the careful organization of the data In order.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
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 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Chapter 15 A External Methods. © 2004 Pearson Addison-Wesley. All rights reserved 15 A-2 A Look At External Storage External storage –Exists beyond the.
1 CS 311 Data Structures. 2 Instructor Name : Vana Doufexi Office : 2-229, Ford Building Office hours: By appointment.
© 2006 Pearson Addison-Wesley. All rights reserved5 B-1 Chapter 5 (continued) Linked Lists.
1 Data Organization Example 1: Heap storage management –Keep track of free chunks of memory Example 2: A simple text editor –Maintain a sequence of lines.
Chapter Lists Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
 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.
Data Structure and Algorithm Introduction.  The manner in which computer program is being developed is not as simple as you may possibly think.  It.
1 Chapter 4 Unordered List. 2 Learning Objectives ● Describe the properties of an unordered list. ● Study sequential search and analyze its worst- case.
© 2006 Pearson Addison-Wesley. All rights reserved15 A-1 Chapter 15 External Methods.
 2015, Marcus Biel, Linked List Data Structure Marcus Biel, Software Craftsman
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
CSCE , SPRING 2016 INSTRUCTOR: DR. NANCY M. AMATO 1.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
1 Data Organization Example 1: Heap storage management Maintain a sequence of free chunks of memory Find an appropriate chunk when allocation is requested.
UNIT-V ABSTRACT DATA TYPE 1.LIST 2.STACK 3.QUEUE EC6301-II-ECE-C.
CH 1-4 : INTRODUCTION ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND.
Lists and the Collection Interface Chapter 4. Chapter 4: Lists and the Collection Interface2 Chapter Objectives To become familiar with the List interface.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Advanced Data Structures Lecture 1
Linked List ADT used to store information in a list
Unit – I Lists.
CSCI-255 LinkedList.
Linked Lists Chapter 5 (continued)
Linked Lists Chapter 6 Section 6.4 – 6.6
Arrays and Linked Lists
Sequences 11/27/2018 1:37 AM Singly Linked Lists Singly Linked Lists.
Linked Lists.
Problem Understanding
Linked List and Selection Sort
Introduction to Data Structure
Linked Lists Chapter 5 (continued)
Data Structures & Algorithms
Lecture 3 – Data collection List ADT
Problem Understanding
Presentation transcript:

1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation. In both cases we have a sequence of data items (activation records, actions) and we can only add and remove items from one end of the sequence. We can design a data organization scheme that retains the general characteristics of this "data and operations" model (without any dependencies on the type of data or method of implementation). This is called data abstraction. Big advantage: code reuse. We can use the same scheme for both problems.

2 Problem Solving Encapsulation The way the data is organized and the operations that can be performed on it are implemented should be hidden. Data can be manipulated in a controlled way, only through an interface. The internal details are hidden. This is called encapsulation. Big advantage: The code has higher maintainability. The internal organization/implementation can be modified/improved without changing the interface. Big advantage: Outside objects cannot interfere with the internal organization, inadvertently corrupting it.

3 Problem Solving Information hiding A solution typically consists of different modules that interact with one another. Information hiding is the idea of concealing details from other modules that do not need to know those details.

4 Data organization Major components: The data The operations allowed on it These make up an Abstract Data Type A Data Structure is a construct that implements a particular ADT. Example: An indexed-list ADT.

5 The List ADT Data: a collection of homogeneous elements arranged in a sequence Operations: Insert Delete Find Update Retrieve Length

6 The List ADT: Operations Retrieve Which element? Specify an index, OR Use a pointer to the current location What additional operations will be needed in this case? Insert Where? At some index, OR Before /after current location What complications arise in this case? We'll have problems inserting at the tail/head of the list. Possible solution: a dummy node. BUT, we must be careful not to allow data retrieval at that node.

7 The List Data Structure Implementation 1 : Contiguous memory Use a dynamic array How is each operation implemented? How efficient is each operation? Random access capability good for retrieval when we use index rather than current pointer. Important: the list ADT does NOT provide random access. We will need to shift elements every time we insert or delete. In addition, if the array fills up, we need to reallocate a bigger chunk of memory. We will need to reallocate when it fills up.

8 The List Data Structure Implementation 2 : Linked memory Use a node structure to store the data and a pointer to the next node, to create a chain of nodes. Uses more space than the array (due to the pointers) but insert/delete do not require shifting However, deleting requires us to traverse the whole list in order to access the predecessor of the current node. Trick solution (works for deleting any node but the last): move the next node's contents into the one to be deleted and then physically remove the next node. This maintains the correct abstract picture of the structure. We can use a similar trick for the insert operation. See ~b11/labs/Templates for an example.