BuiltWithNOF
Sample Final

Below I will put the statements I will make in your evaluaion, and below, in red, I will put some sample test questions that will be the source of my adjectives- from evolving, beginning, basic, good, very good, excellent, mastery (and perhaps some variations..)

1. Joe has a good understanding of reading code involving basic control structures and 2 dimensional arrays.

   predict the output for the following code: Put your final correct answer for the output in the box provided:
intA = 5; intB = 1; intC = 8;
while (intB < intC)
{
System.out.println ("yes" + intC);
intB = intB + 1;
if (intA > 3)
{
System.out.println ("more");
while (intA > intB)
{
System.out.println ("do it" + intB);
if (intB < 4)
{
intC = intC - 1;
System.out.println (intC);
if (intA == 5)
{
System.out.println ("done");
}
System.out.println ("finish");
}
intB++;
intA-=1;
}
System.out.println ("stop" + intB);
}
if (intC < 3)
{
System.out.println ("junk");
intC = intC - 1;
}
intC--;
}
 

Predict the output the the following code:

import java.applet.Applet;
import java.awt.*;

public class NestForOut extends Applet
{

int board[][];
int row,col;

public void init()
{
board = new int[3][5];
board[1][0]=9;
for (int x=0; x<3; x++)
for (int y=1; y<4; y++)
{
if (x == y) board[x][y] = x+y;
if (x<y) board[x][y] = y-x;
else (board[x][y] = x-y+2);
}

}


public void paint(Graphics g)
{
for (int r=0; r<3; r++)
{
for (int c=0; c<5; c++)
{
g.drawString(String.valueOf(board[r][c]),c*20,r*20+20);
}
}
}
}

2. Joe has a good ability to read code involving parameter passing by tracing the runtime stack.

Predict the output for the following code:

public class MO
{
static int a = 1;
static int b = 5;
public static void main( String args[] )
{
int a=3; int c=2; int d=4;
System.out.println(a+" "+b+" "+c+" "+d);
a = first(a,b);
b = a + c;
System.out.println(a+" "+b+" "+c+" "+d);
sec(b);
System.out.println(a+" "+b+" "+c+" "+d);
}

static int first(int c, int d)
{
int b = c+1;
System.out.println(a+" "+b+" "+c+" "+d);
sec(b);
System.out.println(a+" "+b+" "+c+" "+d);
c++;
b=7;
System.out.println(a+" "+b+" "+c+" "+d);
return c;
}

static void sec(int c)
{
b = 9;
int d = a;
System.out.println(a+" "+b+" "+c+" "+d);
}
}

3. Joe has a good ability to design and code an algorithm involving nested control structures and arrays

Write a java method, assuming a filled array of integers called scores, that will pass in an integer and return with the highest even number in the list that is within this passed in value of the average.. So,  in you pass in 10 and the average was 50,   you would return with the highest even number between 40 and 60.

4. Joe has a good ability to design and code classes to store and manipulate arrays of hirarchical data in Java.

http://academic.evergreen.edu/curricular/fofc/f3/html/test_prep.html

5. Joe has a good understanding of linked structures and the ability to design and maniputlate dynamic memory structures.

   check the April 29 and May 6 Test Prep links under Sessions

6. Joe has a good understanding of basic Data Structures

   1. Write classes that would allow you to store the linked structure described under the Test Prep- LStruc link for Sessions/May 6

2. Suppose you had a stack called Junk of Strings. Suppose you did the following opperations:

Push(“Ed”) Push (“Sue”) Push(“jim”) Pop Pop Push(“Jill”) Pop Push (“Tom”) Pop

What would the stack look like at the end.. Show top and bottom of the stack

3. Write a push method for Junk, assuming top was an integer pointing to the top element of an array of Strings

4. Suppose you had a queue of integers and did the following opperations:

enq(56) enq(32) deq enq(67) enq(21) deq deq enq(78) enq(36) deq deq

Show the status of the queue after the following opperations, assuming first points to the first of the queue and last points to the end of the queue

5. Show how to make a Binary Search Tree node to hold a linked structure holding name and ages

6. Suppose you entered the following values into a BST
45, 64, 21, 89, 78, 34, 92, 91, 73, 38, 99, 89, 46

7. Show what the BST would look like

8. Show how you could store this in an array

9. Answer the questions on the May 27 Test Prep link

7. Joe has a good ability to read and write recursion

   check the May 13 links for recursion read and write

8. Joe has a good understanding of the analysis of algorithms using Big O

   May 13 Big O link

What is the output for the following code, assuming you call Moves(3)? and output is a Listbox.

public void Moves(int s)
{

   if (s<2) output.addItem("exit"+s);
   else
   {
         Moves(s-2);
         output.addItem("mid "+s);
         Moves(s-1);
         output.addItem("done "+s);
   }
}

 

Write a recursion method to find a dipStick number.  The nth dipstick number is found by adding the previous 3 dipstick numbers together and subtracting 1.  The first 3 dipstick numbers are 1.   The progression goes:  1,1,1,2,3,5,9,16,29...

 

 

 

 

 

 

What is the big O of the following algorithm, assuming s can grow and x can get up to 50000.

       for a = 30000 to s/2
               b=2000
               while b < s*2
                       b = b * 2
                       for c = 1000 to x*2
                               c++;
     for d = 1 to s * 5
             k = 5000
             while k < x
                     k = k * 2                   Big O _________________


On the back of this test, write an O(n*n*log2n) algorithm. Use 2 variables and tell how each can grow.
 

 

[Home] [Syllabus] [Sessions]