CSE 2231 Midterm 1 Stuff

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/61

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

62 Terms

1
New cards

Mathematical Type

Every program type in a program has this, ex: integer, real

2
New cards

Precondition

Otherwise known as the requires clause, it characterizes the responsibility of the program that calls (uses) that method. In other word, it’s the responsibility of the client using the code.

3
New cards

Postcondition

Otherwise known as the ensures clause, it characterizes the responsibility of the program that implements that method. In other words, it’s the responsibility of the implementer making the program.

4
New cards

Universal Quantification

Used when you want to say something is true for every combination of values that satisfy a certain property.

Example:
for all quantified-variables
where (restriction-assertion)
(main-assertion)

5
New cards

Existential Quantification

Used when you want to say something is true for some combination of values

Example:
there exists quantified-variables
(assetrion)

6
New cards

Object Class

A special built in class that provides default implementations for the following instance methods:
boolean equals(Object obj)
int hashCode()
String toString()

7
New cards

Abstract Class

A kind of “partial” or incomplete class that contains bodies for some but (typically) not all of the methods of the interfaces it claims to implement

8
New cards

Convenience Methods

Methods implemented in JUnit Kernel testing that are meant to help you create test cases or handle other busy work

9
New cards

Version Control

In team projects, software engineers:
- Share and extend a common code base
- Work concurrently with each other

Best practice is for a team to use a … system

10
New cards

Central Repository

Keeps all files and a history of all modifications to them
- A new team member can check out their own private copy from the …
- Each member can update their own copy to reflect the changes in the …
- Each member can commit changes from their own private copy to the …

11
New cards

Implementing a Kernel

Two major questions to address:
1. What data representation (data structure) should be used to represent a value of the new type being implemented?
2. What algorithms should be used to manipulate that data representation to implement the contracts of the kernel methods?

12
New cards

Two-Level Thinking

Restrict your attention to exactly two adjacent levels in the tower:
- One is the level for which you ae implementing a new kernel class
- The other is the level directly below the level for the new kernel class you are creating

13
New cards

Client View (Kernel)

Can see the mathematical model and method contracts

14
New cards

Implementer View (Kernel)

Can see the data representation and algorithms

15
New cards

Abstract State Space

The set of all possible math model values as seen by a client

16
New cards

Concrete State Space

The set of all possible math model values of the data representation

17
New cards

One Step Thinking

Restrict your attention to the states just before and just after a method call

18
New cards

Commutative Diagram

Shows the relationships between the concrete state space and the abstract state space before and after the method calls

19
New cards

Abstract Transition

For each state before the call, where it might end up according to the method’s contract.

20
New cards

Concrete Transition

For each state before the call, where it might end up according to the method’s body

21
New cards

Representation Invariant

Which “configurations” of values of the instance variables can ever arise?

Characterizes the values that the data representation (instance variables) might have at the end of each kernel method body, including the constructor(s)

Made to hold by the method bodies’ code, and it is recorded in the convention clause in a javadoc comment for the kernel class

22
New cards

Abstraction Function

How are the values of the instance variables to be interpreted to get an abstract value?

Describes how to interpret any concrete value (that satisfies the representation invariant) as an abstract value

Not computed by any code, but is merely recorded in the correspondence clause in a javadoc comment for the kernel class

23
New cards

Kernel Purity Rule

No constructor or method body in the kernel class should call any public method from the same component family

24
New cards

Linear Search

The algorithm that examines - potentially - every item in a collection until it finds what it is looking for

25
New cards

Constant Time

Runtime does not change with input size

26
New cards

Log Time

Runtime grows very slowly as input size grows

27
New cards

Linear Time

Runtime grows directly with input size

28
New cards

n Log n Time

runtime slightly worse than linear; divide and conquer style

29
New cards

Quadratic Time

Runtime grows with the square of the input size

30
New cards

Exponential Time

Runtime doubles with each extra input element

31
New cards

Hashing Thought

Instead of searching through all of the items, store the items in many smaller buckets and search through only one bucket that:
1. Can be quickly identified
2. Must contain the item you’re looking for

32
New cards

Hashing Identification

Suppose you need to search through n items of type T, and you decide to organize the items into m buckets

Given x of type T, compute from it some integer value h(x)

Look in bucket number h(x) mod m

33
New cards

Hashing Procedure

  1. Create hashTable by declaring something like a set of arrays

  2. Get the hashCode value of a certain integer in given data set

  3. Take that hashCode value and mod it by the hashTable size

    1. Put the value in that bucket

34
New cards

Binary Tree

Can be thought of as a structure containing zero or more nodes, each with a label of some mathematical type, say T, called the label type

Is either:
- an empty tree which has no nodes at all
- a non empty tree, which has a root node and two subtrees of the root

35
New cards

Size

The total number of nodes in a tree (binary tree)

36
New cards

Height

The number of nodes on the longest path from the root to an empty subtree of t

37
New cards

Labels

The set whose elements are labels of a tree (binary tree)

38
New cards

Binary Tree Assemble

assembles in this a binary tree with root label root and subtrees left and right

39
New cards

Binary Tree Disassemble

Disassembles this into its root label, which is returned as the value of the function, and subtrees left and right

40
New cards

Pre-order

Root is visited before left and right

41
New cards

In-Order

Root is visited between left and right

42
New cards

Post-Order

Root is visited after left and right

43
New cards

Binary Tree ReplaceRoot

Replaces the root of this with x and returns the old root

44
New cards

Binary Search Tree

A common arrangement of labels, which supports searching that is much faster than linear search

45
New cards

Total Preorder

A binary relation on T that is total, reflexive and transitive

46
New cards

Binary Relation

May be viewed as a set of ordered pairs of T, or as a boolean valued function R of two parameters of type T that is true iff that pair is in the set

47
New cards

Total Relation

The binary relation R is … whenever:
for all x, y: T
(R(x, y) or R(y, x))

48
New cards

Reflexive Relation

The binary relation R is … whenever:
for all x: T (R(x, x))

49
New cards

Transitive Relation

The binary relation R is … whenever:
for all x, y, z: T
(if R(x, y) and R(y, z) then R(x, z))

50
New cards

Binary Search Tree Arrangement

A binary tree is a BST whenever the arrangement of node labels satisfies these two properties:
1. For every node in the tree, if its label is x and if y is that node’s left subtree, then y < x

  1. For every node in the tree, if its label is x and if y is that node’s right subtree, then y > x

51
New cards

SortingMachine

Component family that allows you to add elements of type T to a collection of such elements, and then to remove them one at a time in sorted order according to a client-supplied ordering

52
New cards

SortingMachine Mathematical Model

An ordered triple (or a three tuple of a boolean, a binary relation on T, and a finite multiset of T)

SORTING_MACHINE_MODEL is {
insertion_mode: boolean,
ordering: binary relation on T,
contents: finite multiset of T

53
New cards

Finite Multiset

Essentially a finite set with multiple copies of elements allowed, so there are effectively “counts” of all values of the element type T

54
New cards

SortingMachine Add

Adds x to the contents of this

55
New cards

SortingMachine changeToExtractionMode

Changes the mode of this from insertion to extraction

56
New cards

SortingMachine removeFirst

Removes and returns some “first” (smallest) element from this

57
New cards

SortingMachine isInInsertionMode

Reports whether this is in insertion mode

58
New cards

SortingMachine order

Reports Comparator<T> being used for sorting of this

59
New cards

SortingMachine size

Reports the number of elements in this.contents

60
New cards

Insertion Sort

Sorting algorithm where it divides the array into two parts: a sorted portion and unsorted portion. It then takes the first element from the unsorted portion and inserts it into the correct spot in the sorted portion, and does this until it’s all sorted (add method does all of the work)

61
New cards

Quick Sort

Sorting algorithm that selects a pivot and arranges it so that the elements smaller than the pivot are on its left and larger on its right and will repeat this until the array is sorted (changeToExtractionMode does all of the work)

62
New cards

Selection Sort

Sorting algorithm where it will find the smallest element from the unsorted portion of the list and swapping it with the first unsorted element, which is repeated until sorted (removeFirst does all of the work)