CS 280 Data Structures Professor John Peterson. Exam 1 Stuff O(Log(n)) + O(n) = ? for (int i = n; i>0; i=i/2) for (int j = 0; j < i; j++) print(j); n*log(n)

Slides:



Advertisements
Similar presentations
Objects and Classes Part II
Advertisements

Unit 8 - Lesson 1 Angles in Triangles
1 Working with References. 2 References Every object variable is a reference to an object Also true when an object is passed as an argument When the object.
E(X 2 ) = Var (X) = E(X 2 ) – [E(X)] 2 E(X) = The Mean and Variance of a Continuous Random Variable In order to calculate the mean or expected value of.
CSE 332: C++ copy control I Copy Control (Part I) Copy control consists of 5 distinct operations –A copy constructor initializes an object by duplicating.
Lists CS 5010 Program Design Paradigms “Bootcamp” Lesson 4.1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAA 1 ©
Defining classes and methods Recitation – 09/(25,26)/2008 CS 180 Department of Computer Science, Purdue University.
CIS 101: Computer Programming and Problem Solving Lecture11 Usman Roshan Department of Computer Science NJIT.
CS 280 Data Structures Professor John Peterson. Project “Tree 1” Questions? Let’s look at my test cases.
CS 280 Data Structures Professor John Peterson. Phase 2 We’re moving on from array-based to link- based structures. You already have experience with links.
CS 280 Data Structures Professor John Peterson. Examples N copies?
CS 280 Data Structures Professor John Peterson. Quiz 4 Recap Consider the following array: {2, 6, 7, 3, 4, 1, 5, 9}. Draw this in tree form and then show.
CS 280 Data Structures Professor John Peterson. Homework #1 Remember: this is due by class Wednesday! Ask questions now or by /wiki
CS 280 Data Structures Professor John Peterson. Example: log(N) This is where things get hairy! How would you compute Log 10 (N) in a very approximate.
CS 280 Data Structures Professor John Peterson. Next Project YET ANOTHER SORT! We’ll do Quicksort using links instead of arrays. Wiki time.
CS 280 Data Structures Professor John Peterson. Log Complexity int j = n; while (j > 0) { System.out.println(j); j = j / 2; /* Integer division! */ }
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
The If/Else Statement, Boolean Flags, and Menus Page 180
Miscellaneous OOP topics Java review continued. Simple data types & wrapper classes Simple data types are the built-in types provided as part of the Java.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 2: Single-Table Selections.
CS 280 Data Structures Professor John Peterson. Grading the Projects Boo-boos: Not allowing bubble sort to exit soon enough Mistakes in the heapify, especially.
CS 280 Data Structures Professor John Peterson. Example 5 null 7 ab Link Data.
CS 206 Introduction to Computer Science II 09 / 19 / 2008 Instructor: Michael Eckmann.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
.NET Data types. Introduction ٭ A "data type" is a class that is primarily used just to hold data. ٭ This is different from most other classes since they're.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
CSE 333 – SECTION 4. Overview Pointers vs. references Const Classes, constructors, new, delete, etc. More operator overloading.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
Chapter 11 Introduction to Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
C++ crash course Class 8 statements, sort, flight times program.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
CS 11 C++ track: lecture 5 Today: Member initialization lists Linked lists friend functions.
The Big Three Based on Weiss “Data Structures and algorithm Analysis CS240 Computer Science II.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes.
Adding Integers. Zero Pair = 0 Why it works… __________ Property says you can add or subtract zero without changing the value of an expression.
Defining Classes II. Today’s topics  Static methods  Static variables  Wrapper classes  References  Class parameters  Copy constructor.
C++ 程序语言设计 Chapter 9: Name Control. Outline  How to control storage and visibility by the static keyword  C++’s namespace feature  C++’s References.
CS 210 DATA STRUCTURES AND ALGORITHIMS Fall 2006.
Questions about 3.9 HW?  P. 167 #1-17all Add and Subtract Rational Expressions Quiz: Friday 3.11 Quiz: April 21 Performance Exam: April.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
CSC 212 – Data Structures Lecture 2: Primitives, References, & Classes.
Objects and Variables Local variables – Confined to single context: allocated on stack – Primitive types such as int or object references – Must be initialized.
CSC 212 – Data Structures Lecture 5: Variables. Problem of the Day Why do underground subway stations always have more escalators going up than down?
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
Week 12 - Monday.  What did we talk about last time?  Defining classes  Class practice  Lab 11.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
Today’s lecture Review chapter 5 go over exercises.
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
CS162 - Topic #6 Lecture: Pointers and Dynamic Memory –Review –Dynamically allocating structures –Combining the notion of classes and pointers –Destructors.
Passing Function Arguments by Reference : A Sample Lesson for CS 1 using the C Programming Language Andy D. Digh Friday, May 29th, 1998.
CS180 Recitation Chapter 7: Defining Your Own Classes II.
Problem of the Day  Why are manhole covers round?
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Lecture 3: Fields, Methods, & Constructors
Professor John Peterson
Defining Classes II.
CS 2308 Exam II Review.
CS 2308 Exam II Review.
CS 2308 Exam II Review.
Java Programming Language
Thursday, May 26, 2016 ESL Level 3 Week 13.
Lec 17 Using Nested Loops and Objects in an Applet Class
Classes and Objects Object Creation
四時讀書樂 (春) ~ 翁森 山光照檻水繞廊,舞雩歸詠春風香。 好鳥枝頭亦朋友,落花水面皆文章。 蹉跎莫遣韶光老,人生唯有讀書好。
SPL – PS3 C++ Classes.
Presentation transcript:

CS 280 Data Structures Professor John Peterson

Exam 1 Stuff O(Log(n)) + O(n) = ? for (int i = n; i>0; i=i/2) for (int j = 0; j < i; j++) print(j); n*log(n) n = 100, t = 10, n = 1000, t = ? 15: Let’s do this now! Know it!!

This Week No project other that #7 from last week Homework is a very short program due Monday since there’s no class Friday Exam will be Monday

Types of Objects Primitive Compare values with == Never need to say “new” (no constructor) Fixed vocabulary Passed by value A “boxed type” is available – implicit coercion x = y copies value No internal structure Default depends on type Ordinary == compares identity, not values Always need to say “new” to make a value Can add user-defined classes Passed by reference x = y creates alias Contains instance vars Default is null

Example 5 null 7 ab Link Data

Example 5 null 7 ab Link Data Link a = new Link () a.data = 5 Link b = new Link () b.data = 7 a.link = b

Example 5 null 7 ab Link Data Evaluate a.link a.data a.link.data b.link a.link.link b.data

Example 5 null 7 ab Link Data What if you do b.link = a b.data = a.data b.link = a.link a.data = b.data

Aliasing Exercises Link a = new Link (); Link b = new Link (); Link c = new Link (); Link d = a; a.data = 2; b.data = 3; c.data = 4; d.data = 5; a.link = b; b.link = c; c.link = a; a.link.data = 6; b.link.link.data = 7; print(d.data);

Avoiding Aliasing One style of programming avoids issues involving aliasing: non-destructive (function) programming. Once you create structure, you never change it. This allows you to ignore the difference between objects and values

Embracing Aliasing If aliasing is present, you need to know that changes are seen by all objects sharing a reference (pointer) to an object. This might be just what you want! You need to be VERY aware of where pointers point.