Category Archives: Resources
Chapter 6 Review
For review Array and Big-O Review for Chapter 6 Test, question 11 (39)
If we trace the code with num = 20, how many times would the inner loop run?
While Delta < 40 Delta = 2, k = 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 → 10 Delta = 4, k = 2, 6, 10, 14, 18 → 5 Delta = 8, k = 4, 12, 20 → 3 Delta = 16, k = 8 → 1 Delta = 32, k = 16 → 1 10 + 5 + 3 + 1 + 1 = 20
Answer is C: O(n)
Note: you will not get this type of question tomorrow.
Solutions for the previous review:
2. D
3. C
4. B
5. C
6. E
7. C
8. A
9. C
10. B
11. D
Topics:
Arrays – Concepts and applications
ArrayLists
Searches: linear and binary – Concepts and tracing, Big-O, average, best and worse cases.
Sorts: Insertion and Selection – Concepts and tracing, Big-O, average, best and worse cases.
Study Guide:
Self-Review problems, T/F questions, MC questions and SA exercises.
Homework assignment from last Friday
Fun with Lego Mindstorms
This genius machine can fold and fly paper airplanes… using only LEGOs.
Posted by The Verge on Monday, February 8, 2016
One-hundred sixty eigth Day 1314 Lego robots
One-hundred sixty sixth Day 1314 Lego robots
DifferentialPilot
The DifferentialPilot class controls a vehicle that has two driving wheels, each with its own motor. It steers the vehicle by controlling the speed and direction of rotation of its motors. It is one of several Move Controllers that are based on different mechanical designs, but the differential steering design is the simplest.
The pilot object needs to know the wiring diagram of the robot, i.e. which ports the motors are connected to and whether driving the motors forward makes the robot move forward or backward (reverse). It also needs to know the diameter of the wheels and the width of the track, i.e. the distance between the centres of the tracks of the two wheels. DifferentialPilot uses the wheel diameter to calculate the distance it has traveled. It uses the track width to calculate how far it has rotated. Obviously, both parameters must be in the same units, but they can be anything you wish. With proper adjustment of these parameters, errors in distance traveled and angle of rotation can be held do 2% or perhaps less. This information is passed to the pilot constructor. DifferentialPilot is in the lejos.robotics.navigation package. The documentation for this class is here.
New Assignment: Use what you learned to make your robot follow an 8 shape pattern.