4.6 Data Structures for relations and digraphs

Slides:



Advertisements
Similar presentations
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
Advertisements

1. 1. Database address space 2. Virtual address space 3. Map table 4. Translation table 5. Swizzling and UnSwizzling 6. Pinned Blocks 2.
Graphs CS-240/341. Graphs Used for representing many-to-many relationships –can take two forms directed (digraph) - a finite set of elements called vertices.
Queue using an array. .head.tail Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
3 Data. Software And Data Data Data element – a single, meaningful unit of data. Name Social Security Number Data structure – a set of related data elements.
Graphs Upon completion you will be able to:
Graph Representations And Traversals. Graphs Graph : – Set of Vertices (Nodes) – Set of Edges connecting vertices (u, v) : edge connecting Origin: u Destination:
Data Structures and Algorithm Analysis Dr. Ken Cosh Linked Lists.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Request Dispatching for Cheap Energy Prices in Cloud Data Centers
SpringerLink Training Kit
From Word Embeddings To Document Distances
Virtual Environments and Computer Graphics
D. Phát triển thương hiệu
Evolving Architecture for Beyond the Standard Model
HF NOISE FILTERS PERFORMANCE
Electronics for Pedestrians – Passive Components –
L-Systems and Affine Transformations
CMSC423: Bioinformatic Algorithms, Databases and Tools
Some aspect concerning the LMDZ dynamical core and its use
Current State of Japanese Economy under Negative Interest Rate and Proposed Remedies Naoyuki Yoshino Dean Asian Development Bank Institute Professor Emeritus,
Face Recognition Monday, February 1, 2016.
Solving Rubik's Cube By: Etai Nativ.
Theoretical Results on Neutrinos
Wavelet Coherence & Cross-Wavelet Transform
Hui Wang†*, Canturk Isci‡, Lavanya Subramanian*,
داده کاوی سئوالات نمونه
ლექცია 4 - ფული და ინფლაცია
FLUORECENCE MICROSCOPY SUPERRESOLUTION BLINK MICROSCOPY ON THE BASIS OF ENGINEERED DARK STATES* *Christian Steinhauer, Carsten Forthmann, Jan Vogelsang,
Interpretations of the Derivative Gottfried Wilhelm Leibniz
Advisor: Chiuyuan Chen Student: Shao-Chun Lin
Widow Rockfish Assessment
SiW-ECAL Beam Test 2015 Kick-Off meeting
On Robust Neighbor Discovery in Mobile Wireless Networks
You NEED your book!!! Frequency Distribution
Ch48 Statistics by Chtan FYHSKulai
Factor Based Index of Systemic Stress (FISS)
THE BERRY PHASE OF A BOGOLIUBOV QUASIPARTICLE IN AN ABRIKOSOV VORTEX*
ارائه یک روش حل مبتنی بر استراتژی های تکاملی گروه بندی برای حل مسئله بسته بندی اقلام در ظروف
NV centers in diamond: from quantum coherence to nanoscale MRI
פרויקט מסכם לתואר בוגר במדעים (B.Sc.) במתמטיקה שימושית
Data Structure By Amee Trivedi.
7.2 Labeled trees.
Top 50 Data Structures Interview Questions
CSCI-255 LinkedList.
CS 1114: Implementing Search
CS 367 – Introduction to Data Structures
Operating Systems (CS 340 D)
10.3 Finite State Machines.
Linked list insertion Head. Linked list insertion Head.
Object Oriented Programming COP3330 / CGS5409
Arrays and Linked Lists
Queue and Priority Queue Implementations
Chapter 14: Queue and Priority Queue Implementations
Graphs Chapter 11 Objectives Upon completion you will be able to:
Linked List Insert After
Problem Understanding
Graphs.
Data Structures & Algorithms
Lecture No.02 Data Structures Dr. Sohail Aslam
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
Linked List Functions.
Linked Lists.
Queues and Priority Queue Implementations
Linked List Insert After
Problem Understanding
Presentation transcript:

4.6 Data Structures for relations and digraphs

Data can be stored in a list known as an array Data can be stored in a list known as an array. The locations of an array are consecutively numbered in a computer memory.

Example: Array by the name of A with 5 data items: A [1] Data 1 Index Location A [1] Data 1 A [2] Data 2 A [3] Data 3 A [4] Data 4 A [5] Data 5 With this method, it would be difficult to add an item between D2 and D43. D1 D2 D3 D4 D5

A linked list includes a pointer Data Pointer Index Array Array Location A [1] [2] [3] [4] [5] The pointer tells us what location to go to next. Start at D1 location at A [2]. P[2] points to location [3]. D2 is in location A [3]. D4 4 D1 3 D2 5 D5 D3 1

Location P[3] points to location A[5]. D3 is in location A [5]. When you get to A[4], P[4] contents is 0 which means you are done. We can put the data in any order. We have to go thru the links to access the data we want.

If we have the following digraph: We see that we have 10 edges. We can conclude that we have 10 pairs. R = {(1,2),(1,6),(1,3),(2,1),(2,3),(3,5),(3,4),(3,6),(5,4),(6,1)} 2 2 1 8 5 7 4 3 1 3 5 10 6 9 6 4

An array called VERT for Vertex contains a pointer for every vertex in the digraph. The digraph has 6 verticies, so the VERT array will have 6 locations. The ordered pairs of the digraph will be called TAIL to represent the beginning vertex. The HEAD array will represent the ending vertex. The NEXT array will be a pointer array to get all of the pairs for a given vertex.

TAIL HEAD NEXT [1] [2] [3] [4] VERT [5] [1] [6] [2] [7] [3] [8] [4] [9] [5] [10] [6] 5 8

TAIL HEAD NEXT [1] [2] [3] VERT [4] [1] [5] [2] [6] [3] [7] [4] [8] [5] [9] [6] [10] 2 3 2 1 2 3 5 7 9 5 4 3 4 3 4 6 3 6 6 1 5 1 6 10 8 1 3 1

VERT tells us which location to point to for our pairs. First we go to TAIL location [9]. TAIL [9] = 1 and HEAD [9] = 6. In our NEXT location [9] we point to another relation for vertex 1. We are directed to TAIL[10] where we see the TAIL, HEAD pair of 1,3We are then pointed to NEXT [10] to location [1] where we find TAIL,HEAD pari (1,2). We are done with vertex 1 so, in the NEXT [1] we have a 0 which indicates that we need to go to the next VERT entry, which happens to be 3. So we go to location [3] of TAIL and we fin the TAIL,HEAD pair (2,1)

1st look at vertex position [1] edge (1,6) (1,3) (1,2) 0 done with edges leaving vertex 1 Next look at vertex position [2] edge (2,1) (2,3) 0 done with edges leaving vertex 2 Next look at vertex position [3] edge (3,4) (3,5) (3,6) 0 done with edges leaving vertex 3

Next, look at vertex position [4] It is 0 so done with edges leaving vertex 4. Next look at vertex position [5] edge (5,4) 0 done with edges leaving vertex 5 Last look at vertex 6 edge (6,1) 0 done with edges leaving vertex 6