CSC 212: Programming with Data Structures

Spring 2016

Vocab Study Sheet


  • argument

    Arguments are objects or primitive types that are passed into a method.


  • array

    An array is a set amount of data, which are all of the same type, where the amount of spaced needed for the set amount of data is allocated (reserved or set specifically for that amount, nothing more or less).


  • casting

    Changing the type of a particular Object into either something more specific which is called downcasting, or something more general which is called upcasting.


  • class

    A class is essentially the outline for creating new individual objects that are all the same kind of object. Classes can (and usually do) have fields, constructors, and methods that often do something to those fields (though not always). Essentially, classes are blueprints. Classes can implement interfaces, or extend other classes. This makes them super useful, we also wouldn't get too far without them!


  • client-server model

    The client-server model is a distributed communication framework of network processes among service requestors, clients, and service providers. The client-server connection is established through a network or the Internet.

    Example: checking your bank account via your computer ~ a client program on your computer forwards your request to a server program at the bank.


  • command line and terminal

    Command Line: Command Line arguments are an array entered after the compiled program is called in the terminal. For example:

    
    javac CommandLineDef.java
    java CommandLineDef "this is a command line argument" "so is this"
    
    Terminal: A text-based way to interact with your computer. Lacks the aesthetics and ease-of-use associated with using a GUI, but also adds some functionality.


  • complexity and Big O

    "Big O" notation is used to describe the efficiency (i.e. time complexity) of an algorithm or method. For example, insertion sort, bubble sort, and selection sort are considered O(n2). O(n2) means that the time it takes to sort increases quadratically with the length of the list, n. Methods like "get" for a linked list are O(n), which means that the time it takes to get an element increases linearly with the length of the list. Methods like "push" and "pop" for stacks are O(1) which means they are constant time no matter how many elements are in the stack.


  • constructor

    A method one includes (in the beginning of a class) that specifies the initial values of various fields. A constructor must be called to create an instance of a class. Example:

    
    public ImAConstructor(data){
    
       // this was created at the very top (not pictured),
       // so you shouldn't specify a type here.
       this.imAField = data;
    
       // usually you'll want to specify with this.variable
       this.alsoAField = 5; 
    }
    

  • controller (model-view-controller pattern)

    The controller takes in user interactions and translates them into actions that will be performed by the model. The controller controls the data flow into the model and updates the view when the data changes. It keeps view and model separate.


  • data structure

    A data structure is a specialized format for organizing and storing data. The data structures we have learned are array, linked list, stack and queue. Any data structure is designed to organize data to suit a specific purpose so that it can be accessed and worked with in appropriate ways. In computer programming, a data structure may be selected or designed to store data for the purpose of working on it with various algorithms.


  • exception

    An exception is an object that can be created and thrown. They normally stop the program from running when they are found, but they can also be caught with a try block (catch). The two types of exceptions are compile time exceptions, and mean that there was an issue on the side of the programmer in the code itself. A runtime exception can be due to bugs or due to invalid inputs from users.


  • field

    A variable inside a class, declared outside any method (and usually initialized inside its constructor). When we declare a field we have to say its type, and give it a name. We can add an original value (initializing the field), and say whether the field is static and/or final. We also can specify the access modifier (public, protected, or private). Fields are like global variables within their class.

    Java keywords associated: static, final, public, protected, private


  • final

    - indicates a field is a constant

    - cannot be reassigned or edited once declared

    - public static fields are often final (ex: Color.BLUE)

    - ex: private static final int TEMP = 98

    - is a keyword itself

    - a final method cannot be overridden

    - a final class cannot be extended (have a subclass)


  • generic

    Generics is a way for programmers to re-use code. Using generics allows you to write a class without specifying what type of data you are going to use with it. For instance if you made a generics class Node you could use it in a program where you create a linked list of strings AND a program where you create a linked list of integers. If you did not use generics and wanted to do that you would have to either write two difference node classes (one for integers, and one for strings) or you would have to cast every time you used Node.

    When you write the Node class it is initialized with

    
    public class Node<E> {
       ...
       public Node(E data) {
          ...
       }
       ...
    }
    
    Later when using it in a program you can say
    
    Node<String>
    
    and it will work with strings.


  • inherit, augment, override

    inherit: when you refer to existing methods and fields that have to be present in the superclass.

    augment: adds new methods and fields

    override: overrides methods that have been previously set in the superclass.


  • inheritance

    A child class inherits from a parents class using the word "extends" in Java. The child (or derived class) inherits all the functions and methods from its parent (or superclass). In Java, a class can only have one direct superclass.


  • instance

    -When you use the keyword new for example JFrame frame = new JFrame(); you are creating an instance ("frame") of the class JFrame.

    -"instance" is best understood as it relates to "class" in programming.

    E.g. A "Car" class might dictate that all cars be defined by their make, model, year, and mileage. But you can't provide specifics about a particular car (for example, that 1978 Chevy Impala with 205,000 miles on it that your uncle Mickey drives) until you create an "instance" of a Car. It's the instance that captures the detailed information about one particular Car.)


  • interface

    - a set of public methods that can be implemented by a class

    - does not provide any code to implement methods, but provides the method signatures

    - class that implements interface must provide an implementation for each method defined by the interface

    - can also define public constants. Then, those constants are available to any class that implements the interface.


  • iterator

    An iterator is used to go through and access data in a collection (i.e. LinkedList, ArrayList). It is a generic interface, with three methods: hasNext(), which returns true if there are more elements to iterate; next(), which returns the next element, and remove(), which removes the last element returned by the iterator.


  • Java standard library

    A set of pre-coded objects provided with Java for implementation in programs.


  • Javadocs

    Javadocs are comments that describe classes, fields, constructors, and methods in the code. They begin with /** and end with a */. Javadocs can include various descriptive tags that define various parts of the code (i.e. @author, @param, @version). These comments are written immediately above the classes, fields, constructors, and methods.


  • linked list

    A linear (sequential) collection of data elements, encapsulated in nodes, each referring to the next node by means of pointer. In a doubly-linked list, each element contains pointers to elements immediately before and immediately after it. Elements can be inserted into middle of linked list efficiently by simply adjusting pointers in elements before and after inserted element. However, elements in a linked list can't be retrieved as efficiently as elements in an array. The LinkedList class in Java implements the List interface (and also the Queue interface).


  • method

    A method is a collection of statements that are grouped together to perform an operation. It is usually in the format:

    
    modifier returnType nameOfMethod(Parameter list) {
        // code for method
    }
      
    where:

    modifier - defines access type of method (public/private and static)

    returnType - what the method is meant to return (int/double/String/etc. and void if nothing is meant to be returned)

    nameOfMethod - whatever signature you would like the method to be remembered as

    Parameter list - the different parameters/information necessary to complete the code in the method (optional)


  • model (model-view-controller pattern)

    Model-view-controller is a design used with Graphic User Interfaces. There are three different elements, the model, the view, and the controller. The model is representative of the data and the rules that govern access to that information.


  • object

    Object is a superclass where all other classes can implement the methods of Object. An Object is an instance of the Object class, and has state and behavior.


  • object-oriented

    Object-oriented is an adjective that describes a category of programming languages. Object-oriented programming (OOP) revolves around the concept of an object. In an object-oriented language (OOL), a connection between declarations of data and definitions of functions is established right at the outset, and the program is based on this connection. Java is an example of an OOL.


  • pointer/reference

    Pointers are like index values that reference another value, and are used in arrays, lists and linked lists to refer to their corresponding element's place in memory. In fact, all variables in Java are pointers to their corresponding data in memory (for the purposes of this class we don't need to go into the difference between a reference and a pointer, but officially in Java they are called references). For example, an element plus its pointer is referred to as a node. For the last node in a list, the pointer is "null." Pointers prevent elements from being "lost" as other elements are moved -- a new pointer with the new element should "re-route" and point to the next element in sequence.


  • primitive type

    A primitive types store values (as opposed to objects). They include byte, short, int, long, char, float, double, and boolean.


  • private

    The private keyword is used in the declaration of a method, field, or inner class; private members can only be accessed by other members of their own class (or subclasses).


  • protected

    Protected can be used when specifying a method, field, or inner class. When a method/field/class is protected, it means that it can only be accessed by members of its own class, the class's subclasses, or other classes in the same package.

    Relevant key words: method, field, class.


  • public

    Used when declaring something such as classes, methods, and fields. Opposite of private, it allows other classes to view these items. It is available to classes, packages, subclasses, and the world.

    For example, other classes can access different methods from another class as long as they are public/visible.

    ex:

    
    public class Bike {
    
       public int speed;
    	
       public Bike(int startSpeed){
          this.speed = startSpeed;
       }
    
       public void increaseSpeed(int increase){
          speed += increase;
       }
    }
    


  • queue

    A Queue is a data structure in which elements/data are kept in order. It is a first-in-first-out data structure, which means that the first element added to the queue will be the first one to be removed. In Java, the Queue interface requires six methods to be implemented: add(E e), element(), offer(E e), peek(), poll() and remove().


  • sorting

    Insertion sort: It is an effective and popular sorting method which usually creates a new data structure (usually a linked list) and sorts the elements while adding into the new data structure. Usually, the first element is added to the new data structure, and each element is taken from the original list and added to the new "sorted" list by comparing it with all the elements and placing it in the right position. At the end the new list is sorted.

    Runtime of insertion sort: Insertion sort, in worst case, takes each element in the original list and compares it to every element in the new list. This results in the process being approximately O(n2). It is usually faster than bubble sort.

    Bubble sort: Bubble sort is another popular and relatively simple sorting method that compares two adjacent elements and swaps then if they are out of order. It is required to go through the entire list and compare two adjacent elements n times, n being the number of elements. After n rounds of comparing and swapping the list is sorted in place.

    Runtime of bubble sort: Bubble sort has no best or worst case. Every time it is done, comparing and swapping has to be done to the entire list n times. Thus the process is always O(n2). It is usually slower than insertion sort.


  • stack

    A Stack is a data structure with multiple elements that follows a First In Last Out ("FILO") rule. Common operations include accepting data (push), removing data (pop), and testing if the stack is empty (isEmpty).


  • static

    Static is a modifier that associates a field or a method with the class itself. There can only be one value set for a static field. Static fields are the same for all instances of a class. For static methods, you don't have to create an instance of a class before using a static method on it. Static methods cannot access non-static fields. Static can be used with the final modifier to set a constant.


  • type

    A classification identifying one of various kinds of data, such as double, int or boolean, that determines the possible values for instances of that type. Types can be primitive types or class types. Method signatures must include a return type (or the keyword void if the method does not return anything). Java is "strongly typed", so all variables must have a type declaration.


  • UI/GUI

    GUI is "graphical user interface" and UI is just "user interface." GUI is a subset of UI. UI can include non-graphical interfaces such as screen readers or command line interfaces which aren't considered GUI.


  • user

    The user is the person using a computer system or program. In this course we've developed Graphical User Interfaces (or GUI's) which the user interacts with. We can also develop user exceptions tailored to errors that we anticipate a user to make. For example: if a user enters a wrong input we can throw the following exception:

    
    class Input {
       void method() throws WrongInputException {
          throw new WrongInputException("Wrong input");
       }
    }
    
    User could refer to another programmer building upon our code, or a non-programmer using our code through a GUI or command line interface.


  • variable

    Stores a value that can change as the program executes.

    • Before using a variable, declare its data type and name, and assign a value to initialize it.

    • Assignment statement assigns a value to the variable. Value can a literal value, another variable, or an arithmetic expression.

      • Syntax: How to declare and initialize a variable in one statement:
        
        Type variableName = value;
        
      • Examples:
        
        double unitPrice = 15.99;
        
        int quantity = 0;  
        int maxQuantity = 50;
        quantity = maxQuantity;
        
        int x = 61; 
        int y = 40;
        int result = 61 - 40;
        
    • Occasionally it makes sense to declare and initialize a variable in two separate statements. It is common to see variables declared at the start of the code (such as fields), and not be assigned a value until later in code (often the constructor).

      • Syntax: How to declare (first line) and initialize (second line) a variable in two statements:
        
        Type variableName;
        variableName = value;
        

  • view (model-view-controller pattern)

    The view renders the contents of a model (i.e. the data) in a GUI. It is the part of the program that displays the information to the user, updating its appearance in accordance with changes in the model.


References:
  1. Javadocs and tutorials
  2. Stack Overflow
  3. Wikipedia