1 / 18

Sorted Linked List

Sorted Linked List. A linked list is a data structure that consists of a sequence of data records such that in each record there is a field that contains a reference (i.e., a link) to the next record in the sequence. Course Name: Networking Level(UG/PG): UG

nayef
Download Presentation

Sorted Linked List

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sorted Linked List A linked list is a data structure that consists of a sequence of data records such that in each record there is a field that contains a reference (i.e., a link) to the next record in the sequence. • Course Name: Networking Level(UG/PG): UG • Author(s) : Phani Swathi Chitta • Mentor: Aruna Adil *The contents in this ppt are licensed under Creative Commons Attribution-NonCommercial-ShareAlike 2.5 India license

  2. Learning Objectives After interacting with this Learning Object, the learner will be able to: • Explain the concept of sorted linked list

  3. Definitions of the components/Keywords: 1 • Glossary: • Node: Node contains a value and reference to next node • Reference: Reference is address of next node in the linked list • Null Pointer: Reference with no address • Head: Starting node of linked list • TEMP node: Node with no address 2 3 4 5

  4. Definitions of the components/Keywords: 1 In Computer Science, a linked list is a data structure that consists of a sequence of data records such that in each record there is a field that contains a reference (i.e., a link) to the next record in the sequence. Linked Lists are among the simplest and most common data structures. They provide an easy implementation for several important abstract data structures including stacks, queues, hash table, symbolic expressions and skip lists. The principle benefit of a linked list over a conventional array is that the order of the linked items may be different from the order in which the data items are stored in memory or on disk. For that reason, linked lists allow insertion and removal of nodes at any point in the list, with a constant number of operations. 2 3 4 5

  5. Master Layout 1 1 Sorted Linked list: 2 Fig. B Fig. A 3 • Give a PLAY button • Give PAUSE and RESTART/CLEAR buttons • Give the color details as given below 4 5

  6. Step 1: 1 Sequence: 15, 50, 40, 10, 60, 35 2 3 4 5

  7. Step 2: 1 2 3 4 5

  8. Step 3: 1 2 3 4 5

  9. Step 4: 1 2 3 4 5

  10. Step 5: 1 2 3 4 5

  11. Step 6: 1 2 3 4 5

  12. Electrical Engineering Slide 1 Slide 3 Slide 13-17 Slide 18 Introduction Definitions Analogy Test your understanding (questionnaire)‏ Lets Sum up (summary)‏ Want to know more… (Further Reading)‏ Interactivity: Try it yourself • The same algorithm as in demo is followed • When ADD is selected, add the values given by user and fill the sorted linked list. • When REMOVE is selected, remove the particular number from the list as given by user • When SEARCH is selected, find out the corresponding number in the list • Give a text box to enter node value • Give limit that only 7 nodes can be added • Give ADD, REMOVE and SEARCH buttons 12 Credits

  13. Questionnaire 1 1. In the sorted linked list with n elements, how many shift operations are required for deleting the first element? Answers: a) n b) 0 c) n-1 d) n/2 2 3 4 5

  14. Questionnaire 1 2. Suppose getFront is called on a sorted linked list that has exactly two entries with equal priority. How is the return value of getFront selected? Answers: a) The one is chosen at random b) The one which was inserted first c) The one which was inserted most recently d) This can never happen (violates the precondition) 2 3 4 5

  15. Questionnaire 1 3. An array of Linked List can be used to implement a Sorted Linked List, with each possible priority corresponding to its own element in the array. When is this implementation not feasible? A. When the number of possible priorities is huge B. When the number of possible priorities is small Answers: a) Both A & B b) Only A c) Only B d) None 2 3 4 5

  16. Questionnaire 1 4. Suppose temp points to a node in a Linked List, what Boolean expression will be true when cursor points to the tail node of the list? Answers: a)cursor==null b)cursor->next==null c) cursor->next==null 2 3 4 5

  17. Questionnaire 1 5. Suppose that TEMP is a pointer variable that contains the NULL pointer. What happens if your program tries to read or write *TEMP? Answers: A syntax error always occurs at compilation time b) A run-time error always occurs when *TEMP is evaluated c) A run-time error always occurs when the program finishes d) The results are unpredictable 2 3 4 5

  18. Links for further reading Reference websites: http://en.wikipedia.org/wiki/Linked_list Books:

More Related