Topic_4.1_Lists - Topic 4.1 Linked List Data Structures 1...

Info icon This preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Topic 4.1 Linked List Data Structures
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Data Structures square6 One of the most important aspects of computer programming is the creation of new data types that are appropriate for a particular problem. E.g list, tree, etc. square6 Data Structures are constructs used to represent these new types.
Image of page 2
3 Data Structures square6 A data structure is an aggregation of atomic and composite data types into a set with defined relationships. square6 We create data structure via combination of data types and fit them into a structure such that we can define its relating rules. square6 Data structures can be nested.
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Example of Data structure No association Position association among the elements A heterogeneous combination of data into a single structure with an identified key A homogeneous sequence of data or data types knows as elements Record (Structs) Array
Image of page 4
5 Linked List Data Structures square6 A linked list is a sequence of data types where each elements has a unique successor 1 2 3 4 6 Head 0 (Prev) (Curr)
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 Linked List Data Structures square6 Generalized Linked List square6 Doubly Linked List square6 Circular List Linked List can be used to implement other data structures: square6 FIFO Queue square6 Priority Queue square6 Stack Linked lists can be divided into a variety of categories:
Image of page 6
7 square6 Every node has two components: data and a pointer to another node. square6 Nodes linked together via the pointers Node Data Node pointer Data Node pointer Data Node pointer struct node { void* data; node* next; } typedef node* nodePtr
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
8 General List square6 A generalised list has a variety of methods for storing and retrieving data items square6 Data can be inserted and deleted anywhere square6 There are no restrictions on the operations that can be used to process the list. square6 A generalised list can be either ordered list or random list
Image of page 8
9 General List square6 In an ordered list. The data are arranged according to some key. square6 This key may be part of the data -- videos ordered by title square6 Or it may be constructed from the data square6 A simple (say, integer) key constructed from the data may be included as part of the data
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
10 General List square6 If the list is ordered by some key. Additions and removals can occur anywhere in the list square6 We need a search process to find where such additions or deletions will occur
Image of page 10
11 General List square6 To implement a generalised linked list a variety of functions would be provided eg: square6 AddToHead(); RemoveFromHead(); square6 AddToTail(); RemoveFromTail(); square6 Insert (); IsEmpty(); NumItems(); square6 Remove (); etc.
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
12 Linear List square6 A linear list can be implemented in an array square6 While arrays are easy to create and use, their fixed size makes them inefficient for storing data that needs to be continually inserted and deleted.
Image of page 12
13 Linear List square6 By implementing a linear list with a linked list the container is able to expand and contract as data items are added and deleted.
Image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern