Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PCS4
Feb 2019
1
Overview
Wee Subject Book
k
1 Delegates & Events Nothing
2 RFID Reader & Sorting (Selection § 18.3.1
sort)
3 Recursion & Binary search § 7.15 & §18.2
4 Passing arguments by: § 7.16
value/reference
“ref” & “out” parameters
5 Linked Lists, Stacks, Queues § 19.4
6 Binary trees § 19.7
7 Repetition (Mock exam)
8 Exam
2
Content
• Topics
– Data structures
– Linked lists
– Queues and Stacks
• Learning objectives
– Understanding of data structures
– Can implement a linked list
– You can make use of data structure using FIFO
– You can make use of a data structure using LIFO
3
Repetition week 4
4
Data types and data structures
• A data type is a type of information we can store.
• A data structure is a structure to store/adjust/retrieve this data.
5
Linked lists
• Knows its neighbor
– Next, previous of both
• Precise size of memory
– Grows dynamically
– Shrinks dynamically
• Searching takes longer than normal arrays!
Sixth
Element
6
Types of Linked lists
• Singly
10| 20| 30|
null
next next next
head
• Doubly
head
7
Linked list implementation
• How to program the structure?
• What operations will we be doing on it?
– Get first element
– Get last element
– Get element at
– Add first
– Add last
– Add i’th
– Remove first
– Remove last
– Remove i’th
8
Linked list example
9
Linked list example
10
Queue, First In First Out(FIFO)
• Can only add to the back, and remove/read from the front!
– Enqueue=> (list.Add equivalent to stack)
– Dequeue => (list.Remove)
• Also returns the element!!!
11
Stack, Last In First Out(LIFO)
• Can only add and delete to front of stack!
– Push => (list.Add equivalent of stack)
– Pop => (list.Remove equivalent of stack)
• Also returns the element!!!
Fourth
Fifth
Element
Third
Element
Second
Element
First
Element
12
13