Thursday, March 24, 2011

Scope

Today we went over the efficiency of the fibonacci code. Even though it's short, it's really in-efficient since it calls itself a lot with higher inputs (over 2 million for an input of 30!).

We also learned about the scope of a program. Basically it's the perspective of the currently running code, or where your code searches for values. The rest of it pretty much went over my head.
The last thing we learned was that in java, arrays can be modified, but we can't immediately swap the values of two arrays.

P.S. - As we all know, we still have to do this weeks homework(i'm no exeption..) so get on it!!

Fibonacci

In class we learned that when you call the method reduce it changes the value of the array and the count but not the value of the len.

We also learned the fibonacci code and we did test preparation.

In the fibonacci code when using blue jay the computer recalculates the whole sequence to get the next value of the fibonacci code.

They add the first two index's to get the next index then recalculates all the index's to get the next sequence of the set.

Tuesday, March 22, 2011

Recursion and Palindromes

Today was a very confusing day for me in class at first.

Today in class we focused on continuing our lesson with recursion and palindromes. To take a problem and repeatedly reduce it to simpler problems is what is known as recursion.

The example we did in class today was our do now. It dealt with coming up with a recursion to tackle the problem of how many ears x amount of bunnies would have if each bunny has two ears. At first I was confused about this and wondered how I would tackle it. But I remembered that we did a recursion problem on Thursday and looked backed on it. This helped greatly which I encourage everyone to do. Look on pass examples.
Remember these three rules to be golden:
1.Find out how to take just one step.
2.Break each journey down into one step plus a smaller journey.
3.Know when to stop.
When you are learning to walk you must learn how to take your first step. When you set a goal to get somewhere as a child every step u take breaks your journey into a smaller step and less of a distance to cover. And when you reach where you are going you stop. Who wants to hit themselves walking into a table.


Towards the middle of the class we started tackling palindromes.
A man, a plan, a canal, Panama!
Read it backwards and yes its cool. This is what is known as a palindrome.
Our example Mr. Jacoby walked us through was to see how to find a palindrome of a string object. The link to the notes which can be found here shows the problem of seeing how we can find palindrome with the first three letters of the word hello. I found this very confusing and I am still eluded by the coding of this. But in essence what I grasp was a piece of code that checked if the letter was the same spelled forward and backward. For example BOB.
The last thing we tackle in class was the Maze. Or as i call it how can programmers do this because its amazing. A code that works it way through a maze. Although we didn't have a chance to go through it, Mr Jacoby showed us how it worked. The link provided shows us how the object going through the maze checks the first direction north and checks all directions if it can go.
This is the end of my first blog EVER. Hope I did alright and you guys find this informative.


recursion

just trying to blog

Well today was an interesting day because with that snowy rain and thats it 4 the day. this is my 1st time doin this so excuse me 4 messing up with anything.

What we learned in class today was about recursion, but it was at the last 10 minutes of class because all of us were doing the jumper project. From Mr. Jacoby recursion is a strategy for solving problems by
repeatedly reducing them to simpler problems.

For example: factorials
5! = 5 x 4!
4! = 4 x 3!
3! = 3 x 2!
2! = 2 x 1!
So from what i got the lower u go the more u can understand what is the answer.
Also that the repitition of it would eventually end it up being easier to do by that every time it recur it would repeat and then the simplest form and then from there go forwards then u should be able to get your answer.

Recursive problems are broken down into two cases

line 1. The base case: the simplest case where no computation is necessary.
line 2. The recursive case: everything else - brings us to closer to the base case. It simplifies or reduces the problem.

                        public int factorial(int n) {
line 1:                           if (n == 0) return 1;
line 2:                           return n * factorial(n ‐ 1);
                        }


All loops can be written recursively though its not a good idea! 

Tuesday, March 15, 2011

INTERFACES!!!

So today we learned about interfaces. We started off class with the do now, which was to explain how you "drive a car." The people who participated explain more in details what the driver does and not explaining about the kind of car. I really didn't get what he meant by that, but since there's different kind of cars they word differently? O.o
Interfaces is an area between 2 systems, where they interact with each other. This ties in with the do now because to drive a car you need two things, a driver and a car of course. They both work together, sorta,to make the car move.


Benefits of Interfaces
- each system works only on its itself and doesn't care about other systems
- they're all independent so its easier to use and more flexible, whatever that means.
There are certain things that interfaces can and can not do, which is all on the website so I won't bother re-writing it.
check it out!!!!! -----------> http://web.aprchs.net/jacoby/mj2x_2011
Another thing I can sorta explain more on is comparing interfaces.
ComparableInterface
It "marks" classes that are comparable, this means you can decide to sort objects in whichever way you want.
EX.
public int compareTo(T obj)
This is going to compare T to an object but using int O.o yea idk
the way I worte it is -int/<, 0/= and +int/>



ok, well im done now. hopefully I didn't confuse anybody! :)
and there's tutoring 4th & 8th for those who need help! be there or be square xD

Monday, March 14, 2011

computer science 3/14/11

HAPPY PI DAY :D


Today's lesson in APCS was based on the pi day contest that the whole school goes through held by all of our known math teacher's Levy, Jacoby, Reisman, and others.
From our class, Omar managed to memorize 93 digits of pi (for what I dont know -__- lolz).

We also installed Eclipse, which like Blue Jay, is another coding "environment" for java. To install Eclipse, all you have to do is unpack the zip file download in the directory you want. When you unzip the file, it creates a subdirectory called "eclipse", with other subdirectories under that.

We got our tests back today, and you're like me who failed, you shouldn't worry about it to much because Jacoby curved the grade. So, take the grade you got on your test and find the square root of that and times it by 10, and that is your grade. Still failed...well try harder next time. =D
teachers Pictures, Images and Photos

Tuesday, March 8, 2011

Test Review 2 plus some Blogspot fail

Well i started about, um an hours ago, and i was trying to post cause it was my turn. So basically i ended using Fern's account to post what i thought i learned today. -SANTIAGO!!!

Firstly, today was super brief (lucky me) and we were refreshed on how an ArrayList works.
for example in ArrayList named List... Do you know what
List.add(x) means?

Well cause ArrayLists are more "Complex" than regular arrays so they have many different codes that remove and add variables to the Array.

Of wait getting ahead of myself now :)
List.add(x) meant that in the ArrayList of List , x was added/implemented to the end of the list. Although Mr.Jacoby didnt further explain this, to the end of the ArrayList did not mean it would literally go to the "end" but to the next space after a variable, if there was no variable inputted and x was the first, then it would be in the first.

Seems vague but most things are.

We were also refreshed on how to add a variable to an index in the ArrayList the code would be the same, a code demonstration would work out better...

List.add(1,5) <=This implements the second indeces, as we have to start counting by one, with the variable 5.

One thing what we have to keep in mind is that when an index is already being used and you add another variable to that indeces using this code, the remainder is shifted up the ArrayList.
so...
List{5,7,4,1}

List.add(1,3) <=the ArrayList will automatically shift the 7,4,1 up and the new array will be List{5,3,7,4,1}.

I NEED to finish off as I'm scared my blog will, or is taking up the webspace xD.
Extra notes>>>>>>>[ ] brackets means what you're declaring is an array,and ArrayList get larger by copying their current variables into a larger arraylist so the ArrayList space is endless and I'm guessing this wasn't so brief after all...-SANTIAGO

Monday, March 7, 2011

Look at that, test review (And random Tidbits of stuff from Fern :D )

Happy Monday guys (Even though its almost Tuesday, being that its 10pm already)
Well today in class, we really only did test review and some GridWorld code for DancingBug
While going through the DancingBug code, one important thing was brought up (In my opinion) which I would like to bring up again:
ARRAYS ARE NOT EASILY UPDATED IN FOR EACH LOOPS!
(Can be done according to Mr. Jacoby, but is somewhat difficult)

Okay, done with Dancing Bug (Free flowing thought: Does anyone else notice how useless the ay in okay actually is? If its not there, it still sounds the same)

Now on to our test review.

Personally, I believed his test was difficult, but thats what our test reviews are for right?

In class, for our test review, we went over all the questions, but discussed questions 1, 6, 8 and all after (Made me notice how bad I did :p )

Questions 2,3,4,5, and 7 were all discussed "Carousel Style" By our own Julio, Omar, Shakira, and Alfredo (Good Job on getting you respective questions right guys)

The interesting question though, was number 11, which had a bug
It asked what would happen when (arr[i] > 0) instead of when (arr[i] <= 0)
(Or was it (arr[i] <= 0)? See now I don't remember)
We were all given credit though, and those who gave a reason as to why it was buggy/incorrect were given bonus points

To end this blog post, I have two announcements to make, which should be known, since we were already told in class, BUT:
1. To those who want to expand on Omar's blog post about REACH on Saturday, e-mail or speak to Mr. Jacoby
2. Do your CodingBat assignments. Not only do they count as homework, they are a great way to study for our UPCOMING EXAM ON THURSDAY!

Thats all, and a random quote for you guys:

Remember, even a blind squirrel is right twice a day (Still don't know what this means)

Have a good day folks (:







Sunday, March 6, 2011

REACH Session #2

During our second session with Mr.Marques we reviewed Arrays, ArrayLists, Inheritance, Polymorphism, and Recursion.
Everything else is something that you should know from class except for recursion and some polymorphism.

For most examples, the teacher uses Mario Kart to explain object-oriented programming.
You can think of the world as the racetrack and the players as the objects.




When you select your player in the game that player is created and you then play the game.
This is analogous to constructing an object through a client method. Once you created it, you can use it (you can play with it).







All of the players have different cars. Mario has a red car, Peach has a chariot hybrid, Donkey Kong has a car made out of trees etc. They are all still vehicles (an abstract class, there aren't really any vehicles! they must be a car or truck etc)and share the same methods. When you push the accelerate button on your console as Peach, you move forward. The same happens when you're Bowser but you move a lot slower. The vehicle interface may have a go() method that is overridden by classes that implement it since they all act a bit different when they move.
This is called polymorphism. Classes have the same method but use it differently.


This can look something like this:

public interface Vehicle {
void go();
}

public class MariosCar implements Vehicle {
public void go() {
/* goes at 50 mph*/
}
}

public class BowsersCar implements Vehicle {
public void go() {
/* goes at 10 mph*/
}
}

We also learned recursion which is, according to Mr.Marques, the hardest topic in CS.
He gave us an example of writing factorials like this:

public int factorial(int n) {
if (n==1) { return 1; } //this is the base case
else {
return n* factorial(n-1);
}
}

It's a complicated topic but easier if you trace it as you go.

He also gave us practice problems to do at home and sent extra copies for those who missed the session.
The next REACH session is on 4/30, by then you should have reviewed everything and come to him with questions.
Remember to use the barron's review book! he strongly recommends it!

Friday, March 4, 2011

Polymorphism and abstract classes

Thursday's lesson was a bit easy to comprehend. Mr. Jacoby taught us a brief concept of polymorphism and abstract classes. Polymorphism is the ability of the Java virtual machine to determine at runtime which version of a method should be used based on the actual class of the object (instead of the declared type of the variable). In other words, it is the ability of a reference variable to change behavior according to the object instance it is holding. The java virtual machine determines the proper method to call the object. The example we did in class was:

Animal class declares speck: it says "hi".
Dog class extends animal, it overrides speck: it says "woof".
Cow class extends animal, it overrides speck: it says "wassup?".

public void talkToAnimal(Animal a) {
a.speak();

}


a will be an object. The object can be Animal, Dog, or Cow. So if the object is cow, it will therefore call out "wassup?" If the Java virtual machine did not know the object, it wouldn't have done anything.

.....

An abstract class declares fields and abstract methods so that its subclasses can use them, but it represents an abstract idea that can't itself be instantiated. An abstract class need concrete subclasses to implement abstract methods. Concrete subclasses are specific. For example, an abstract class would be Car and a concrete subclass would be Move.


- I tried to explain as best as i could and i hope this helped.


Be sure to do Homework 18 (due Monday): GridWorld pg. 15 # 4 (dancing bug!!)

Reminder: We have REACH tomorrow!!....Note: The GridWorld assignment will be bonus for students who attend REACH.




Wednesday, March 2, 2011

Inheritance and GridWorld Actors

Today we reviewed the basic concepts of inheritance and some of the actors in the GridWorld program.

An inheritance diagram is a lot like a family tree with ParentClasses (SuperClasses) and ChildClasses(SubClasses)
An example is a Car SuperClass with SubClasses RaceCar and Truck which are different types of cars (duh!)
This example is shown here:
The arrow from the SubClass to the SuperClass basically means "is a".
So you would read RaceCar is a Car and Truck is a Car.
You wouldn't say Car is a RaceCar because a Car isn't necessarily always a RaceCar (you're parents don't drive race cars!)
As a kid would from it's parent, the subclasses inherit the characteristics of the superclass (methods). However, if a subclass has a method with the same name as a method in its superclass it overrides the superclass' method completely for that specific subclass.

The actors that we've learned about in GridWorld have been the bug, flower, and rock.
They behave much like they do in real life:
rock- does nothing
flower- becomes darker
bug- moves around (takes a step in the direction of it's antennae unless there is something in the way such as a rock or border in which case it turns 45 degrees to the right)
We also learned about different variations of the bug class such as BoxBug, CircleBug, SpiralBug, and ZBug which is due tomorrow.

If you're having trouble understanding inheritance look inside chapter 3 of your barron's review book, it explains things nicely.