CSE 2231 Midterm 2 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/55

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.

56 Terms

1
New cards

Heap

A binary tree of T that satisfies two properties:
- Global shape property: it’s a complete binary tree
- Local ordering property: the label in each node is “smaller than or equal to” the label in each of its child nodes

2
New cards

Complete Binary Tree

A binary tree in which all levels are “full” except possibly the bottom level, with any nodes on the bottom level as far left as possible Z

<p>A binary tree in which all levels are “full” except possibly the bottom level, with any nodes on the bottom level as far left as possible Z</p>
3
New cards

HeapSort

A heap can be used to represent the values in a SortingMachine, as follows:
- In changeToExtractionMode, arrange all the values into a heap
- In removeFirst, remove the root, and adjust the slightly mutilated heap to make it a heap again

4
New cards

SiftDown Algorithm

  1. Remove the root

  2. Find the right most element in the bottom of the heap (last element in the array)

  3. Promote that element to the root of the heap

  4. Look at the two children, find the smallest of the two, then check to see if the root is less than or equal to or greater than or equal to

  5. From there, sift down and repeat

5
New cards

Heapify

Makes a complete binary tree into a heap

6
New cards

Fixed Size

means the size/length of a collection is “inflexible”, in other words it is determined at initialized of the collection and cannot be incrementally adjusted
- synonym is static, this term unfortunately means other things in java

7
New cards

Dynamic Size

means the size/length of a collection is “flexible”, in other words it can be incrementally adjusted by “adding” and “removing” entries

8
New cards

Direct Access

means the entries of a collection may be accessed by providing an int position/index of any entry in the collection

9
New cards

Sequential Access

means the entries of a collection may be accessed in increasing order of position by accessing the “next” entry in the collection

10
New cards

Singly Linked List

A sequence of nodes where each node stores data and a link (or reference) to the next node in the list, called a singly because each node only knows about the next node, not the previous

11
New cards

Node Class

A … class is declared as a nested class inside the kernel implementation that uses it in a data representation of a linked list

12
New cards

Smart Node

A special node at the front of a linked list that doesn’t store real data, it just makes the list operations simpler and more consistent. also referred to as a dummy or sentinel node

13
New cards

advance

Advances the position in this by one

Moving a pointer or reference from the current node to the next node in the list

14
New cards

retreat

Retreats the position in this by one

Moving a pointer or reference from the current node to the previous node in the list

15
New cards

Doubly Linked List

A sequence of nodes where each node stores data and a link (or reference) to the next node in the list as well to the previous

16
New cards

Tree

A … can be thought of as a structure comprising of zero or more nodes, each with a label of some mathematical type, say T, called the label type

Is either:
- the empty tree which has no nodes
- a non-empty tree, which consists of a root node and a string of subtrees of the root

17
New cards

Tree newSequenceOfTree

Creates and returns an empty Sequence<Tree<T>> of the dynamic type needed in assemble and disassemble

18
New cards

Tree assemble

assembles in this a tree with root label root and subtrees children

19
New cards

Tree disassemble

disassembles this into its root label, which is returned as the value of the function, and subtrees in children.

20
New cards

Tree addSubtree

Adds st at position pos in the subtrees of this

21
New cards

Tree removeSubtree

Removes and returns the subtree at position pos of this

22
New cards

Tree numberOfSubtrees

Reports the number of subtrees of the root of this

23
New cards

BugsWorld Simulator

The BugsWorld game is played on a system consisting of:
- Server
- Clients
- Displays

24
New cards

Server

Keeps track of “the world”, processes client requests, resolves conflicts.

25
New cards

Clients

Each client program simulates creature (bug) behavior for all creatures of one species

26
New cards

Displays

Each display shows the current state of the world, plus some statistics about the simulation

27
New cards

BL Compiler

Consists of:
- Tokenizer
- Parser
- Code Generator

28
New cards

Abstract Syntax Tree

A tree model of an entire program or a certain “program structure”

“Abstract” in the sense that some of the characters used in the “concrete” program text do not appear in the AST

29
New cards

AST Node Labels

An AST for BL is a tree of…what?
Each node has some kind of the following:
- The kind of statement (BLOCK, WHILE)
- The test condition (NEXT_IS_EMPTY, TRUE)
- The call of an instruction (infect, move), realizing that this may be an instruction defined elsewhere in the program

30
New cards

Statement

Allows you to manipulate values that are ASTs for BL statements

mathematical model of a … is a tree of STATEMENT_LABEL

31
New cards

Enumerations

Java has a special construct, enum, that easily allows you to use meaningful, symbolic names where you might otherwise be inclined to declare int variables and give them arbitrary values to participate just in equality tests

32
New cards

Statement No Argument Constructor

this = compose((BLOCK, ?, ?), <>)

33
New cards

Statement Kind

Reports the kind of statement this is

34
New cards

Statement addToBlock

Adds the statement s at position pos in this BLOCK statement

35
New cards

Statement removeFromBlock

Removes and returns the statement at position pos of this BLOCK statement

36
New cards

Statement lengthOfBlock

Reports the number of statements in this BLOCK statement

37
New cards

Statement assemble

Depending on the type of condition, assembles in this a statement with root label (Type of condition, condition, ?) and only subtree the BLOCK s

38
New cards

Statement disassemble

Depending on the type of condition, disassembles the Type of Condition statement this into its test Condition, which is returned as the value of the function, and its only subtree, the BLOCK statement s

39
New cards

Program

Allows you to manipulate values that are models of complete BL programs

The mathematical model of a … includes that of a Statement (Specifically a BLOCK) for its body, plus:
- the program name
- the new user-defined instructions, each of which also has a body

40
New cards

Program No-argument Constructor

this = (“Unnamed”, {}, compose((BLOCK, ?, ?), <>))

41
New cards

Program name

Returns the name of this

42
New cards

Program setName

Replces the name of this with n

43
New cards

Program newContext

Creates and returns an empty Map<String, Statement> of the dynamic type needed in swapContext

44
New cards

Program swapContext

Exchanges the context of this with that of c; c must have the dynamic type returned by newContext

45
New cards

Program newBody

Creates and returns a Statement with a default initial value, of the dynamic type needed in swapBody

46
New cards

Program swapBody

Exchanges the body of this with that of b; b must have the dynamic type returned by newBody

47
New cards

Context Free Grammar

used to specify syntactically valid BL programs

use the grammar to implement a recursive descent parser

48
New cards

Rewrite Rule

describes how strings in the language may be formed

49
New cards

Non Terminal Symbol

A placeholder in a grammar that can be replaced by other symbols or groups of symbols according to the grammar’s rules

Represents a category that still needs to be broken down into smaller during parsing

50
New cards

Start Symbol

Non terminal symbol in the first rewrite rule

51
New cards

Terminal Symbol

A symbol in grammar that cannot be broken down any further — it appears directly in the final program or input

52
New cards

Derivation

A … of a string of terminal symbols consists of a sequence of specific rewrite rule applications that begin with the start symbol and continue until only terminal symbols remain

53
New cards

Tokenizer

The job of this is to transform a string of characters into a string of tokens

54
New cards

Parsing

Generally refers to this last step, going from a string to its derivation tree or for programming language perhaps to an AST for the program

55
New cards

{} (parsing)

Signifies a while loop

56
New cards

| (parsing)

Signifies an if-else statement