Previous Quiz Questions CSCE 221

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

Which vertex of the graph is called source ? graph-02a.pdf

1

An undirected graph is connected when DFS - visits all vertices in a graph - generates a DFS forest - generates one DFS tree - detects a cycle in a graph

generates one DFS tree

Select the skip lists operation which is based on a random function. - insert - search - delete

insert

consider: int* ip = new int(5); cout << *ip; What is the type of the variable ip? -int -pointer to type int -reference to type in

pointer to type int

Which traversal operation should be used to evaluate an arithmetic expression stored in the exp_tree_quiz - In-order traversal - Pre-order traversal - Post-order traversal

post-order traversal

Which recurrence relation cannot be solved by the Master method? - T(n) = T(n/2) + O(n) and T(1) = 0 - T(n) = T(n/16) + O(1) and T(1) = 0 - T(n) = T(n/2) + O(log2n) and T(1) = 0 - T(n) = T(n-2) + O(n) and T(1) = 0

- T(n) = T(n-2) + O(n) and T(1) = 0

consider: int* ip = new int[3]{1,2,3}; cout << (*ip)++; What value is displayed by the cout statement?

1

How many times is the push operation called by the algorithm for the evaluation of the expression in the postfix form for the question? given in postfix form: 4 3 1 + / 2 *, find the solution

7

A quadratic algorithm, O(n^2), takes 10^3 sec to complete a task on the input size of 10^6 elements. What should the input size be for this algorithm to complete the same task in 4 · 10^3 sec?

2*10^6

The height of a 2-4 tree with n input items in the internal nodes is the largest when all nodes are - 2-node - 3-node - 4-node

2-node

The merge sort algorithm reaches the base case after a certain number of recursive steps. Select the number of the recursive steps for the merge sort. - nlog2n - log2n - n - 2^n

log2n

Which the Disjoint Sets operation is used by the Kruskal's algorithm as the first one. - make_set() - union() - find_set()

make_set()

Assume that your binary search tree is already built. How many print operations does it take to display binary search tree data in sorted order? - O(log2n) - O(n) - O(nlog2n) - O(n^2)

O(log2n)

How many comparisons does it take to search for a target in the balanced binary search tree with n nodes? - O(log2n) - O(n) - O(nlog2n) - O(n^2)

O(log2n)

The expected number of comparisons for the delete operation in a skip list is - O(1) - O(log2n) - O(n) - O(nlog2n)

O(log2n)

The number of comparisons for unsuccessful search in a 2-4 tree is - O(log2n) - O(n) - O(nlog2n)

O(log2n)

Which sequence is generated by In-order traversal operation for the tree in Q7-I.pdf ? - D H F P V T M - D F H M P T V - M F D H T P V

D F H M P T V

1. Consider a graph represented as an adjacency lists. A->B->D B->A->C C->B->D D->A->C E->F F->E What is the output of the Depth First Search (DFS) algorithm for this graph when the search starts at the vertex A and follows the adjacency list order? Complete this part on paper and answer the questions below based on the output. Which vertex is not in the DFS tree rooted at A?

E

Consider the graph below. What is the indegree of the vertex 1. graph-02a.pdf

0

What is the total number of the subproblems solved by the recursive algorithm? T(n) = 9T(n/3) + n and T(1) = 0

81

Is the merge sort an in-place algorithm? (t/f)

false

An element of a dynamic array allocated on a heap/free memory can be accessed explicitly using the bracket operator [ ]. (t/f)

true

Can a given undirected, weighted graph have more than one MST? (t/f)

true

Consider the BST 15 / \ 5 20 \ 7 Is the tree a valid AVL tree? (t/f)

true

Consider the BST 15 / \ 5 20 \ 7 Is the tree a valid Red-Black tree? Hint: Can you paint every node using two colors (red and black) in this way that the definition of the R-B tree is satisfied? (t/f)

true

Evaluate the statement, "Every AVL tree is a Binary Search Tree (BST)". (t/f)

true

If a private data member of a class is declared as a pointer then the class should define a copy constructor to avoid creating a shallow copy. (t/f)

true

Is the stability of the counting sort a necessary condition for the correctness of the radix sort? (t/f)

true

The AVL balancing technique always generates a BST with height of order log2n (t/f)

true

The Abstract Data Type (ADT) defines a theoretical model of a data structure. (t/f)

true

The first algorithm performs (10^−8)n^2 operations on an input of the size n and the second algorithm on the same input performs (10^3)n operations. "There exists an input such that the first and second algorithm performs the same number of operations." (t/f)

true

The heap and merge sort have the same running time in terms of Big-O asymptotic notation. (t/f)

true

The removal of an object from the queue or stack data structure is done in constant time. (t/f)

true

Which case of the quick sort algorithm cannot be solved by the Master method? - best - worst - average

worst

What is the conclusion from the "Lower Bound Theorem" for the comparison based sorting algorithms? - No one can design a comparison based sorting algorithm with the number of comparisons lower than nlog2n. - No one can design a comparison based sorting algorithm with the number of comparisons lower than nlog2n in the worst case. - No one can design a comparison based sorting algorithm with the number of comparisons greater than nlog2n. - No one can design a comparison based sorting algorithm with the number of comparisons greater than nlog2n in the worst case.

No one can design a comparison based sorting algorithm with the number of comparisons lower than nlog2n in the worst case

The minimum number of comparisons to find an item in a red-black tree is: - O(1) - O(log2n) - O(n) - O(nlog2n)

O(1)

The file below illustrates the stages of the Minimum Priority Queue (MPQ) when the shortest path was calculated from the vertex a to all other vertices in a graph by the Dijkstra's algorithm. Which vertices are on the shortest path from the vertex a to the vertex c? - a b c - a e f d c - a f e c - a f e d c

a f e c

The number of comparisons performed by the quick sort algorithm is the same for - worst and best cases - worst and average cases - best and average cases

best and average cases

Which rotation should be used to fix the property of AVL tree below? 7 / 4 \ 5 Hint: Double left - two rotations: the first right above the child of the pivot, the second left above the pivot. Double right - two rotations: the first left above the child of the pivot, the second right above the pivot. - single left - single right - double left - double right

double right

A debugger makes compilation of very large programs more time efficient. (t/f)

false

The postfix form for the expression: x + y - z + t is

xy + z - t +

Which node in the binary tree BST-Test.png has the same height and depth ?

c

How many comparisons does it take to build an unbalanced binary search tree with n nodes?

O(n^2)

consider: int* ip = new int[3]{1,2,3}; cout << *(ip++); What value is displayed by the cout statement?

1

Assume that an expression consists of one digit numbers and arithmetic operations on them and its is given in postfix form: 4 3 1 + / 2 * What is the value of the expression?

2

Consider a graph represented as an adjacency lists. A->C->B->D B->D C->E->D D->E E->A What is the output of the Breadth First Search (BFS) algorithm for this graph when the search starts at the vertex C and follows the adjacency list order? Complete this part on paper and answer the questions below based on the output. What is the length of the shortest path from the vertex C to A?

2

What is the outdegree of the vertex 4 in the graph? graph-02a.pdf

2

consider: int* ip = new int[3]{1,2,3}; cout << *(++ip); What value is displayed by the cout statement?

2

consider: int* ip = new int[3]{1,2,3}; cout << ++(*ip); What value is displayed by the cout statement?

2

Select a sequence generated by the post-order traversal applied to the tree Exp_tree_quiz.png - 2 a 1 - * 3 b * + - 2 * a - 1 + 3 * b - + * 2 - a 1 * 3 b

2 a 1 - * 3 b * +

The file below illustrates the stages of the Minimum Priority Queue (MPQ) when the shortest path was calculated from the vertex a to all other vertices in a graph by the Dijkstra's algorithm. What is the value of the shortest path from the vertex a to the vertex c? - 50 - 129 - 140 - 167 - 214

214

How many recursive subproblems are solved by the merge sort algorithm applied to a sequence of n elements? - 2^(n/2) - 2^(log2n) - 1 - 2^n - 1 - n/2

2^(log2n) - 1

Consider a graph represented as an adjacency lists. A->B->D B->A->C C->B->D D->A->C E->F F->E What is the output of the Depth First Search (DFS) algorithm for this graph when the traversal starts at the vertex A and it follows the adjacency list order? Complete this part on paper and answer the questions below based on the output. 1. How many vertices are reachable from the vertex A?

3

Consider a graph represented as an adjacency lists. A->C->B->D B->D C->E->D D->E E->A What is the output of the Breadth First Search (BFS) algorithm for this graph when the search starts at the vertex C and follows the adjacency list order? Complete this part on paper and answer the questions below based on the output. What is the length of the shortest path from the vertex C to B?

3

How many external children has an internal node with two items? - 2-children - 3-children - 4-children

3-children

How many operations does it take to solve all sub-problems of the size during the second recursive call of the algorithm? T(n) = 9T(n/3) + n and T(1) = 0 - n - 3n - 9n - 27n

3n

During the insertion operation in 2-4 tree an overflow could occur in - 2-node - 3-node - 4-node

4-node

The height of a 2-4 tree with n input items in the internal nodes is the smallest when all nodes are - 2-node - 3-node - 4-node

4-node

How many sub-problems are formed by the recursive algorithm at each recursive call? Provide the answer based on the recurrence relation. T(n) = 9T(n/3) + n and T(1) = 0

9

Consider a weighted, undirected and connected graph implemented as an adjacency matrix. What is the running time of the Prim's algorithm for MST? Assume that the Minimum Priority Queue is implemented as an unsorted list with an efficient performance of the decrease_key() function. - O(n) - O(n^2) - O(n2log2n) - O(nlog2n)

O(n^2)

Consider a graph represented as an adjacency lists. A->B->D B->A->C C->B->D D->A->C E->F F->E What is the output of the Depth First Search (DFS) algorithm for this graph when the search starts at the vertex A and follows the adjacency list order? Complete this part on paper and answer the questions below based on the output. Which vertex is present at the tree rooted at E?

F

What is the running time of the Dijkstra's algorithm under the assumptions that the graph is implemented as an adjacency matrix and Minimum Priority Queue is implemented as a binary heap. The symbol n denotes the number of vertices. - O(n) - O(log2n) - O(n^2) - O(n2log2n)

O(n2log2n)

What is the complexity of the Binary Search algorithm that runs on sorted input? Assume that n is the input size.

O(log2n)

Assume that the graph is represented as an adjacency matrix with vertices. How many comparisons does it take to find a single vertex indegree? - O(1) - O(log2n) - O(n) - O(n^2)

O(n)

The number of operations to extract data in sorted order from an existing red-black tree is: - O(1) - O(log2n) - O(n) - O(nlog2n)

O(n)

Assume that a graph is represented as an adjacency list with n vertices and m edges. How many comparisons does it take to find a single vertex indegree? - O(n) - O(m) - O(n+m) - O(n*m)

O(n+m)

Consider the quick sort algorithm to sort n consecutive integers and the middle element is selected as the pivot at each recursive call. What is the running time of the quick sort algorithm expressed in terms of the big-O asymptotic notation on this input? - O(nlog2n) - O(n^2) - O(n)

O(nlog2n)

The number of comparisons for building a red-black tree with n items is: - O(log2n) - O(n) - O(nlog2n) - O(n^2)

O(nlog2n)

The number of comparisons for building an AVL tree with n items is: - O(log2n) - O(n) - O(nlog2n) - O(n^2)

O(nlog2n)

What is the running time of the heap sort algorithm expressed in the terms of big-O asymptotic notation? - O(n) - O(nlog2n) - O(n^2)

O(nlog2n)

What is the recurrence relation equation for the merge sort algorithm? - T(n) = T(n/2) + O(n) and T(1) = 0 - T(n) = T(n/2) + O(nlog2n) and T(1) = 0 - T(n) = 2T(n/2) + O(n) and T(1) = 0 - T(n) = T(n/2) + O(nlog2n) and T(1) = 0

T(n) = 2T(n/2) + O(n) and T(1) = 0

Consider the quick sort algorithm to sort n consecutive integers and the middle element is selected as the pivot at each recursive call. What is the recurrence relation that describes the quick sort algorithm on this input? - T(n) = 2T(n/2) + n and T(1) = 0 - T(n) = T(n/2) + n and T(1) = 0 - T(n) = T(n-1) + n and T(1) = 0

T(n) = 2T(n/2) + n and T(1) = 0

Assume that the counting sort algorithm is applied to sort one million, n=10^6 , Social Security numbers (SSNs). Note that the value of the largest SSN is k = (10^10)-1. Why is the counting sort impractical? That is, why is it not used for sorting SSNs? - The allocation of the auxiliary array C by this algorithm takes too much space (computer memory), around 9GB. - The running time of the counting sort is not linear with respect to n

The allocation of the auxiliary array C by this algorithm takes too much space (computer memory), around 9GB.

The Shell sort algorithm is implemented based on the insertion sort. Select the type of input that Shell sort performance is worse than of insertion sort on this input. - The input is already sorted in increasing order. - The input is already sorted in decreasing order. - The input is random order.

The input is already sorted in increasing order.

Why is the postfix form used for an algebraic expression? - The postfix form could be translated faster to any programming language. - The postfix form provides for engineers a more readable form of an algebraic expression. - The postfix form speed up the evaluation process of an algebraic expression. - The postfix form reduces the number of operations during the evaluation process of an algebraic expression.

The postfix form speed up the evaluation process of an algebraic expression.

When does the Dijkstra's algorithm not provide the correct solution to the SSSP problem? - The Minimum Priority Queue is implemented as a binary heap. - There is a cycle with a negative weight in the graph. - There are no edges with negative weights. - The graph adjacency list is arranged in increasing order.

There is a cycle with a negative weight in the graph.

Which statement is false about the 2-4 trees? - All external nodes have the same depth. - The total number of the external nodes differs by 1 from the total number of items in all the internal nodes. - The Inorder traversal is valid operation for 2-4 trees. - To extract all items in the sorted order from a 2-4 tree requires O(log2n) operations.

To extract all items in the sorted order from a 2-4 tree requires O(log2n) operations.

What is the purpose of using the stack data structure during the conversion of infix to postfix form for an arithmetic expression? - To push the operands (a number or variable) into the postfix form in the reverse order. - To push the arithmetic operators before enqueuing them in the right order into the postfix form. - A stack is used only to detect the end of an expression. - A stack is redundant during the conversion to postfix form and it should not be used.

To push the arithmetic operators before enqueuing them in the right order into the postfix form.

Which sorting algorithm contains the insertion sort as part of it? - bucket sort - counting sort - radix sort

bucket sort

Which data structure could be used to implement the Disjoint Sets data structure? - priority queue - hash table - singly linked list - doubly linked list with augmented nodes

doubly linked list with augmented nodes

Which statement is true about the algorithm below? The running time function f (n) provides a formula for the number of operations (additions and assignments) done on the variable sum. The Big-O asymptotic notation is used to classify the algorithm based on the function f (n). Assume that the value of n is the exact power of 4. sum = 0; for (int i = 1; i < n; i*=4) sum = sum + 1; - f(n)=2log2n+1 and f(n)=O(log2n) - f(n)=2log2n+3 and f(n)=O(log2n) - f(n)=2log4n+1 and f(n)=O(log2n) - f(n)=2log4n+3 and f(n)=O(log2n)

f(n)=2log4n+1 and f(n)=O(log2n)

A dynamic array stores input data on the stack computer memory. (t/f)

false

Consider the minimum binary heap given by this array: Table2-Q.png Does this array below represent the minimum binary heap after calling the function remove_min()? Table3-Q.png (t/f)

false

Does this Q8-I.png satisfy the definition of the binary search tree? (t/f)

false

Does this array represent maximum binary heap? Table1-Q.png (t/f)

false

Is the tree Q8-I.png proper? (t/f)

false

Is this recursive function correct? int sum(int n) { if (n == 0) return 0; return (n - 1) + sum(n); } (t/f)

false

Is this statement true? "The running time of the copy constructor and move assignment for the stack data structure expressed in the terms of the Big-O asymptotic notation is the same." (t/f)

false

The binary and linear search algorithms take the same number of comparisons to find the target in the worst case. (t/f)

false

The stack data structure is implemented based on dynamic array. The cost of which stack operation is calculated based on the amortized analysis? - is_empty - top_of_stack - pop - push

push

Which data structure is not part of Dictionary? - queue - skip lists - binary search trees - linked lists

queue

Which data structure should be used for simulation of replenishing bottles of milk in grocery shelves? - stack - queue - STL vector

queue

What is the purpose of the find_set() operation? - Select an edge with the highest (largest) weight and add it to MST. - Select an edge with the lowest (smallest) weight and add it to MST. - Return the size of a set. - Return the identifier of the set.

return the identifier of the set

Build a red-black tree according to the algorithm provided on the lecture slides using the sequence: 26, 13, 17, 36, 46, 56. What is the root and height of the tree? Include the edges to the external nodes. - root=46, height=5 - root=26, height=4 - root=36 , height=3 - root=17, height=4

root=36 , height=3

Build an AVL tree according to the algorithm provided on the lecture slides using the sequence: 26, 13, 17, 36, 46, 56. What is the height of the tree? Include the edges to the external nodes. - root=17, height=4 - root=26, height=4 - root=36, height=3 - root=46, height=2

root=36, height=3

Which rotation should be used to fix the property of AVL tree below? 1 \ 2 \ 3 Hint: Double left - two rotations: the first right above the child of the pivot, the second left above the pivot. Double right - two rotations: the first left above the child of the pivot, the second right above the pivot. - single left - single right - double left - double right

single left

Which data structure does not support unsuccessful search in O(log2n) time in the worst case. - AVL trees - Red-Black trees - 2-4 trees - Skip lists

skip lists

Which data structure listed below is non-deterministic? - Linked lists - AVL trees - 2-4 trees - Skip lists

skip lists

Which data structure is used for building an expression tree? - queue - stack - dynamic array - linked list

stack

Which data structure should be used to reverse input data? - queue - stack - circular array

stack

consider: int* ip = new int(5); cout << *ip; Where does the variable ip reside in computer memory? - heap part - stack part

stack part


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

Physics flashcards for exam 2- examples and steps

View Set

Microeconomics Final Study Guide

View Set

CH 24: Assessing Musculoskeletal System

View Set