Linked List (extra) Lecturer : Kritawan Siriboon, Room no. 913

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

Data Structures: Doubly Linked List1 Doubly linked list l The linear linked list is accessed from the first node each time we want to insert or delete.
Chapter 3: Abstract Data Types Lists, Stacks Lydia Sinapova, Simpson College Mark Allen Weiss: Data Structures and Algorithm Analysis in Java.
Stacks. What is a stack? Last-in first-out data structure (LIFO) New objects are placed on top Removal restricted to top object Examples?
Stacks.
Lecture 36 CSE 331 Dec 2, Graded HW 8 END of the lecture.
EE 220 (Data Structures and Analysis of Algorithms) Instructor: Saswati Sarkar T.A. Prasanna Chaporkar, Programming.
CENG 213 Data Structures Department of Computer Engineering Middle East Technical University Fall 2014 CENG 213 Data Structures 1.
Lecture 29 CSE 331 Nov 11, To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM.
METU Computer Engineering Department
Sorting Algorithms Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 8 © 2002 Addison Wesley.
Stacks and Queues Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 16 © 2002 Addison Wesley.
Recursion Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 7 © 2002 Addison Wesley.
Linked Lists Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 17 © 2002 Addison Wesley.
Course Introductions.  Introduction to java  Basics of Java  Classes & Objects  Java Collections and APIs  Algorithms and their analysis  Recursion.
Lecture 3 Sorting and Selection. Comparison Sort.
Data Structures By Dr. Mehedi Masud ِAssociate Professor, Computer Science Dept. College of Computers and Information Systems Taif University 1.
AVL Balanced Trees Introduction Data structure AVL tree balance condition AVL node level AVL rotations Choosing the rotation Performing a balanced insertion.
Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan.
Data Structures & Algorithms Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison.
Data Structures & Algorithm Stack Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss,
RecursionRecursion Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison Wesley.
Recursion2Recursion2 Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison Wesley.
Choosing a Dental Plan Student Name
Nasal Cannula X particulate mask
Front End Electronics for SOI Monolithic Pixel Sensor
Theoretical Results on Neutrinos
Wavelet Coherence & Cross-Wavelet Transform
yaSpMV: Yet Another SpMV Framework on GPUs
MOCLA02 Design of a Compact L-­band Transverse Deflecting Cavity with Arbitrary Polarizations for the SACLA Injector Sep. 14th, 2015 H. Maesaka, T. Asaka,
Chapter 6 并发:死锁和饥饿 Operating Systems: Internals and Design Principles
Y V =0 a V =V0 x b b V =0 z
Fairness-oriented Scheduling Support for Multicore Systems
Climate-Energy-Policy Interaction
Factor Based Index of Systemic Stress (FISS)
What is Chemistry? Chemistry is: the study of matter & the changes it undergoes Composition Structure Properties Energy changes.
THE BERRY PHASE OF A BOGOLIUBOV QUASIPARTICLE IN AN ABRIKOSOV VORTEX*
NV centers in diamond: from quantum coherence to nanoscale MRI
The new Estimands concept – an introduction and a worked example
Multidimensional Poverty Measurement
CENG 707 Data Structures and Algorithms
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
The Design and Analysis of Algorithms
CENG 213 Data Structures Nihan Kesim Çiçekli
Binary Search Trees.
Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7.
ECET 370 HELPS Education Your Life-- ecet370helps.com.
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Chapter 17 Linked Lists.
Mark Allen Weiss, Addison Wesley
Chapter 12 Collections.
Tree Lecturers : Boontee Kruatrachue Room no Kritawan Siriboon Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,…
CENG 213 Data Structures Nihan Kesim Çiçekli
Copyright © 2011 Pearson Education, Inc
Chapter 5 Algorithm Analysis.
Lecture 3 Sorting and Selection
Chapter 12 Collections.
Revision of C++.
By Yogesh Neopaney Assistant Professor Department of Computer Science
ICS201 Introduction To Computing II
Introduction: Some Representative Problems
C H A P T E R F I V E Memory Management.
Chapter 5 Linked Lists © 2011 Pearson Addison-Wesley. All rights reserved.
How Memory Leaks Work with Memory Diagram
Chapter 6 Dynamic Programming.
Chapter 2 Reference Types.
Algorithm Efficiency and Sorting
Algorithm Efficiency and Sorting
Chapter 4 Greedy Algorithms.
Copyright © 2011 Pearson Education, Inc
Presentation transcript:

Linked List (extra) Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison Wesley

Linked Array Implementation List : ABCDEFG Create Available List (Stack) node n[8]; int avail = 0; avail = 1 2 3 4 5 6 7 -1 2 3 5 4 -1 6 7 1 avail =

Using avialable node from avail stack. Returning avialable node to avail stack. 2 3 5 4 -1 6 7 1 av= 2 3 6 4 -1 7 1 av= 2 3 5 4 -1 6 7 1 av= 2 3 5 4 -1 6 7 1 av= av= 2 3 5 4 -1 6 7 1 take out another node take out another node return node 2 first take out 1st node

getnode() node n[8]; int avail = 0; int h = getnode(d,nx) old_av = avail = 2 3 5 4 -1 6 7 1 A A -1 -1 int h = getnode(d,nx) h = old_av= avail; avail = n[avail].next ; n[old_av].data = d; n[old_av].next = nx; return old_av; 3 5 4 -1 6 7 1 av= A -1 h = results

insertafter() p h X q insertafter(p,d); int q = getnode(d,n[p].next); C 3 -1 h = A 5 insertafter(p,d); D 7 int q = getnode(d,n[p].next); n[p].next = q; q = av = X 6 p = B 4 1 h= av= p= q= 3 -1 5 7 4 1 -1 C A D X B E E -1 results node n[8];

deleteafter() int i = delteafter(p); results p C 3 q = C 3 h -1 q h = 5 D 7 int i = delteafter(p); av = 6 int q = n[p].next; n[p].next = n[q].next; p = B 3 1 h= av= p= q= 3 -1 5 7 6 3 1 -1 C A D B E E -1 results

Application : Multilists 1. class หนึ่งๆ มีใครลงบ้าง 2. นร. คนหนึ่งๆ ลง class ใดบ้าง C1 C2 C3 C4 s1 s2 s3 s4 s5 1 2 3 0 1 2 3 4 s1 c1 s3 c1 s3 c2 s5 c2 s3 c3 s4 c3 s1 c3 s2 c4 s4 c4

Application : Radix Sort input: 64 8 216 512 27 729 0 1 343 125 0 1 2 3 4 5 6 7 8 9 64 8 216 512 27 729 1 343 125 0 1 2 3 4 5 6 7 8 9 64 8 216 512 27 729 1 343 125 64 8 216 512 27 729 1 343 125 0 1 2 3 4 5 6 7 8 9 output: 0 1 8 27 64 125 216 343 512 729