Lesson Objectives Aims – Know about…

Slides:



Advertisements
Similar presentations
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Advertisements

Important Problem Types and Fundamental Data Structures
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Chapter 8: Data Abstractions Senem Kumova Metin. 8-2 Chapter 8: Data Abstractions 8.1 Basic Data Structures – Arrays – Lists, Stacks, Queues – Trees 8.2.
ECE 103 Engineering Programming Chapter 61 Abstract Data Types Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
Priority Queues and Binary Heaps Chapter Trees Some animals are more equal than others A queue is a FIFO data structure the first element.
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
Data Structures Types of Data Structure Data Structure Operations Examples Choosing Data Structures Data Structures in Alice.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
CMSC 202, Version 5/02 1 Trees. CMSC 202, Version 5/02 2 Tree Basics 1.A tree is a set of nodes. 2.A tree may be empty (i.e., contain no nodes). 3.If.
Data Structure and Algorithms
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Introduction toData structures and Algorithms
CSE373: Data Structures & Algorithms Priority Queues
Review Array Array Elements Accessing array elements
ADT description Implementations
Data Structure By Amee Trivedi.
Planning & System installation
Chapter 12 – Data Structures
Top 50 Data Structures Interview Questions
Sorted Linked List Same objective as a linked list, but it should be sorted Sorting can be custom according to the type of nodes Offers speedups over non-sorted.
Data Structure Interview Question and Answers
12 C Data Structures.
Data Structures Binary Trees 1.
Chapter 15 Lists Objectives
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Problems with Linked List (as we’ve seen so far…)
Cinda Heeren / Geoffrey Tien
Week 15 – Monday CS221.
Lecture 22 Binary Search Trees Chapter 10 of textbook
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Hashing Exercises.
Chapter 8: Data Abstractions
Chapter 17 Object-Oriented Data Structures
Binary Trees.
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
structures and their relationships." - Linus Torvalds
Chapter 1.
Arrays and Linked Lists
i206: Lecture 14: Heaps, Graphs intro.
Lesson Objectives Aims
Teach A level Computing: Algorithms and Data Structures
A Kind of Binary Tree Usually Stored in an Array
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Introduction to Data Structures
Lesson 6. Types Equality and Identity. Collections.
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Heaps Chapter 11 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates.
Trees CMSC 202, Version 5/02.
A Robust Data Structure
Searching CLRS, Sections 9.1 – 9.3.
CMSC 202 Trees.
Heaps Chapter 11 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates.
Introduction to Data Structures
Introduction to Data Structure
How to use hash tables to solve olympiad problems
DATA STRUCTURE.
EE 312 Final Exam Review.
Important Problem Types and Fundamental Data Structures
Hash Maps: The point of a hash map is to FIND DATA QUICKLY.
Indexing, Access and Database System Architecture
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
structures and their relationships." - Linus Torvalds
Presentation transcript:

Lesson Objectives Aims – Know about… Arrays (of up to 3 dimensions), records, lists, tuples. (b) The following structures to store data: linked-list, graph (directed and undirected), stack, queue, tree, binary search tree, hash table. (c) How to create, traverse, add data to and remove data from the data structures mentioned above. (NB this can be either using arrays and procedural programming or an object-oriented approach).

Data must be stored in any program for it to do something useful Data structures Data must be stored in any program for it to do something useful Selection of correct data type is essential, but correct data structure is equally important There are two types: Static Dynamic

Static data structures Size is pre-determined and set, it cannot be changed in the program Limited in how useful they can be due to inflexibility and a need to know exact requirements before the program runs This can be seen as part of how “strongly typed” a language is

Strong typing A strongly typed language will expect all data types to be explicitly defined This can extend to: Stating the size of an array The size of strings (pascal… why?!) However, this can be a good thing as such code can be considered almost completely “safe” as it is totally predictable and cannot “outgrow” the system limitations Compilers should catch most typing/casting errors before the code can even run.

Dynamic structures Dynamic data structures allow storage to grow and shrink as necessary This is obviously preferable – you don’t need to know the exact requirements at compile time Dynamic structures will have slightly different overheads and requirements to static structures and may also make use of static structures as the “building blocks” of their structure!

Array – 1d A basic table Dim colours(4) as string Each element has an index Set: colours(2) = “red” Get: console.writeline(colours(2)) 1 2 3 4 green Blue red Purple orange

Array – 2d A table… Dim SalesFigures(12,3) as decimal (row,column) Set: SalesFigures(11,2) = “32000” 1 2 3 …. 11 32000 12

Array – 3d A set of tables… Dim SalesFigures(3,12,3) as decimal (table,row,column) Set: SalesFigures(3,2,5) = “32000”

1D Array 2D Array 3D Array

Probably… In the exam, indexes would be 1D - (index – row) 2D - (column, row) 3D - (table, column, row) VB is special…

Records A custom data structure which allows data of different types to be stored and accessed through a common name Person.name = “dave” Person.weight = 85 VB calls this a “structure” – it’s the same thing

Tuples Like a record but cannot be changed Can contain data of varying types Can be referenced by index as an array, but is NOT an array – an array is one data type only.

Depends on the language…! Lists Depends on the language…! IF they are static then they work like arrays but allow different types of data to be stored IF they are dynamic, then… No fixed size May have a set data type… may not!

Dynamic data structure Each piece of data is a “node” in the list Linked list Dynamic data structure Each piece of data is a “node” in the list Each node contains a pointer to either: The next element Null The list requires a starting pointer

Linked lists Diagram time… Adding Removing Inserting…?

In VB… Dim myList as new list(of string) Can be anything – list of objects even. Mylist.add(item) Mylist.remove(item)

Queues First in First Out data structure Can grow and shrink dynamically Will require a pointer to the “head” and “tail” Often implemented as a linked list!

In vb… Dim myQ As New Queue() myQ.Enqueue("Hello")’stores at the tail Var = myQ.Dequeue()’gets from head of the queue

I’m bored now You lot have done very little recently. Task 1: make notes on and be ready to explain: Hash tables Stacks Binary Trees Graphs You will need code examples in VB too. I will add YOUR notes to this presentation

Then… Get the programming tasks from the shared area Do them I DO expect this handed in, it WILL affect my judgement of your suitability to continue next year. Really. Code in. Everyone.

Uses a hashing algorithm to: Hash Tables Uses a hashing algorithm to: Generate a unique value for given data This value links to an index in the hash table This means data can be stored anywhere (basically) in the table, but… Can be found VERY quickly because a hashing algorithm will produce the same output for a given input.

Collisions In small data sets there is more likelihood of collisions Collisions are dealt with by creating a linked list (or other suitable data structure) at each entry in the table where there is more than one piece of data to be stored

stacks FILO – First in, Last Out Adding data: Remove Data: Stack must not be full Otherwise stack overflow New item added to the top of the stack (Push) Stack pointer increased by 1 Remove Data: POP operation Stack pointer Decreased

Uses of Stacks: Backtracking (undo) Reversing data Storing states (CPU, Interrupts etc)

Nodes can be named (parent, child, root, leaf) Storing data: Binary tree Made up of nodes (data) Nodes can be named (parent, child, root, leaf) Storing data: Left usually smaller Right usually larger Searching: Starts at root node Complexity logn

Adding nodes Given this tree… Add the breed “poodle”

Method Start at root node – Poodle > Harrier Go down to the next node Poodle < Rottweiler so go LEFT Next node – Poodle < Pug so go LEFT and add the node to the LEFT underneath PUG

Poodle

Finding a node Same method as before – find “Whippet” Start at root, Whippet > Harrier so go RIGHT Whippet > Rottweiler so go RIGHT Node = Whippet = found.

Graphs A structure consisting of Vertices and Edges (nodes and connections) Connections can be directional Nodes (vertices) can have multiple connections to other nodes Used to model real world network like structures such as roads, computer networks, railways etc. Often used to calculate distances/times and so on – Logistical operations!

Review/Success Criteria