CSI 2310 Test 2

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 25

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

26 Terms

1

addAll

Use insatnceof

New cards
2

When typing IntNode

ex.) answer.head = IntNode.listCopy(head);

New cards
3

IntArrayBag union

Uses instanceof

New cards
4

IntLinkedBag union

Does not use instanceof

New cards
5

clone method

Create local variable

New cards
6

Where cursor = head in for loop

listSearch, listLength

New cards
7

Where cursor and i is used in for loop

listPosition

New cards
8

ADT

Encapsulates data with a set of operations which form the interface

of the type. An ADT can be implemented as a Java class.

New cards
9

Collection

Object that contains a collection of elements that may be objects as well. Such object is called a container.

Ex.) bags, sets, sequences

New cards
10

Collection ADT called IntBag

Specification

public interface IntBag

{ void add(int element);

boolean remove (int target);

int size();

int countOccurrences(int target);

void addAll(IntBag addend);

IntBag union(IntBag addend); // different from book;}

New cards
11

Invariant

A class is a property of objects of

the class. It must hold of the state of the object before and after each public method. Each public method (except constructors) can assume the invariant holds before execution and must make sure the invariant holds after execution.

New cards
12

Linked List

Dynamic dynamic sequential data

structure that is comprised of nodes that have data and link to next node. Used to implement collections or list of elements in some type of order.

New cards
13

IntNode class

private int data;

private IntNode link;

New cards
14

head

Not a node, a reference to a node. Store as null.

New cards
15

Insert Node at front

public static IntNode insertAtFront(IntNode head, int entry)

return new IntNode(entry, head);

New cards
16

Remove head Node

head = head.getLink(); Now goes into garbage collection.

New cards
17

Insert Node at front

head = IntNode.insertAtHead(head, entry);

New cards
18

New Node not at front

previous.link = IntNode.insertAtHead(previous.link, entry);

New cards
19

Add Node after

public void addNodeAfter(int item) {

link = new IntNode(item, link); }

New cards
20

Remove Node after

public void removeNodeAfter( ) {

link = link.link; }

New cards
21

Computation on entire list

Length, copying, locating

New cards
22

Traversal

Visiting a node in a list and performing an action on it.

for (cursor = head; cursor!=null; cursor=cursor.link) {

do computation with the node referred to by cursor }

New cards
23

Sequence class on LL

public class DoubleLinkedSeq implements DoubleSeq {

private DoubleNode head;

private int manyItems;

private DoubleNode current; }

New cards
24

add element to bag

1.) Create new node

2.) Increment total elements

New cards
25

addAll elements from addend

1.) Create node array

2.) instance of

3.) new must be > 0

4.) create new node w/ tail

5.) link to head

6.) set head to head of copy

7.) add to manyNodes

8.) else throw exception

New cards
26

Node

Places each element together with links.

New cards
robot