2214 Quizzes

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Given a list with nodes 'Z', 'A', 'B', 'X' Sort(list) yields _____.

'A', 'B', 'X', 'Z'

Any recursive definition must have a non-recursive part, called the ___________, which permits the recursion to eventually end.

Base case

The number of times that a method calls itself is known as the

Depth of recursion

Which of these have the smallest time complexity?

Quick

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

Sorting

A ______ can be used to reverse the order of a set of data.

stack

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

0

________ 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 tree

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

21

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

3559

What is the result after first pass if Insertion Sort is used with this data set ( 5 3 9 5 )?

3595

What is the result after second pass if Insertion Sort is used with this data set ( 5 3 9 5 )?

3595

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

Which of the following statement(s) is TRUE?

A hash function takes a message of arbitrary length and generates a fixed length code. A hash function may give the same hash value for distinct messages.

A collection is an __________ where the details of the implementation are hidden.

Abstraction

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

Adjecent

Which of the following scenarios leads to linear running time for a random search hit in a linear-probing hash table?

All keys hash to the same index

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

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

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.

B-tree

Inserting an element in the middle of a LinkedList is more efficient than inserting an element into the middle of an ArrayList. Which of the statement is correct?

Because the LinkedList has to shift all elements after the insertion point to make room for the new element.

A recursive method is a method that _____________________

Call itself

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

Collect

A _______ is an object that gathers and organizes other objects.

Collection

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

Collision

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

Collision

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

Cycle

Which of the following basic algorithms can be used to most efficiently determine if a given graph is connected?

DFS algorithm

The __________ method is very effective when dealing with an unknown set of key values.

Division

Which of the following is not an invariant maintained in the balanced binary search tree system called 2-3-4 trees?

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

AVL trees are efficient because they provide Θ(n) access/search time and insert time.

False

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

False

If both the left and right subtrees of a binary tree T meet the definition of an AVL tree, then T must be also meet the definition of an AVL tree.

False

If the algorithm is inefficient, a faster processor will help. t/f

False

In Java method calls are always O(n). t/f

False

Insertion sort is an algorithm that sorts a list of values by repetitively putting a particular value into its final, sorted, position. t/f

False

Mathematical problems and formulas should not be expressed recursively.

False

Objects that are stored in a collection should contain implementation details of the underlying data structure. t/f

False

Selection and Insertion sort all have time complexity of O(n). t/f

False

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

False

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

False

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

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

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

Heaps are complete binary trees

Inserting an element into a 2-3-4 tree can have a ripple effect up the tree causing the _______ of the tree to increase.

Height

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

Inorder

The _____________ method and the mid-square method may also be effectively used with strings by manipulating the binary representations of the characters in the string.

Length dependent

If h is any hashing function and is used to hash n keys in to a table of size m, where n<=m, the expected number of collisions involving a particular key x is ________.

Less than 1

A data structure that uses object reference variables to create links between objects is:

Linked Structure

What kind of list has the best performance when answering questions such as "What is the item at position n?"

Lists implemented with an array.

In hashing, elements are stored in a hash table, with their _________ in the table determined by a hashing function.

Location

The _____ sort algorithm sorts a list by recursively dividing the list in half until each sub-list has one element and then merging these sub-lists into the sorted order.

Merge

Which sort method starts by repeatedly splitting the list in half?

Merge

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?

Multiply all values by 10

In a B-tree, an internal node with N keys must have ____ children.

N+1

A linked list is composed of objects that each point to the _______________.

Next object on the list

The goal of hashing is to produce a search that takes _____.

O(1)

Adding an item to an array that were the problem does not allow duplicate items in the array requires approximately how many comparisons of elements?

O(n)

Selection and Insertion sort all have time complexity of __________.

O(n^2)

Merge Sort has time complexity _____.

O(nlogn)

The addElement operation for both the linked and array implementations is O(__________).

O(nlogn)

The best comparison sort in terms of the order is:

O(nlogn)

The following code segment has ______ time complexity? for(int i = 0; i < n; i++){ for(int j = 0; j < n: j=j*2){ int val = (j*i); System.out.println(val)

O(nlogn)

What is the order of the following growth function? t(n)= 5nlogn + 20n - 4

O(nlogn)

Extraction involves using _________ of the element's value or key to compute the location at which to store the element.

Only a part

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

Ordered

Each recursive call to a method creates new local variables and __________.

Parameter

The predecessor of a node in a binary tree is called its

Parent

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

Path

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

A ______ can be used to preserve the order of a set of data.

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 describe a difference between a queue and a stack?

Queues modify both ends of the structure; stacks modify only one.

The ____________ sort algorithm sorts a list by partitioning the list and then recursively sorting the two partitions.

Quick

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

Secondary

This type of sequential sort algorithm sorts a list by repeatedly placing the next smallest element into its final sorted position.

Selection sort

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

Split

The only difference between a depth-first traversal of a graph and a breadth-first traversal is the use of a _________ instead of a queue to manage the traversal.

Stack

Tree algorithms typically run in time O(d). What is d?

The depth of the tree

In a list implementation of a queue, the end of the list from which elements are removed is called

The front of the queue

The variable top in the array implementation of a stack refers to

The next available position in the array

What does a growth function show?

Time or space utilization relative to the problem size

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

Trace

A data structure is the underlying programming construct used to implement a collection. t/f

True

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

True

During insertion, only a full node can be split.

True

Inserting an element in the middle of a LinkedList is more efficient than inserting an element into the middle of an ArrayList. t/f

True

The selection sort algorithm sorts a list of values by repetitively putting a particular value into its final, sorted, position. t/f

True

The elements of an _____________ are kept in whatever order the client chooses.

Unordered list

A systematic procedure for starting at the first node in a list, and visiting all nodes in the list by going from each node to its successor is called

a traversal

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

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

bubble

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

compareTo

A linked list is _______.

dynamic

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

false

The most efficient way to implement an array-based stack keeps the top of the stack at the position 0 of the array? t/f

false

Which of the following operations of a queue examines the element at the front of the queue?

first

The method ______ returns element at specified index.

get()

The method ______ returns the element at specified index.

get()

The method ______ returns the number of elements in the ArrayList.

get()

Items in a stack are added to the _______, and removed from the __________. (answers are in the order of the blanks).

head, head

___________ is the process of deriving a new class from an existing one.

inheritance

What type does "compareTo" return?

int

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

internal node

In general, a balanced n-ary tree with m elements will have height _______.

log n m

A ___________ is a complete binary tree in which each node is less than or equal to both the left child and the right child.

minheap

The time complexity of the add operation on a linked implementation would be O(____) if we chose to add at the end of the list instead of the front?

n(logn)

What is the time complexity of a Quick sort?

n(logn)

What is the O(_) of this growth function? 3n4+n2+3n-867.5309

n^4

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

ordered list

Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their ________.

parent

To remove an element from stack you use the ------ method.

pop

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

push

A breadth first traversal of a tree or a graph is commonly implemented with a(n)_______

queue

Simulations are often implemented using _______ to represent waiting lines.

queue

A minheap stores its smallest element at the ________ of the binary tree.

root

The method ______ replaces element at specified index with newElement.

set()

The method ______ returns the number of elements in the ArrayList.

size()

Like a loop, a recursive method must have __________________

some way to control the number of times it repeats itself.

In an array implementation of a Stack, the array is ___________ causing the implementation to have to create a new larger array and copy the contents of the stack into the new array in order to expand the capacity of the stack.

static

You are writing a pointer-based, doubly linked, non-circular list using a Node class with fields called "prev", "data" and "next". Which code fragment would remove the last node in the list?

tail.prev.next = null; tail = tail.prev;

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 list implementation of a queue, the end of the list at which elements are added is called

the rear of the queue

A ________ is a randomized BST that maintains balance in a probabilistic way.

treap

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

true

A linked list has no set capacity limitations other than the size of the computer's memory. t/f

true

A linked structure uses object reference variables to link one object to another. t/f

true

Every subtree of a "binary search tree" is also a "binary search tree".

true

Given a graph G = (V;E) with positive edge weights, the Bellman-Ford algorithm and Dijkstra's algorithm can produce different shortest-path trees despite always producing the same shortest-path weights.

true

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

true

Recursion is the most elegant and appropriate way to solve some problems, but for others it is less intuitive than an iterative solution.

true

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

true

The enqueue and dequeue operations work on opposite ends of the collection. t/f

true

The merge sort algorithm sorts a list by recursively dividing the list in half until each sublist has one element and then merging these sub-lists into the sorted order. t/f

true

The open addressing method for handling collisions looks for another open position in the table other than the one to which the element is originally hashed. t/f

true

The order in which references are changed is crucial to maintaining a linked list. t/f

true

The order of an algorithm is found by eliminating constants and all but the dominant term in the algorithm's growth function. t/f

true

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

vertices


Kaugnay na mga set ng pag-aaral

Chapter 2 - Basics of Real Estate Practice Questions

View Set

Prep U Chapter 34: Assessment and Management of Patients with Inflammatory Rheumatic Disorders

View Set

AP II_21007 Lect_ Chapter 17 Endocrine Sytem _ Tophat

View Set

RUC 1The Evolution of Nursing chap. 1

View Set