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.

Slides:



Advertisements
Similar presentations
Lists CS 3358.
Advertisements

Linked Lists.
DATA STRUCTURES USING C++ Chapter 5
Linked Lists Linked Lists Representation Traversing a Linked List
CHP-5 LinkedList.
Data Structure Lecture-3 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
M180: Data Structures & Algorithms in Java
Review Learn about linked lists
Data Structures: A Pseudocode Approach with C
1 Linked Lists Gordon College Prof. Brinton. 2 Linked List Basics Why use? 1.Efficient insertion or deletion into middle of list. (Arrays are not efficient.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.
Memory Management A memory manager should take care of allocating memory when needed by programs release memory that is no longer used to the heap. Memory.
©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Data Structure Data structure uses collection of related variables that can be accessed.
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.
Summary of lectures (1 to 11)
Chapter 3: Arrays, Linked Lists, and Recursion
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.
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.
Data Structures and Algorithms Data Structures and Algorithms (CS210/ESO207/ESO211) Lecture 7 Data Structures Modeling versus Implementation Example: Abstract.
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
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.
Data Structure & Algorithm
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
1 Data Structures CSCI 132, Spring 2014 Lecture 20 Linked Lists.
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.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Linked List by Chapter 5 Linked List by
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.
M180: Data Structures & Algorithms in Java Linked Lists Arab Open University 1.
1 Linked Lists (Lec 6). 2  Introduction  Singly Linked Lists  Circularly Linked Lists  Doubly Linked Lists  Multiply Linked Lists  Applications.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
Chapter Lists Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
Linear Data Structures
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More Linking.
 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.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
Data Structure and Algorithm Introduction.  The manner in which computer program is being developed is not as simple as you may possibly think.  It.
Data Structure & Algorithms
Chapter 5 Record Storage and Primary File Organizations
© 2006 Pearson Addison-Wesley. All rights reserved15 A-1 Chapter 15 External Methods.
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
CC 215 DATA STRUCTURES LINKED LISTS Dr. Manal Helal - Fall 2014 Lecture 3 AASTMT Engineering and Technology College 1.
LINKED LISTS.
List Structures What is a list? A homogeneous collection of elements with a linear relationship between the elements linear relationship - each element.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part R2. Elementary Data Structures.
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.
Unit – I Lists.
CSCI-255 LinkedList.
More Linking Up with Linked Lists
Lecture - 6 On Data Structures
Stacks and Queues.
CSCE 210 Data Structures and Algorithms
Further Data Structures
Linked Lists.
Problem Understanding
File Organization.
Chapter 9 Linked Lists.
Problem Understanding
Presentation transcript:

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 Example 3: Stable matching problem –Maintain the set of currently free men –Keep track of each person's preferences Quickly find the highest-ranked woman to whom a man has not proposed yet –Quickly find whether a woman is engaged and to whom

2 Data Organization All these examples have a common organizational model: –A sequence of similar items (memory blocks, lines, men/women) –Certain desired operations find, insert, delete

3 The list ADT Data: –A collection of homogeneous elements arranged in a sequence Operations –Insert –Delete –Find –Update –Retrieve –Length

4 The list ADT Most operations refer to a certain position in the list. How will this be designed? –Maintain a "current" position? –Specify an index? –Specify a pointer to an element? –Specify a generalized pointer to an element?

5 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 is good for retrieval if we use an index for element access –Important: The list ADT does not provide random access. We need to shift elements every time we insert or delete We need to reallocate whenever the array fills up.

6 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 node to be deleted. Easy solution: keep in mind the abstract image of a linked list! –Move the next node's contents into the one to be deleted, and then physically remove the next node. –We can use a similar trick for the insert operation –Does this work in all cases?

7 Other list flavors Doubly-linked list –Each node has a pointer to its successor and its predecessor. Faster insert/delete, but more space. Circular list –The last node points back to the head. Sorted list –Items stored in sorted order. –Which implementation provides faster operations? Array or linked memory?

8 Other list flavors XOR list –A space saving list –Instead of both a previous and next pointer, store the XOR of the predecessor and successor. Node B stores &A XOR &C If you are at B and know the address of A, you can compute the address of C. The list can be traversed in any direction, provided you know where you came from. –Interesting, but not very useful...

9 Other list flavors Unrolled linked list –A space saving list –Store k data items in each node It's a list of arrays Reduces cache misses Each node should be at least half-full If a node is too empty after a delete, merge it with a neighbor. If a node overflows after an insert, split it.

10 Other list flavors Satellite list –An easily reversible list –Developed for use in TSP algorithms –Imagine each node as having two "satellites", north and south. A chain of pointers links all the northern satellites and another chain links all the southern ones. –Reversing part of the list requires changing only 4 pointers. Compare this to reversing a doubly-linked list.