James Wei Professor Peck 9/20/2013

Slides:



Advertisements
Similar presentations
Week 14 - Monday.  What did we talk about last time?  Image manipulation  Inheritance.
Advertisements

Recitation 7 James Wei Professor Peck 2/28/2014. Covered in this Recitation LinkedList practice with JUnit testing Submit through ambient.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Compsci 201 Recitation 12 Professor Peck Jimmy Wei 11/15/2013.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
Compsci 201 Recitation 12 Professor Peck Jimmy Wei 4/11/2014.
Chapter 2 Wrap Up 2/18/16 & 2/22/16. Topics Review for Exam I DecimalFormat More Style Conventions Debugging using eclipse The Java API.
Introduction to Computing Systems and Programming Programming.
Week91 APCS-A: Java Problem Solving November 2, 2005.
How to sign up for Goodreads Goodreads is NOT an e-reader! The books are not in this app. Goodreads is a “digital bookshelf.” It stores a list of all the.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
CMSC201 Computer Science I for Majors Lecture 07 – While Loops
Debugging with Eclipse
Java Arrays and ArrayLists COMP T1 #5
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Solving systems of equations
Compsci 201 Midterm 1 Review
Week 13: Searching and Sorting
Day 1 on Google Cloud Platform
Introduction to Python
What to do when a test fails
Foundations of Programming: Arrays
Algebra 7. Solving Quadratic Equations
Testing and Debugging.
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
UNIT 3 – LESSON 5 Creating Functions.
CS1371 Introduction to Computing for Engineers
C ODEBREAKER Class discussion.
Repeating code We could repeat code we need more than once: i = 1 print (i) i += 1 print (i) #… stop when i == 9 But each line means an extra line we might.
Paul Ammann & Jeff Offutt
Week 8 - Programming II Today – more features: Loop control
Manipulating Pictures, Arrays, and Loops part 2
Writing Methods AP Computer Science A.
CompSci 101 Introduction to Computer Science
Comp 110/401 Appendix: Debugging Using Eclipse
Arrays versus ArrayList
Work Experience Year 10.
Paul Ammann & Jeff Offutt
We’re moving on to more recap from other programming languages
Module 4 Loops.
Debugging Taken from notes by Dr. Neil Moore
Building Java Programs
EET 2259 Unit 6 Shift Registers
Building Java Programs
CMSC201 Computer Science I for Majors Lecture 09 – While Loops
Programming We have seen various examples of programming languages
Homework Any Questions?.
Python programming exercise
Debugging Taken from notes by Dr. Neil Moore
Creative Commons Attribution Non-Commercial Share Alike License
Nested If Statements While Loops
Building Java Programs
Tonga Institute of Higher Education IT 141: Information Systems
Building Java Programs
Building Java Programs
Tonga Institute of Higher Education IT 141: Information Systems
Building Java Programs
Making decisions with code
Building Java Programs
Building Java Programs
Chapter 2 Lecture 2-2: The for Loop reading: 2.3
Year 10 Work Experience Programme
6.6 Solve Radical Equations
Review of Previous Lesson
Software Development Techniques
EET 2259 Unit 6 Shift Registers
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

James Wei Professor Peck 9/20/2013 Recitation 4 James Wei Professor Peck 9/20/2013

Covered in this Recitation Help with Jotto: Common APT List manipulation Debugger example (if you didn’t get to it last week) Google form: http://goo.gl/lKCW25

Common APT Go to the course APT page and read the prompt for the Common APT. In Eclipse, write code to solve this APT. Use the tester as always to verify that your solution works. Feel free to work with a friend. Ask the TAs if you have any questions!

Common APT There are many different ways to solve this APT. What are some different solutions for Common? How do these different solutions perform (think Big O)? Possible solutions: Double for loop checking if each letter in word 1 is in word 2 and updating word 2 to replace used letters with asterisks (or some other character) Creating a map storing the number of letters in each word then comparing the maps to see how many are in common

List Manipulation If you haven’t already, snarf the code for Recitation 4. Run the code for “fruit1.txt” and take note of the output and what the code is doing. Try running the code for “fruit2.txt”. Why doesn’t this code work? Consider: What do the words that fail to be removed have in common? How is the iteration index changing with each iteration? Explanation: Removing an item from the list changes the index of all items behind it in the list; specifically, the element after the removed item has its index set to the index of the removed item, so when we increment the index we skip an item.

List Manipulation Let’s fix the code. One way we can do that is by creating a new ArrayList and copying elements over into that new list. Take some time to fix the code in Eclipse by writing a new method called removeFromListGood(). This method should create a new ArrayList, copy over the elements we want to keep from the old list to the new one, then update the old list to be equal to the new list. Consider: How do we make sure we are creating a new list instead of a reference to the existing one? How do we update the old list once we have finished making the new list? Once the students have finished this, it would be good to write the code for removeFromListGood() together.

List Manipulation How else can we fix the broken list remove code? We can try manipulating the index as we loop through the list. Create a new method called removeFromListIndex() that does this. As you code, consider: What is the index at the end of each iteration? What should the index be at the end of each iteration? When should the index be manipulated before the next iteration begins?

Debugger Example If you didn’t get to it last week, snarf the MysteryClass.java code from last week. Using the debugger, figure out what the code is doing. Remember: Set breakpoints by double clicking in the left sidebar (just left of the line numbers if you have those enabled) Step over lines of code to see them executed Step into lines of code containing methods to jump to the code for those methods If you find yourself breaking at weird places, you might be in Java source code—make sure you’re not breaking at exceptions and try using step return to get out of unfamiliar territory

Don’t forget to submit your answers! Have a good weekend! Don’t forget to submit your answers!