WGU C949 Data Structures and Algorithms

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

1/101

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.

102 Terms

1
New cards

A functions whose cost scales linearly with the size of the input

O(n)

2
New cards

Iterating over a collection of data once often indicates an ______ algorithm. (alphabet for-loop example)

O(n)

3
New cards

A functions whose cost scales logarithmically with the input size

O(log n)

4
New cards

Which type of function works by breaking down large problem into smaller and smaller chunks?

O(log n)

5
New cards

As the size of the input grows the cost of the algorithm does not increase at the same rate. The overall cost of performing an operation on 1,000,000 items is only twice that of performing the operation on 1,000 items.

O(log n)

<p>O(log n)</p>
6
New cards

A function that exhibits quadratic growth relative to the input size

O(n^2)

7
New cards

An example of this type of function is doubly nested loop

O(n^2)

8
New cards

Which type of function gets really expensive really quickly?

O(n^2)

<p>O(n^2)</p>
9
New cards

A function that has two inputs that contribute to growth

O(nm)

10
New cards

An example of this type of function is when there is a nested loop that iterates of two distinct collections of data

O(nm)

11
New cards

Are Big-O cases used in the best or worst situations?

Worst

12
New cards

Which statement is static?

readonly Contact[] contacts = new Contact[];

readonly Contact contacts = new Contacts[100];

readonly Contact contacts = new Contacts[100];

13
New cards

A container where data is stored in nodes consisting of a single data item and a reference to the next node

Linked List

14
New cards

A ______ is a container where nodes of data are linked together into a list

Linked List

15
New cards

Linking together complex nodes into a single structure

Linked List

16
New cards

Each link in a chain for a linked lists is called a ______

node

17
New cards

What two things do nodes contain?

1. the value

2. reference to next item in the list

18
New cards

Give a coded example on how to create a 3 chained linked list of nodes.

Node head = new Node(1);

head.Next = new Node(2);

head.Next.Next = new Node(3);

19
New cards

A list where we start at the first node and follow the chain of nodes iterating over each until we get to the end

Singly Linked List

20
New cards

A list that builds on the singly linked list by adding reverse iteration.

Doubly Linked List

21
New cards

Give a coded example on how to create a doubly linked list

Node node1 = new Node(1);

Node node2 = new Node(2);

Node node3 = new Node(3);

node1.Next = node2;

node2.Previous = node1;

node2.Next = node3;

node3.Previous = node2;

22
New cards

The first and last nodes of a doubly linked list should have a value of ______

null

23
New cards

Adds a value to the beginning of the list

AddHead

24
New cards

Adds a value at the end of the linked list

AddTail

25
New cards

Finds the first node whose value equals the provided argument

Find

26
New cards

Returns true if the specified value exists in the list, false otherwise

Contains

27
New cards

Removes the first node on the list whose value is equal to the argument

Remove

28
New cards

A doubly linked list where the values are inserted and sorted in order

Sorted List

29
New cards

Adds the specified item to the linked list in the sort order of the item type

Add

30
New cards

A way of organizing, storing, and performing operations on data

Data Structure

31
New cards

A data structure that stores subitems, with a name associated with each subitem.

record

32
New cards

A data structure that stores an ordered list of items, with each item is directly accessible by a positional index.

Array

33
New cards

A data structure that stores ordered list of items in nodes, where each node stores data and has a pointer to the next node.

linked list

34
New cards

A data structure in which each node stores data and has up to two children, known as a left child and a right child.

binary tree

35
New cards

A data structure that stores unordered items by mapping (or hashing) each item to a location in an array.

hash table

36
New cards

A tree that maintains the simple property that a node's key is greater than or equal to the node's childrens' keys.

max heap

37
New cards

A tree that maintains the simple property that a node's key is less than or equal to the node's childrens' keys.

min heap

38
New cards

A data structure for representing connections among items, and consists of vertices connected by edges.

graph

39
New cards

This represents an item in a graph.

vertex

40
New cards

This represents a connection between two vertices in a graph.

edge

41
New cards

A Last-in, First-out (LIFO) data container

Stack

42
New cards

When something is retrieved from a stack, does it come from the top or bottom of the stack?

Top

<p>Top</p>
43
New cards

A First-in, First-out (FIFO) container

Queue

44
New cards

When something is removed from a queue, does it come from the head or the tail?

Head

<p>Head</p>
45
New cards

When something is added to a queue, does it get added to the head or the tail?

Tail

46
New cards

A queue-like container which is both First-in, First-out and Last-in, Last-out

Doubly Ended Queue (deque)

47
New cards

Which type of function allows for items to be added or removed from the beginning or end?

Doubly Ended Queue (deque)

48
New cards

A data structure where nodes have parent-child (1:N) relationship

Tree

49
New cards

Each node in a Tree has at least ______ parent, but the number of children depends on the type of tree

one

50
New cards

Every node in a tree has how many parents?

one

51
New cards

Every part of a tree spawns how many children?

0 or more

52
New cards

Nodes that have no children are called what?

Leaf nodes

53
New cards

How many data items does each node on a tree contain?

one

54
New cards

At most how many children can each node have in a binary tree?

two

55
New cards

The maximum number of children that each node can have

Degree

56
New cards

The maximum amount of edges between that node and a leaf

Height

57
New cards

When smaller values are added to this tree smaller values are added to the left

Binary Search Tree

58
New cards

The smallest value in a binary search tree will be on the bottom most ______, while the largest value will be on the bottom most ______

left

right

<p>left</p><p>right</p>
59
New cards

The insertion complexity on average of a binary search tree

O(log n)

60
New cards

The insertion complexity with the worst case of a binary search tree

O(n)

61
New cards

The node is visited before it's children

Pre-order

62
New cards

The left child is visited before the node, then the right child

In-order

63
New cards

The left and right children are visited before the node

Post-order

64
New cards

An example of why pre-order traversals are useful

To create an identical copy of a tree

65
New cards

What are in-order traversals useful for?

Sorting trees from least to greatest

<p>Sorting trees from least to greatest</p>
66
New cards

What are post-order traversals useful for?

To delete every node in a tree

67
New cards

The average case, best case and worst case for Traversal Complexity

O(n)

68
New cards

Searching in Binary Search Tree

O(log n)

69
New cards

How can a leaf node be removed from a tree?

Unlinking the node

70
New cards

How can a node with One Child be removed from a tree?

Promote the child

<p>Promote the child</p>
71
New cards

How can a node with Two Children be removed from a tree?

Move the successor's child up to the root node.

<p>Move the successor's child up to the root node.</p>
72
New cards

Removal Complexity in a Binary Tree

O(log n)

73
New cards

Containers that contain key-value pairs

Associative Array

74
New cards

A collection of key/value pairs where the key can only exist once in the collection

Associative Array

75
New cards

An associative array container that provides O(1) insert, delete and search operations

Hash Table

76
New cards

A function that maps data of arbitrary size to data of a fixed size

Hash Function

77
New cards

For a function to qualify as a hash function it has to have what three properties

Stability

Uniformity

Security

78
New cards

A hash function always generates the same output given the same input

Stability

<p>Stability</p>
79
New cards

A hash algorithm should distribute its resulting has value uniformly throughout the output space

Uniformity

80
New cards

A secure hashing algorithm cannot be inverted (the input derived from the output hash)

Security

81
New cards

An integer counter that represents how many variables reference an object

Reference Count

82
New cards

Equation for finding the middle value of an array

(high + low)/2

(DO NOT ROUND UP)

83
New cards

If an object is assigned to null (int = null;), will the object be considered for garbage collection?

Yes (it's considered for garbage collection right once it's assigned to null)

84
New cards

These can have any value, but cannot have matching keys

Dictionaries

85
New cards

Dictionary keys must be _____ and ______

unique

immutable

86
New cards

What method removes a value from a dictionary?

remove();

87
New cards

Which method removes a key from a dictionary?

pop();

88
New cards

Which method removes a key-value pair from a dictionary?

popitem();

89
New cards

Which method removes all keys from a dictionary?

keys();

90
New cards

There are 3 items in a stack, the next line of code is "push('item');". How many items are now in the stack?

4

91
New cards

1. Visit node

2. Traverse left

3. Traverse right

Preorder Traversal (Binary Tree)

92
New cards

Cannot handle sets, lists or dictionaries

Hash Function

93
New cards

A modulo hash function is used to map to indices 0 to 9. The hash function should be: key % _____

10

94
New cards

key % 1000 maps to indices 0 to ____.

999

95
New cards

A modulo hash function for a 50 entry hash table is: key % _____

50

96
New cards

A hash function computes a bucket index from an item's _____.

key

97
New cards

A 100 element hash table has 100 _____.

buckets

98
New cards

For a well-designed hash table, searching requires _____ on average.

O(1)

99
New cards

In a Hash Table keys need to be ______.

unique

100
New cards

Given a hash table with 100 buckets and modulo hash function, in which bucket will HashInsert(table, item 334) insert item 334?

34