CSI 2310 Test 2

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/25

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.

26 Terms

1
New cards

addAll

Use insatnceof

2
New cards

When typing IntNode

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

3
New cards

IntArrayBag union

Uses instanceof

4
New cards

IntLinkedBag union

Does not use instanceof

5
New cards

clone method

Create local variable

6
New cards

Where cursor = head in for loop

listSearch, listLength

7
New cards

Where cursor and i is used in for loop

listPosition

8
New cards

ADT

Encapsulates data with a set of operations which form the interface

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

9
New cards

Collection

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

Ex.) bags, sets, sequences

10
New cards

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;}

11
New cards

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.

12
New cards

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.

13
New cards

IntNode class

private int data;

private IntNode link;

14
New cards

head

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

15
New cards

Insert Node at front

public static IntNode insertAtFront(IntNode head, int entry)

return new IntNode(entry, head);

16
New cards

Remove head Node

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

17
New cards

Insert Node at front

head = IntNode.insertAtHead(head, entry);

18
New cards

New Node not at front

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

19
New cards

Add Node after

public void addNodeAfter(int item) {

link = new IntNode(item, link); }

20
New cards

Remove Node after

public void removeNodeAfter( ) {

link = link.link; }

21
New cards

Computation on entire list

Length, copying, locating

22
New cards

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 }

23
New cards

Sequence class on LL

public class DoubleLinkedSeq implements DoubleSeq {

private DoubleNode head;

private int manyItems;

private DoubleNode current; }

24
New cards

add element to bag

1.) Create new node

2.) Increment total elements

25
New cards

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

26
New cards

Node

Places each element together with links.