Computer Science Final Review

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

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.

77 Terms

1
New cards

Default Access Modifier

Variable/class is only available to the current package

2
New cards

Public Access Modifier

Variable/class is visible to all packages

3
New cards

Private Access Modifier

Variable/class is only visible to the class/package that contains it.

4
New cards

Protected

Variable is only accessible by subclasses.

5
New cards

Objects

Have properties (variables) and functions (methods).

6
New cards

Class

A blueprint to make objects.

7
New cards

Constructor

Simplifies the creation of one object by combining it into one method call. Passes parameters. Has no return type. Has the same name as the object.

8
New cards

Copy Constructor

Passes an object as its parameter. Used to copy values of one object to another without using the same address for both objects. Manually copies properties from one object to another.

9
New cards

Getter and Setter Functions are used for…

Objects with private properties.

10
New cards

abstract

Keyword used to define abstract classes and methods

11
New cards

Abstract Classes

Can’t be instantiated directly. They contains abstract methods and concrete methods. Abstract methods must be implemented by its children. Concrete methods are automatically inherited.

12
New cards

extends

Keyword used for classes that extend from the abstract class.

13
New cards

Linked List

Data structure for storing a collection of items. Can be visualized as nodes connected to each other. Goes in one direction, left to right. Stores the location of first and last nodes (head/tail nodes). Can be treated as a stack/queue.

14
New cards

Head

First node

15
New cards

Node Properties in a Linked List

2 Attributes; data and the next node.

16
New cards

Doubly Linked List

Each node keeps track of the next node as well as the previous node.

17
New cards

Tail

Last node

18
New cards

Create a linked list of string objects

LinkedList<String> linkedList = new LinkedList<>();

19
New cards

Add the element “A” onto the linked list via stack

linkedList.push"(“A”); // puts at the start of linked list

20
New cards

Remove an element of the linked list via stack

linkedList.pop();

21
New cards

Print out the linked list

System.out.println(linkedList);

22
New cards

Add the element “A” onto the linked list via queue

linkedList.offer(“A”); // puts at the end of the linked list

23
New cards

Remove an element of the linked list via queue

linkedList.poll();

24
New cards

Add the element “E” at index 4 for linked list

linkedList.add(4, “E”);

25
New cards

Remove the element “G” from linked list

linkedList.remove(“"G”);

26
New cards

Find the index of “F” in a linked list

linkedList.indexOf(“F”);

27
New cards

Peek at the first item in the linked list

linkedList.peekFirst();

28
New cards

Peek at the last item in the linked list

linkedList.peekLast();

29
New cards

Remove the first item in the linked list

linkedLast.removeFirst();

30
New cards

Remove the last item in the linked list

linkedLast.removeLast();

31
New cards

Add “0” to the start of the linkedList

linkedList.addFirst(“0”);

32
New cards

Add “G” to the end of the linkedList

linkedList.addLast(“G”);

33
New cards

Arraylist

Dynamic, their sizes can change.

34
New cards

Create an arraylist of integers

Arraylist<Integer> list = new ArrayList<>();

35
New cards

Add 1 into the arraylist

list.add(1);

36
New cards

Remove 2 from the arraylist

list.remove(2);

37
New cards

Set index 2 of the arraylist to 4

list.set(2, 4);

38
New cards

Get the item at index 3 of an arraylist

list.get(3);

39
New cards

Get the size of the arraylist

list.size();

40
New cards

Stack

LiFo, has push(), pop(), peek(), empty(), search(). Takes O(1) to push and pop.

41
New cards

Create a stack of string objects

Stack<String> stack = new Stack<String>();

42
New cards

Push “Minecraft” into the stack

stack.push(“Minecraft”);

43
New cards

Pop off the stack

stack.pop();

44
New cards

Check if the stack is empty

stack.empty();

45
New cards

Peek at the top most item of the stack

stack.peek();

46
New cards

Search for “DOOM” in the stack

stack.search(“DOOM”);

47
New cards

Create a queue of strings

Queue<String> queue = new LinkedList<String>();

48
New cards

Add “Karen” to the queue

queue.offer(“Karen”);

49
New cards

Remove from the queue

queue.poll();

50
New cards

Find the size of the queue

queue.size();

51
New cards

Check if the queue contains “Harold”

queue.contains(“Harold”);

52
New cards

Check if queue is empty

queue.isEmpty();

53
New cards

Hashtable

Stores key-value pairs. Search, insert, and deleting each takes O(1) time

54
New cards

Chaining

If a new element collides with one in a hashtable, the pre-existing element in the hashtable links to the new element via a linkedlist.

55
New cards

Open Addressing

Linear probing; if a collsion, check for space on the right of the pre-existing element. Keep going until it’s empty.

56
New cards

Double Hashing

Randomly chooses how far to go to check for an empty space when there’s a collision.

57
New cards

Adjacency Matrix

O(1) time complexity, O(V2) space complexity. Has unique nodes along columns and rows. If a 1, edge exists between those nodes.

58
New cards

Adjacency List

O(V) time complexity, O(V + E) space complexity. Uses an array/arraylist of linkedlists. Travel the linked list to identify which nodes are connected to which.

59
New cards

Depth First Search

A search algorithm for traversing a tree/graph data structure. Travels by branches and uses a stack.

60
New cards

Breath First Search

A search algorithm for traversing a tree/graph data structure. Checks one level at a time using a queue.

61
New cards

Time complexity of one for loop

O(n)

62
New cards

Time complexity of double for loop

O(n2)

63
New cards

Binary Search Tree

A tree where each node has at most 2 children. Values are arranged in a certain order. The root is greater than the left child and less than the right child. Remaining structure follows the same pattern.

64
New cards

In Order Tree Traversal

Left-most child, root, right
private void traverseTree(Node root) {
traverseTree(root.left);
System.out.println(root.data);

traverseTree(root.right);

}

65
New cards

Pre Order Tree Traversal

Print as you go left and right; root, left, right
private void traverseTree(Node root) {
System.out.println(root.data);
traverseTree(root.left);

traverseTree(root.right);

}

66
New cards

Post Order Tree Traversal

Print children before parent; Left, right, root
private void traverseTree(Node root) {
traverseTree(root.left);

traverseTree(root.right);

System.out.println(root.data);

}

67
New cards

Queue

FiFo, has offer(), poll(), peek(). O(1) to offer and poll.

68
New cards

Selection Sort Time Complexity

O(n2)

69
New cards

Bubble Sort Time Complexity

O(n2)

70
New cards

Insertion Sort Time Complexity

O(n2)

71
New cards

Merge Sort Time Complexity

O(nlogn)

72
New cards

Quick Sort Time Complexity

O(nlogn)

73
New cards

Insertion Sort

Compare the the value at index 1 to the values on the left. If it’s in the incorrect position, shift values. Then move to index 2. Compare to left. Shift if incorrect, repeat until the end.

74
New cards

Merge Sort

Recursively divides the array into sub arrays. Stop when the size is 1. Using a helper function, it merges the sub arrays in order into the bigger one. It continues merging until it reaches the original aray size and is completely sorted.

75
New cards

Quick Sort

Uses a pivot and finds the final place of that pivot. Compare the pivot to the values in the array. All items to the left are smaller than the pivot and all items to the right are bigger than the pivot. After the pivot is in the right place, partition the array up until the pivot from the left and right sides. Pass the partitions into another recursive step of quick sort.

76
New cards

Bubble Sort

Compares 2 values. Highest value bubbles to the top. Continue until array is sorted.

77
New cards

Selection Sort

Compares 2 values. Smallest number by default is at the start. Find the smallest number and swap with the first position. Continue until array is sorted.