ITEC 320 Lecture 12 Higher level usage of pointers.

Slides:



Advertisements
Similar presentations
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Advertisements

Graphs COP Graphs  Train Lines Gainesville OcalaDeltona Daytona Melbourne Lakeland Tampa Orlando.
Recursion CS 367 – Introduction to Data Structures.
Analysis of programs with pointers. Simple example What are the dependences in this program? Problem: just looking at variable names will not give you.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
CSE 373: Data Structures and Algorithms Lecture 19: Graphs III 1.
Data Structure and Algorithms (BCS 1223) GRAPH. Introduction of Graph A graph G consists of two things: 1.A set V of elements called nodes(or points or.
Graphs By JJ Shepherd. Introduction Graphs are simply trees with looser restrictions – You can have cycles Historically hard to deal with in computers.
Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.
1 Networking through Linux Partha Sarathi Dasgupta MIS Group Indian Institute of Management Calcutta.
Connecting with Computer Science, 2e
Tirgul 9 Amortized analysis Graph representation.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
1 1 Lecture 4 Structure – Array, Records and Alignment Memory- How to allocate memory to speed up operation Structure – Array, Records and Alignment Memory-
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
Design Patterns for Efficient Graph Algorithms in MapReduce Jimmy Lin and Michael Schatz University of Maryland MLG, January, 2014 Jaehwan Lee.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Geography and CS Philip Chan. How do I get there? Navigation Which web sites can give you turn-by-turn directions?
Computer Science 112 Fundamentals of Programming II Introduction to Graphs.
Threads, Thread management & Resource Management.
WAES 3308 Numerical Methods for AI
Connecting with Computer Science, 2e Chapter 8 Data Structures.
Representing and Using Graphs
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
Review Introduction to Searching External and Internal Searching Types of Searching Linear or sequential search Binary Search Algorithms for Linear Search.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Group 3 Sandeep Chinni Arif Khan Venkat Rajiv. Delay Tolerant Networks Path from source to destination is not present at any single point in time. Combining.
Buffers Let’s go for a swim. Buffers A buffer is simply a collection of bytes A buffer is simply a collection of bytes – a char[] if you will. Any information.
Overview of Course Java Review 1. This Course Covers, using Java Abstract data types Design, what you want them to do (OOD) Techniques, used in implementation.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
ITEC 320 Lecture 19 Higher level usage of pointers.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
CS 206 Introduction to Computer Science II 11 / 16 / 2009 Instructor: Michael Eckmann.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Author: Haoyu Song, Murali Kodialam, Fang Hao and T.V. Lakshman Publisher/Conf. : IEEE International Conference on Network Protocols (ICNP), 2009 Speaker:
Source: CSE 214 – Computer Science II Graphs.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Data Structures and Algorithms Lists, Stacks, Queues, and Graphs Sorting and searching algorithms.
ITEC 352 Lecture 16 ISA(7). Review Exam / Questions? Conditional codes, how important are they? How important are comments in assembly? What are the benefits.
CSC 143 P 1 CSC 143 Recursion [Chapter 5]. CSC 143 P 2 Recursion  A recursive definition is one which is defined in terms of itself  Example:  Compound.
File-System Management
CSE 214 – Computer Science II Maps
May 3rd – Hashing & Graphs
FileSystems.
Page Replacement.
Lesson Objectives Aims
Graphs Chapter 11 Objectives Upon completion you will be able to:
Graphs.
CSE 373: Data Structures and Algorithms
Chapter 40 Remote Method Invocation
Tree Searching.
CSE 373 Data Structures Lecture 16
Chapter 46 Remote Method Invocation
CSE 373: Data Structures and Algorithms
Chapter 46 Remote Method Invocation
Algorithms Lecture # 29 Dr. Sohail Aslam.
Depth-First Search CSE 2011 Winter April 2019.
Brad Karp UCL Computer Science
Tree Searching.
Tree Searching.
Tree Searching.
Virtual Memory.
Presentation transcript:

ITEC 320 Lecture 12 Higher level usage of pointers

Pointers Review Linked list –Pointer usage –Package design

Pointers Problems What are the major problems with pointers?

Pointers Reference counting Each object has to be uniquely tracked in a system The number of pointers to that object is also counted Whenever a pointer is disposed, the reference count is decreased What happens when it reaches 0? What problem does this resolve?

Pointers Smart pointers Contain regular pointers Also contain number of other pointers that are pointing to the object Or do they… –What if an object contains the number of pointers to itself? –Benefits / downsides Designs for this

Pointers Factories In your words, what are they?

Pointers Approache s Function that returns an object Function that takes an object and returns a pointer Function that takes an id and returns a pointer to it Hash map for memory addresses and # of accesses Others?

Pointers Advantages/ Disadvantage s Why use factories? What do they mean for your code? Benefits Downsides

Pointers Flyweight What does the word bring to mind? One object / pointer reused lots and lots of times Similar to NULL except it is a type / pointer What reasons do you think you would use a flyweight object? Benefits / Downsides

Pointers Disk buffer How many GB does a DVD hold? 3 DVD game How does that game load everything into RAM? Or does it load everything into RAM? Memory Mapping to HD idea

Pointers How it works Several blocks of data reserved in memory Each block maps to a unique block on a HD Data is requested, it is loaded from HD –If it is in list, use it, move to MRU position –If it isn’t, load into least recently used block and move it to the MRU position –Linked list of blocks?

Pointers What it enables

Pointers Design patterns Not language specific features Encompasses a particular idea May or may not be heavily supported in a language –Java supports smart pointers by default –C++ requires a separate class Not a silver bullet

Pointers Command pattern Signals when an action needs to be performed Command Central Command Central Contains pointers to objects Contains list of commands Told to execute X, it actually does it

Pointers Cell phones How do they work (communication side)

Pointers Cell Networks

Pointers Other scenarios Computer networks Google maps Facebook friends Gaming

Pointers Rationale How do you model a cell phone network on a computer? Why would you want to simulate a cell phone network?

Pointers Graphs Composed of vertices and edges Vertices –Represent an object in a graph Edges –A connection between two vertices

Pointers Variations Weighted graph –Toll road –Hotel cost –Identifiers Possible usage scenarios?

Pointers Methods of implementation Arrays Pointers Benefits of each approach Downsides of each approach

Pointers Code Should we use a package? What about generics?

Pointers Searching How do you find information in a graph? Destination Start

Pointers Breadth first For each node I am connected to –Is this the node I’m looking for? If I didn’t find it –For each node I am connected to Call breadth first search on it

Pointers Depth first If I am the node searched for, stop and return For each node I am connected to –Call depth first search on that node

Pointers Issues What are some of the issues that might happen with searching? How do you implement each way? –Stacks / Recursion / Packages / ?

Pointers More How do you pick the best path? –Lowest cost –Highest cost –Cover all points with least overlap

Pointers Summary Rationale for graph theory Approach Finding algorithms

Pointers Summary Memory usage at a higher level