Potential Test 2 Questions (Part I) As a result of several requests from student
ID: 3576113 • Letter: P
Question
Potential Test 2 Questions (Part I)
As a result of several requests from students after Test 1, we decided to release some of the potential questions for Test 2 earlier than the end of classes. This document contains the potential short-essay and terms for the first three lectures of the second half of the term. Part II of the Study Guide (containing the potential questions and terms for Lectures 9-11) will be released by December 5th.
Short-Essay Questions
- when preparing your answers for these short essay questions, please keep in mind that each question is worth 4 marks which implies that you need to make at least four points. Also, please note that terms like Describe, Discuss, Differentiate mean that we are looking for a sentence or two for each point (not just a list of terms). There will be five (5) short-essay questions from each lecture (or lecture/seminar combination). Two (2) short-essay questions from each lecture (or lecture/seminar combination) will appear on Test 2 (for a total of twelve (12) from Part I and Part II).
Lecture 6 (Omar Alam)
What is procedural programming? How were programs written prior to procedural programming?
What is the difference between compiler errors and run-time errors?
Describe four of the five phases of the Program Development Life Cycle.
Describe four different considerations when choosing a programming language.
What is the difference between source code and object code?
Lecture 7 (Jamie Mitchell)
Describe 4 ways to add a sprite to a Scratch program.
Draw and appropriately label the x,y grid used for positioning on Scratch’s stage, and add a sprite
(your choice) to approximate position (-50,90).
Describe a forever loop in Scratch, give an example of a situation where you might use it, and explain
why you would use a forever loop rather then another looping structure.
What is broadcasting and how is it used in Scratch?
10. Describe four categories of blocks in Scratch, and give an example of a block from each.
Lecture/Seminar 8 (Brian Srivastava/Colin Rous)
11. 12. 13. 14.
15.
Discuss 4 key aspects of desk ergonomics.
Describe 4 good ways to minimize neck pain such as that caused by “Text Neck”?
How does a dyslexic friendly font work?
In class we discussed for 4 primitive operations on an object. Rotation, Scaling, Shear and
translation. Illustrate each operation below using a stick figure.
In class, we discussed that Google changed their logo from a raster to vector font. Explain the
difference between these types of images and discuss some reasons why Google may have made this change. (note: you are not expected to do math on this question). Hint: Both Google and users pay for data.
Terms
- this is the first half of the terms that you will be responsible for on Test 2. These terms have all been discussed in the lectures (or lecture/seminar combination). We will choose twenty-four (24) terms in total (from Part I and Part II) to appear in a matching question on Test 2.
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
debugging Java Fortran COBOL pseudocode compiler flowchart stage
sprite argument block
12. script
13. comments
14. conditional 15. legibility
16. readability
17. discoverability 18. intelligibility 19. audibility
20. regression bug 21. triangle mesh
Explanation / Answer
import java.util.Scanner; /* Class AVLNode */ class AVLNode { AVLNode left, right; int data; int height; /* Constructor */ public AVLNode() { left = null; right = null; data = 0; height = 0; } /* Constructor */ public AVLNode(int n) { left = null; right = null; data = n; height = 0; } } /* Class AVLTree */ class AVLTree { private AVLNode root; /* Constructor */ public AVLTree() { root = null; } /* Function to check if tree is empty */ public boolean isEmpty() { return root == null; } /* Make the tree logically empty */ public void makeEmpty() { root = null; } /* Function to insert data */ public void insert(int data) { root = insert(data, root); } /* Function to get height of node */ private int height(AVLNode t ) { return t == null ? -1 : t.height; } /* Function to max of left/right node */ private int max(int lhs, int rhs) { return lhs > rhs ? lhs : rhs; } /* Function to insert data recursively */ private AVLNode insert(int x, AVLNode t) { if (t == null) t = new AVLNode(x); else if (x t.right.data) t = rotateWithRightChild( t ); else t = doubleWithRightChild( t ); } else ; // Duplicate; do nothing t.height = max( height( t.left ), height( t.right ) ) + 1; return t; } /* Rotate binary tree node with left child */ private AVLNode rotateWithLeftChild(AVLNode k2) { AVLNode k1 = k2.left; k2.left = k1.right; k1.right = k2; k2.height = max( height( k2.left ), height( k2.right ) ) + 1; k1.height = max( height( k1.left ), k2.height ) + 1; return k1; } /* Rotate binary tree node with right child */ private AVLNode rotateWithRightChild(AVLNode k1) { AVLNode k2 = k1.right; k1.right = k2.left; k2.left = k1; k1.height = max( height( k1.left ), height( k1.right ) ) + 1; k2.height = max( height( k2.right ), k1.height ) + 1; return k2; } /** * Double rotate binary tree node: first left child * with its right child; then node k3 with new left child */ private AVLNode doubleWithLeftChild(AVLNode k3) { k3.left = rotateWithRightChild( k3.left ); return rotateWithLeftChild( k3 ); } /** * Double rotate binary tree node: first right child * with its left child; then node k1 with new right child */ private AVLNode doubleWithRightChild(AVLNode k1) { k1.right = rotateWithLeftChild( k1.right ); return rotateWithRightChild( k1 ); } /* Functions to count number of nodes */ public int countNodes() { return countNodes(root); } private int countNodes(AVLNode r) { if (r == null) return 0; else { int l = 1; l += countNodes(r.left); l += countNodes(r.right); return l; } } /* Functions to search for an element */ public boolean search(int val) { return search(root, val); } private boolean search(AVLNode r, int val) { boolean found = false; while ((r != null) && !found) { int rval = r.data; if (val rval) r = r.right; else { found = true; break; } found = search(r, val); } return found; } /* Function for inorder traversal */ public void inorder() { inorder(root); } private void inorder(AVLNode r) { if (r != null) { inorder(r.left); System.out.print(r.data +" "); inorder(r.right); } } /* Function for preorder traversal */ public void preorder() { preorder(root); } private void preorder(AVLNode r) { if (r != null) { System.out.print(r.data +" "); preorder(r.left); preorder(r.right); } } /* Function for postorder traversal */ public void postorder() { postorder(root); } private void postorder(AVLNode r) { if (r != null) { postorder(r.left); postorder(r.right); System.out.print(r.data +" "); } } } /* Class AVL Tree Test */ public class AVLTreeTest { public static void main(String[] args) { Scanner scan = new Scanner(System.in); /* Creating object of AVLTree */ AVLTree avlt = new AVLTree(); System.out.println("AVLTree Tree Test "); char ch; /* Perform tree operations */ do { System.out.println(" AVLTree Operations "); System.out.println("1. insert "); System.out.println("2. search"); System.out.println("3. count nodes"); System.out.println("4. check empty"); System.out.println("5. clear tree"); int choice = scan.nextInt(); switch (choice) { case 1 : System.out.println("Enter integer element to insert"); avlt.insert( scan.nextInt() ); break; case 2 : System.out.println("Enter integer element to search"); System.out.println("Search result : "+ avlt.search( scan.nextInt() )); break; case 3 : System.out.println("Nodes = "+ avlt.countNodes()); break; case 4 : System.out.println("Empty status = "+ avlt.isEmpty()); break; case 5 : System.out.println(" Tree Cleared"); avlt.makeEmpty(); break; default : System.out.println("Wrong Entry "); break; } /* Display tree */ System.out.print(" Post order : "); avlt.postorder(); System.out.print(" Pre order : "); avlt.preorder(); System.out.print(" In order : "); avlt.inorder(); System.out.println(" Do you want to continue (Type y or n) "); ch = scan.next().charAt(0); } while (ch == 'Y'|| ch == 'y'); } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.