Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Lecture 9 Single Linked List Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.

Presentasi serupa


Presentasi berjudul: "Lecture 9 Single Linked List Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1."— Transcript presentasi:

1 Lecture 9 Single Linked List Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1

2 » What is Linked List » Iteration, Inserting, Removing » Implementation » Linked List in C# » Linked List VS List » Performance Comparison with List » When use List, and Linked List » Exercise 2 © Sekolah Tinggi Teknik Surabaya

3 3

4 » A data structure consisting of a group of nodes which together represent a sequence. » Example: » Linked List with Header: 4 © Sekolah Tinggi Teknik Surabaya Next Property Node Class Element Value Property

5 » Store its element in Node Class » Each Node have next reference to hold next element » Linked List Class have header » Last element is Nothing/Null » If header is null then the linked list is empty 5 © Sekolah Tinggi Teknik Surabaya

6 6

7 » Start with header, trace its next » Example: Finding Bacon 7 © Sekolah Tinggi Teknik Surabaya It is Bacon ?

8 » Example: Inserting Cookies After Eggs » Create Node Cookies » Find Node Eggs, get its Next (Bacon) » Set Cookies’s Next to Bacon » Set Eggs’s Next to Cookies 8 © Sekolah Tinggi Teknik Surabaya

9 » Example: Removing Bacon » Find Bacon » Get Bacon’s Previous Node (Cookies) » Get Bacon’s Next Node (Nothing) » Set Cookies’s Next to Nothing 9 © Sekolah Tinggi Teknik Surabaya

10 10

11 » Generic Class » Store Element » Have Link to store its Next 11 © Sekolah Tinggi Teknik Surabaya

12 » Constructor and Property 12 © Sekolah Tinggi Teknik Surabaya

13 » Find and Insert Method 13 © Sekolah Tinggi Teknik Surabaya

14 » Find Previous and Remove Method 14 © Sekolah Tinggi Teknik Surabaya

15 » PrintList Method (Iteration) 15 © Sekolah Tinggi Teknik Surabaya

16 16

17 » A generic collection class System.Collections.Generic.LinkedList » Node Class: LinkedListNode 17 © Sekolah Tinggi Teknik Surabaya

18 18

19 DifferenceListLinked List Storing ElementArray basedNode reference based Access ElementBy its indexFind the node, from header Insertion Method1.Add 2.AddRange 3.Insert 4.InsertRange 1.AddAfter 2.AddBefore 3.AddFirst 4.AddLast Remove1.Remove 2.RemoveAll 3.RemoveAt 4.RemoveRange 1.Remove 2.RemoveFirst 3.RemoveLast Select1.List[index] 2.List.ElementAt 1.Link.Find 2.Link.FindLast 3.Link.ElementAt 19 © Sekolah Tinggi Teknik Surabaya

20 20

21 » Adding, Iterate, Insert, and Deleting 100.000 element » Use Stopwatch Class to measure the time 21 © Sekolah Tinggi Teknik Surabaya

22 22 © Sekolah Tinggi Teknik Surabaya

23 23 © Sekolah Tinggi Teknik Surabaya

24 24 © Sekolah Tinggi Teknik Surabaya

25 25 © Sekolah Tinggi Teknik Surabaya

26 26 © Sekolah Tinggi Teknik Surabaya

27 27 © Sekolah Tinggi Teknik Surabaya

28 28 © Sekolah Tinggi Teknik Surabaya

29 29 © Sekolah Tinggi Teknik Surabaya

30 30

31 » Fast Adding » Fast Iteration 31 © Sekolah Tinggi Teknik Surabaya

32 » Fast Insertion » Fast Deletion 32 © Sekolah Tinggi Teknik Surabaya

33 33

34 Write a program that can read an indefinite number of lines of VB.NET code and store reserved words in one linked list and identifiers and literals in another linked list. When the program has finished reading input, display the contents of each linked list. 34 © Sekolah Tinggi Teknik Surabaya

35 » Andrew Troelsen, Pro C# and The.Net 4.5 Framework (Sixth Edition), Apress, 2012 » Linked List MSDN, http://msdn.microsoft.com/en- us/library/he2s3bh7(v%3Dvs.110).aspx http://msdn.microsoft.com/en- us/library/he2s3bh7(v%3Dvs.110).aspx 35 © Sekolah Tinggi Teknik Surabaya


Download ppt "Lecture 9 Single Linked List Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1."

Presentasi serupa


Iklan oleh Google