Review for the test
-
Loops
-
Counting forward and backward by one or more
example: Write me a loop that counts from 100 ... 1 by threes
-
for, while and do loops
-
Infinite loops
-
If-Thens
-
Simple if-thens, and if-thens
-
If-thens with elses
-
Complex conditions
write me an if that prints "yes" if the variable 'age' is greater
than 10 or the variable 'name' is Jenny Jones
you should know and, or, and not
you should know <, <=, ==, >=, >, !=, and string.compareTo
-
Remember that string compares do NOT use ==
-
Files
-
If a file is a text file or a binary file.
-
How to open a file.
-
How to read from a file.
-
How to write to a file.
-
What needs to go into the try block.
-
When does the code in the catch block execute.
-
Write me a program that copies a file.
-
Write me a program that counts the number of lines in the file.
-
Write me a program that prints "yes" if the file "fred.txt" exists
-
Write me a program that prints "yes" is the file contains a line
that reads "to be or not to be".
-
Simple array stuff
-
Given an array, put this value in location 0, and push every thing down
one.
-
Remove the value at location 12, and move 13 ... up to fill the spot.
-
Reverse the array (hard)
-
Fill the array with the value '10'.
-
Count the number of 3's in the array
-
Find the biggest/smallest element in the array
-
Sorting
-
How does bubble sort work.
-
How does selection sort work.
-
How does merge sort work.
-
Which is fastest/slowest.
-
Be able to write either bubble or merge sort, or convert from one to the
other.
-
Know how to sort in reverse order
-
Look at the code below. Which kind of sort is it? Will array[0]
be the smallest or the largest element in the array?
-
If it takes 10 seconds to sort a 1000 element list, and 40 seconds to
sort a 2000 element list, could this be a merge sort?
-
Stacks
-
What are the basic operations of a stack?
-
Suppose I push(4), push(12), push(3), pop(), pop(), and push(7). How
many elements are currently on the stack? What will the next pop
give me?
-
Does it take much longer to push a number onto a stack with 1,000,000
elements, or a stack with 10 elements.
-
Look at the code below. Notice the push() function.
Will that actually put a value on the stack, or is the push function broken?
-
Queues
-
What are the basic operations of a queue?
-
Which is a better way to model an assembly line, a queue or a stack?
-
Suppose I put 10 items onto a queue? Which one comes out
first? Last?
-
Know the circular buffer concept, and how modular arithmatic works.
-
Know that normally, the buffer has one empty spot even when full.
-
In the code below, what does the 'head' variable point to?
Where the next item should be inserted
Where the next item should be taken from
One past where the next item to add should be inserted
The first free spot ready for the next insertion