data structures and algorithms lab6
TRANSCRIPT
![Page 1: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/1.jpg)
DATA STRUCTURES AND ALGORITHMS
LAB 6
Bianca Tesila
FILS, March 2014
![Page 2: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/2.jpg)
OBJECTIVES
Linked Lists
![Page 3: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/3.jpg)
LINKED LISTS: INTRODUCTION
What is a list? What is a linked list?
![Page 4: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/4.jpg)
LISTS: IMPLEMENTATION
Linked Lists Each node contains the information and the link to its
neighbors (doubly linked lists) or to the next element in the list (singly linked lists )
The nodes are allocated dynamically
Dynamic Arrays The nodes are stocked in arrays If, when adding a new element, the size of the array
is exceeded, the array is reallocated
What are the advantages and disadvantages of each implementation?
![Page 5: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/5.jpg)
LISTS: BASIC OPERATIONS
o Add – adds an element (entity) to the list: at the beginning, at the end or at an arbitrary position
o Remove – removes an element (entity) from the beginning/end of the list or by taking into account its index/content
o Get – retrieves an element by taking into account its index
o Update – updates the information/content of an element
!! These operations depend on the chosen implementation.
![Page 6: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/6.jpg)
LINKED LISTS: TYPES
Singly-linked linear lists
Doubly-linked linear lists
![Page 7: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/7.jpg)
LINKED LISTS: TYPES
Singly-linked circular lists
Doubly-linked circular lists
![Page 8: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/8.jpg)
LINKED LISTS
!!Exercise:
Taking into account the elements of a linked list, store them in two separate linked lists - one for the even elements and another one for the odd elements.
![Page 9: Data structures and algorithms lab6](https://reader038.vdocuments.mx/reader038/viewer/2022100600/555e347fd8b42a63048b4775/html5/thumbnails/9.jpg)
HOMEWORK
Imagine you have a task list. Each task has a priority and a description. You would like to solve these tasks according to their priority.
Whenever you solve a task, you remove it from the list.
Implement an application for managing a task list using a linked list.