Final exam prep Ch 5 - 9

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 10, which of the following statements are true? (Multiple answers)

* 1471, 6171 hash to the same value * 9679, 1989, 4199 hash to the same value

The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table?

0 - 1 - 2 12 3 13 4 2 5 3 6 23 7 5 8 18 9 15

A hash table's items will be positive integers, and -1 will represent empty. A 7-bucket hash table is: -1, -1, -1, -1, 72, -1, -1. How many items are in the table?

1

Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. 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 1, 10, 8, _, _, _, 3 8, _, _, _, _, _, 10 1, _, _, _, _, _,3

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

Look at the following pseudocode algorithm. algorithm Test14(int x) if (x < 8) return (2 * x) else return (3 * Test14(x - 8) + 8) end Test14 What value is returned for Test14(7)? 0 7 14 -5

14

________ are trees with perfect height balance but the nodes can have different number of children so they might not be weight balanced. - AVL trees - 2-3-4 trees - Treaps - B-trees

2-3-4 trees

Consider the weighted graph below, what is the weight of the shortest path from vertex 2 to vertex 3? 2->4->3 = 19 2->5->3 = 4 2->1->4->3 = 29

4

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

4

A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below. Which one of the following choices gives a possible order in which the key values could have been inserted in the table? 0 - 1 - 2 42 3 23 4 34 5 52 6 46 7 33 8 - 9 -

46, 34, 42, 23, 52, 33

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

56

In _________ tree all leaf nodes must be at the same level. - Binary - Linked - Multi-way - B-tree

B-tree

________ are a generalization of 2-3-4 trees that allow for a large branching factor, sometimes up to 1000s of children. Due to their large branching factor, they are well-suited for storing data on disks. - AVL trees - Red-Black trees - Treaps - B-trees

B-trees

A node that has a parent is called the root of a tree. FALSE

False

The goal of hashing is to produce a search that takes _____. O(n log n) time O(n2) time O(1) time O(n) time

O(1) time

The complexity for insert into a binary search tree is _____. - O(n^2) - n (log n) - O(n^3) - O(n)

O(n)

A find operation on a balanced binary search tree is O(logn) where as a find operation for binary search tree without the balance assumption is O(n).

True

All the leaves of a B-tree are at the same level.

True

Any recursive definition must have a nonrecursive part, called the base case, which permits the recursion to eventually end.

True

Dijkstra's Algorithm will NOT work for both negative and positive weights.

True

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

True

Each recursive call to a method DOES NOT use the same local variables and parameters.

True

If a problem can be solved with iteration, it can be solved with recursion.

True

Mathematical problems and formulas should be expressed recursively

True

The depth of a node in a tree is equal to the number of its ancestors.

True

The __________ method adds a given Comparable element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap. addElement add addNext none of the above

addElement

Which statement is true for a B-tree? - All nodes contain the exact same number of entres. - All leaves are at the exact same depth. - All entries of a node are greater than or equal to the entries in the node's children. - All non-leaf nodes have the exact same number of children.

all leaves are at the exact same depth

___________ 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. - Queues - Linked lists - Arrays - Stacks

arrays

A _________ is what occurs when two objects that are not equal have the same hash code cycling collision shorting indexing

collision

Since a heap is a complete tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full. - Maxheap - Balanced tree - Complete tree - Minheap

complete tree

A binary tree is a collection of nodes in which - each node has at most one predecessor and exactly two successors - each node has at most one predecessor and at most two successors - each node has at least one predecessor and at most two successors - each node has at most one predecessor and at most one successor

each node has at most one predecessor and at most two successors

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

false

In a B-tree of order 8, the root node must have at least 4 subtrees. FALSE

false

Key value pairs is usually seen in _____ - ArrayLists - Hash tables - Heaps - LinkedLists

hash tables

A technique for direct search is _______________ linear search hashing binary search tree search

hashing

What is the maximum number of edges present in a simple directed graph with 7 vertices if there exists no cycles in the graph?

i still think it's 6.

In tree structure diagrams, non leaf node is called __________. - descendant node - external node - internal node - search node

internal node

In hashing, elements are stored in a hash table, with their _________ in the table determined by a hashing function. - Order - Location - Precedence - None of the above

location

Assuming value of every weight to be greater than 10, in which of the following cases the shortest path of a directed weighted graph from 2 vertices u and v will never change? - In both the cases of multiplying and adding by 10 - add all values by 10 - subtract 10 from all the values - multiply all values by 10

multiply all values by 10

A binary tree with no root - must have only one node - must have exactly two nodes - must be empty - None of the above

must be empty

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

ordered

A breadth first traversal of a tree or a graph is commonly implemented with a(n)_______. - queue - double-linked list - stack - weighted graph

queue

Which of the following method calls itself? Reoccurring Circular Recursive Looping

recursive

_____________ processing can be simulated using a stack to keep track of the appropriate data Push Loop Pop Recursive

recursive

A node that does not have a parent is called the ______ of a tree. top leaf root foot

root

Access to ____________ storage is very slow relative to access to primary storage, which is motivation to use structures such as B-trees. - secondary - cache - cloud - recent

secondary

Like a loop, a recursive method must have __________________ - a return statement. - a counter. - some way to control the number of times it repeats itself. - a predetermined number of times it will execute before terminating.

some way to control the number of times it repeats itself

If the propagation effect of a 2-3-4 tree insertion causes the root to _________, the tree increases in height. - be deleted - expand - split - rotate

split

The depth of recursion is: - the value returned from the last recursive call. - There is no such term. - the number of times that a method calls itself. - the value that will terminate the recursive calls.

the number of times that a method calls itself

A path in a directed graph is a sequence of directed edges that connects two _________ in a graph. - Trees - Edges - Vertices - Junctions

vertices

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 the recursive case for the method? x < y x != y -5 x >= y

x >= y


संबंधित स्टडी सेट्स

BUSI - Chapter 6 (Management in Today's Organizations)

View Set

Software Engineering- Chapter 04: Process Models

View Set

15. Two siblings: 4 year-old male and 8 week-old male with vomiting

View Set

Becker: EXAM #1, REG 1, MODULES 1-6

View Set