COMPSCI 2 FINAL

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/31

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.

32 Terms

1
New cards

True or False: If there exists a recursive solution to a problem you should always opt to use it over any iterative solution

False

2
New cards

Every ____ call requires that the system allocate memory space for its formal parameters and local variables, and then deallocate the memory space when the method exits.

Recursive

3
New cards

True or False: Every (recursive) call also has its own set of parameters and local variables.

True

4
New cards

True or False: There are usually two ways to solve a particular problem – iteration and recursion.

True

5
New cards

A linked list is a collection of components, called ____.

Nodes

6
New cards

True or False: Using two reference variables can simplify the insertion code for a linked list.

True

7
New cards

True or False: Computers use stacks to implement method calls.

True

8
New cards

What statement can you issue to run the garbage collector?

System.gc();

9
New cards

A(n) _______ is a list of homogeneous elements where addition and deletion occur only at the top of the stack.

Stack

10
New cards

A stack is also called a(n) ______ data structure.

Last In First Out (LIFO)

11
New cards

add(value)

appends value at end of list

12
New cards

add(index, value)

inserts given value just before the given index, shifting subsequent values to the right

13
New cards

clear()

removes all elements of the list

14
New cards

indexOf(value)

returns first index where given value is found
in list (-1 if not found)

15
New cards

get(index)

returns the value at given index

16
New cards

remove(index)

removes/returns value at given index, shifting
subsequent values to the left

17
New cards

set(index, value)

replaces value at given index with given value

18
New cards

size()

returns the number of elements in list

19
New cards

toString()

returns a string representation of the list
such as "[3, 42, -7, 15]"

20
New cards

addAll(list)
addAll(index, list)

adds all elements from the given list to this list
(at the end of the list, or inserts them at the given index)

21
New cards

contains(value)

returns true if given value is found somewhere in this list

22
New cards

containsAll(list)

returns true if this list contains every element from given list

23
New cards

equals(list)

returns true if given other list contains the same elements

24
New cards

iterator()
listIterator()

returns an object used to examine the contents of the list
(seen later)

25
New cards

lastIndexOf(value)

returns last index value is found in list (-1 if not found)

26
New cards

remove(value)

finds and removes the given value from this list

27
New cards

removeAll(list)

removes any elements found in the given list from this list

28
New cards

retainAll(list)

removes any elements not found in given list from this list

29
New cards

subList(from, to)

returns the sub-portion of the list between
indexes from (inclusive) and to (exclusive)

30
New cards

toArray()

returns the elements in this list as an array

31
New cards

The statement, ____, creates a node somewhere in memory and stores the address of the newly created node
in newNode

newNode = new Node();

32
New cards

In a stack, the ____ operation removes the top element from the stack.

pop