ITCS 2214 FINAL

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

B-tree properties

- All keys in a B-tree must be distinct. - All leaf nodes must be at the same level. - An internal node with N keys must have N+1 children. - Keys in a node are stored in sorted order from smallest to largest. - Each key in a B-tree internal node has one left subtree and one right subtree. All left subtree keys are < that key, and all right subtree keys are > that key.

Treaps

- Uses a main key that maintains a BST ordering property and a secondary key generated randomly during insertino that maintains a heap property - A mix of a tree and a max-heap - Search is the same as a BST search - Insert is a BST until a random priority is assigned

Look at the following method. public static int test2(int x, int y) { if ( x < y) { return -5; } else { return (test2(x - y, y + 5) + 6); } } What is returned for test2(10, 20)?

-5

A binary tree with just one node has height _________.

0

In Java, the first node in a list has index _________.

0

Consider a hash table of size seven, with starting index zero, and a hash function (3x+4) mod 7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that '_' denotes an empty location in the table.

1, 8, 10, _, _, _, 3

3 properties of a Directed Tree

1. no connections from other vertices to root (single direction) 2. every non-root element has one connection to it 3. there is path from root to every other vertex

3 forms of Multi-Way Search Tree

2-3 Trees, 2-4 Trees, and B Trees

________ are trees with perfect height balance but the nodes can have different number of children so they might not be weight balanced.

2-3-4 trees

_____ expands on the concept of 2-3 trees to include the use of 4 nodes and each node can contain 3 elements.

2-4 trees

After one pass on the numbers ( 5 3 9 5 ), what would be the result if you were to use Bubble Sort?

3 5 5 9

What is the number of unlabeled simple directed graph that can be made with 2 vertices?

4

Suppose that a non-leaf node in a B-tree has 41 entries. How many children will this node have?

42

Given a list with nodes 40, 20, 32, -3, 2, what does GetLength(list) return?

5

What is the maximum possible number of edges in a directed graph with no self loops having 8 vertices?

56

AVL

A BST with a height balance property and specific operations to rebalance the tree when a node is inserted or removed

Connected graph

A graph in which all vertices are connected (paths between verticies)

Complete graph

A graph in which each of the n vertices is connected to every other vertex. (edges between each verticies)

Perfect Binary Tree

A perfect binary tree is a binary tree in which all interior nodes have two children and all leaves have the same depth or same level.

Topological sort

A topological sort of a directed, acyclic graph produces a list of the graph's vertices such that for every edge from a vertex X to a vertex Y, X comes before Y in the list

Which statement is true for a B-tree?

All leaves are at the exact same depth.

Suppose that X is a B-tree leaf containing 41 entries and having at least one sibling. Which statement is true?

Any sibling of X is also a leaf.

___________ may provide a better solution both within a B-tree node and for collecting B-tree nodes because they are effective in both primary memory and secondary storage.

Arrays

Bellman-Ford shortest path algorithm

At each vertex, the distance and predecessor pointer is determined

In _________ tree all leaf nodes must be at the same level.

B-tree

A graph is connected if and only if the number of vertices in the __________ traversal is the same as the number of vertices in the graph regardless of the starting vertex.

Breadth-first (if all the nodes can be reached from each node)

A ________ is a path in which the first and last vertices are the same and none of the edges are repeated.

Cycle

Binary Tree

Each node has up to two children

Which of the following is not an invariant maintained in the balanced binary search tree system

Every internal node contains 2, 3, or 4 keys.

Dijkstra's algorithm may not terminate if the graph contains negative-weight edges.

False

The implementation of the collection operations should affect the way users interact with the collection.

False

A rotation will never change the root node

False, a left or right rotation can cause the root's value to change

complete binary tree

In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible.

Dijkstra's shortest path algorithm

Initializes all vertices' distances to infinity, travels to the lowest nodes

A _____________ can have more than two children per Node, and can store more than one element in each Node.

Multi-way Search Tree

2-3 Trees

Multi-way search tree where each node has 0, 2, or 3 children, and each Node contains 1 or 2 elements.

worst case BST Time

O(N)

AVL tree with n nodes has a height of

O(log(n))

best case BST time

O(logN)

The shifting of elements in a noncircular array implementation creates an _______ complexity.

O(n)

What is the time complexity of a Quick sort?

O(nlogn)

A directed graph, sometimes referred as a digraph, is a graph where the edges are _________ pairs of vertices.

Ordered

if the _________ of a 2-3 tree insertion causes the root to split, the tree increases in Height

Propogation Effect

Fusion

Provides an additional option for increasing the number of keys in a node. The inverse operation of a split

Inserting an Element into a 2-3 tree can have a _____

Ripple Effect

____________ is the process of finding a designated target within a group of items or determining that it doesn't exist.

Searching

Suppose that a B-tree has maximum of 10 branching of 11 and that a node already contains the keys/values 1 through 10. If a new value, 11, is added to this node, the node will split into two nodes. What values will be in these two nodes?

The first piece will have 1 through 5 and the second piece will have 7 through 11.

Breadth First Search

Visits the neighbor vertices before visiting the child vertices Often used to find the shortest path from one vertex to another. A queue is usually implemented

In a height balanced binary search tree (AVL), when do you make an adjustment in the tree?

When the height difference between two sides of a node is greater than or equal to two.

Full Binary Tree

a binary tree in which all of the leaves are on the same level and every nonleaf node has two children

max-heap

a binary tree where a node's key must be greater than or equal to the node's children root must have maximum key

In a red black tree, a null child is considered...

a black leaf node

Red-Black Tree

a self-balancing binary tree in which nodes are "colored" red or black. The longest path from the root to a leaf is no more than twice the length of the shortest path.

depth-first search

a traversal that visits a starting vertex, then visits every vertex along each path starting from that vertex to the path's end before backtracking

Two vertices in a graph are ___________ if there is an edge connecting them.

adjacent

2-3-4 tree

an order 4 b-tree

The ____________ sort algorithm sorts a list by repeatedly comparing neighboring elements and swapping them if necessary.

bubble

Each hash table array element is called a __________.

bucket

A red nodes child

cannot be red

A _________ is what occurs when two objects that are not equal have the same hash code.

collisions

The chaining method for handling __________ simply treats the hash table conceptually as a table of collections rather than as a table of individual cells.

collisions

If a class implements Comparable, it must have a ___________ method.

compareTo

Directed Tree

directed graph that has an element designated as a root

Topological Order

each node is ordered by in-order

A pop operation on a Stack returns a(n) _________.

element

A collection where each node can have from 0 to 3 children is called a Binary Tree.

false

Each recursive call to a method uses the same local variables and parameters.

false

Mathematical problems and formulas should not be expressed recursively.

false

Stack elements are processed in a FIFO manner-the first element in is the first element out.

false

The first operation removes an element at the front of the queue and returns a reference to it.

false

If the equals method reports that two objects are equal, then both objects' ________ methods should return the same value.

hashCode

A technique for direct search is _______________

hashing

In a red black tree, All paths from a node to any null leaf descendant node must...

have the same number of black nodes

What feature of heaps allows them to be efficiently implemented using a partially filled array?

heaps are complete binary trees

in an AVL tree, a balance factor of 2 or -2

implies that a rotation must occur

_________ traversal means visit the left child, then the node, then the right child.

inorder

A binary tree traversal method that recursively traverses the left subtree, then visits the root, then traverses the right subtree is called _________.

inorder traversal

What type does "compareTo" return?

int

In tree structure diagrams, non leaf node is called __________.

internal node

A hash table has buckets 0 to 5 and uses a hash function of key mod5. If the table is initially empty and the following inserts are applied in the order shown, the insert of which item results in a collision? HashInsert(hashTable, item 3) HashInsert(hashTable, item 5) HashInsert(hashTable, item 17) HashInsert(hashTable, item 22)

item 22

Ordering Property of a 2-4 Tree

left Child < Left most element of Node <2nd < 3rd < 4th

Which of the following has the smallest time complexity? - Logn + 2 - 3n+5+2n - n logn - 3n+4

logn + 2

A binary tree with no root

must be empty

What is the O(_) of this growth function? 3n^4+n^2+3 n-867.5309

n^4

A ________, or a weighted graph, is a graph with weights or costs associated with each edge.

network

The elements of an _____________ have an inherent relationship defining their order.

ordered list

Which of the following is NOT a primary method for a queue?

pop

Which of the following problems cannot be programmed recursively?

printing a class list with grades

Though not a queue at all, a minheap provides an efficient implementation of a _____________.

priority queue

To add an element to a stack you use the _________ method.

push

Simulations are often implemented using _______ to represent waiting lines.

queue

We are writing a program to simulate traffic flow at a 4-way stop. Which is the best data structure choice for simulating the cars waiting at each stop sign?

queue

Which of the following method calls itself?

recursive

The part of a problem that is solved with recursion is known as the

recursive case

A node that does not have a parent is called the ______ of a tree.

root

The method ______ replaces element at specified index with newElement.

set()

A circular array implementation of a queue is more efficient than a fixed array implementation of a queue because elements never have to be ___________.

shifted

min-heap

similar to a max-heap but a node's key is less than or equal to its children's keys

__________ is the process of arranging a list of items into a defined order based on some criteria.

sorting

If the propagation effect of a 2-3-4 tree insertion causes the root to _________, the tree increases in height

split

As the order of a B-trees increases...

the maximum number of keys and children per node increases

Elements in a collection are typically organized by

the order of their addition to the collection or by some inherent relationship among the elements

In a binary tree,

there must be at most one node with no predecessor

A careful _______ of recursive processing can provide insight into the way it is used to solve a problem.

trace

A careful trace of recursive processing can provide insight into the way it is used to solve a problem.

true

A hash function may give the same hash value for distinct messages.

true

A hash function takes a message of arbitrary length and generates a fixed length code.

true

A linked list dynamically grows as needed and essentially has no capacity limitations.

true

Implementing a list with a sentinel node or dummy node as the first node eliminates the special cases dealing with the first node.

true

One of the reasons recursion is so elegant and effective is that it creates a new set of local variables and parameters with each call.

true

The order of a recursive algorithm can be determined using techniques similar to analyzing iterative processing.

true

A path in a directed graph is a sequence of directed edges that connects two _________ in a graph.

verticies


Ensembles d'études connexes

GS ACCT 2302 Chapter 19 Cost Management Systems: Activity-Based, Just-in-Time, and Quality Management Systems

View Set

Microbiology Chapter 6 - Exam #1

View Set

Microeconomics: Canada in the Global Environment: CHAPTER 3Q1. What is the distinction between a money price and a relative price? The money price of a good is the dollar amount that must be paid for it. The relative price of a good is itUESTIONS REVIEW

View Set

international conflict exam 1, International Conflict, International Conflict Midterm, International Conflict Review, International Conflict Midterm, International Conflict Test 1, International Conflict Exam 1, International Conflict Midterm 1, Inte...

View Set