Advanced Data Structures and Algorithms Exam 1

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

Give the Inorder, Preorder, and Postorder for the following tree .....1 ..../.\ ...2...3 ../.\ 4....5

(a) Inorder (Left, Root, Right) : 4 2 5 1 3 (b) Preorder (Root, Left, Right) : 1 2 4 5 3 (c) Postorder (Left, Right, Root) : 4 5 2 3 1

1 + 2 + 3 + ... + 999 a) 9990 b) 99900 c) 999000 d) 500000 e) 499500

1 + 2 + 3 + ... + 999 e) 499500 How: (999*1000)/2

How do you solve a left-to-right binary method for powers?

1. Convert decimal to binary 2. Start on the left, the 1 becomes an x 3. For each new binary place, multiply by x² (if 1 then multiply by an additional x)

A data structure that can be used to obtain a non-recursive version of a recursive algorithm: a) stack b) queue c) priority queue d) 2-tree e) balanced tree

A data structure that can be used to obtain a non-recursive version of a recursive algorithm: a) stack

A sorting algorithm that is not comparison-based: a) Mergesort b) Quicksort c) Insertionsort d) Treesort e) Radix Sort

A sorting algorithm that is not comparison-based: e) Radix Sort

An algorithm with worst-case complexity W(n) is said to be polynomial-time if a) W(n) is a polynomial b) W(n) ∈ O(n^k ) for some constant k c) W(n) ∈ Ω(n^k ) for some constant k d) W(n) ∈ Θ(n^k ) for some constant k e) W(n) has sub-exponential order

An algorithm with worst-case complexity W(n) is said to be polynomial-time if b) W(n) ∈ O(n^k ) for some constant k

An algorithm with worst-case complexity W(n) is to be exponential if a) W(n) is a super-polynomial b) W(n) ∈ O(2ⁿ) c) W(n) ∈ Ω(2ⁿ) d) W(n) ∈ Θ(eⁿ) e) W(n) ∈ Ω(aⁿ) and W(n) ∈ O(bⁿ) for real numbers a and b, 1 ≤ a ≤ b

An algorithm with worst-case complexity W(n) is to be exponential if e) W(n) ∈ Ω(aⁿ) and W(n) ∈ O(bⁿ) for real numbers a and b, 1 ≤ a ≤ b

An efficient algorithm for computing the greatest common divisor of two integers is: a) DFS b) Horner's rule c) FFT d) Euclid's Algorithm e) Kruskal's Algorithm

An efficient algorithm for computing the greatest common divisor of two integers is: d) Euclid's Algorithm

An efficient algorithm for polynomial evaluation is: a) DFS b) Horner's rule c) FFT d) Euclid's algorithm e) Kruskal's algorithm

An efficient algorithm for polynomial evaluation is: b) Horner's rule

An efficient on-line sorting algorithm (i.e., elements added over time): a) Mergesort b) Quicksort c) Insertionsort d) Treesort e) Radix Sort

An efficient on-line sorting algorithm (i.e., elements added over time): c) Insertionsort

Assuming a uniform distribution the worst case and average complexities of Insertion sort are: a) ~n/2 and ~n/4 b) ~nlog₂n and ~log₂n/2 c) ~4n and ~2n d) ~n²/2 and ~n²/4 e) ~4n²/2 and ~2n²

Assuming a uniform distribution the worst case and average complexities of Insertion sort are: d) ~n²/2 and ~n²/4

Binary Search assumes as a precondition that: a) The search element is on the list b) The list consists of integers or floating-point numbers c) The list satisfies a uniform distribution d) The list is sorted once the search element is added e) The list is sorted

Binary Search assumes as a precondition that: e) The list is sorted

Bubblesort has best, average and worst-case complexities, respectively, given by: a) Θ(n) , Θ(n) , Θ(n²) b) Θ(n) , Θ(n²), Θ(n²) c) Θ(n log n) , Θ(n log n), Θ(n²) d) Θ(n log n), Θ(n²) , Θ(n²) e) Θ(n²) , Θ(n²) , Θ(n²)

Bubblesort has best, average and worst-case complexities, respectively, given by: b) Θ(n) , Θ(n²), Θ(n²)

Consider the array implementation of a complete binary tree in C++. For a node indexed by I the indices the parent, left child and right child are respectively given by: a) I, 2*I, 3*I b) (I - 1)/2, 2*I + 1 , 2*I + 2 c) I - 1, 2*I , 2*I + 1 d) (I - 1)/2, 2*I , 3*I e) I - 1, I + 1 I + 2

Consider the array implementation of a complete binary tree in C++. For a node indexed by I the indices the parent, left child and right child are respectively given by: b) (I - 1)/2, 2*I + 1 , 2*I + 2

What are three important issues to consider when designing an algorithm?

Correctness, Efficiency, and Choice of Data Structure (ADT)

Horner's Rule for the polynomial 2x⁴ + 6x³ - 44x² + x + 5 is based on which parenthesizing a) ((2x⁴ + 6x³) - (44x² + x)) + 5 b) (((2x + 6)x - 44)x + 1)x + 5 c) ((2x⁴ + 6x³) - 44x² ) + x) + 5 d) x(2x³ + 6x²)+ x (44x + 1) + 5 e) none of the above

Horner's Rule for the polynomial 2x⁴ + 6x³ - 44x² + x + 5 is based on which parenthesizing b) (((2x + 6)x - 44)x + 1)x + 5

If Euclid's GCD algorithm is initially called with a = 100019 and b = 100 after one iteration a) a = 100, b = 100019 b) a = 100019, b = 19 c) a = 100, b = 19 d) a = 99919, b = 19 e) b = 19, a = 100

If Euclid's GCD algorithm is initially called with a = 100019 and b = 100 after one iteration c) a = 100, b = 19

What Binary Tree Traversal is used to output the items of a binary search tree in sorted order?

Inorder

Insertionsort has best, average and worst-case complexities, respectively, given by: a) Θ(n) , Θ(n) , Θ(n²) b) Θ(n log n), Θ(n²) , Θ(n²) c) Θ(n log n) , Θ(n log n), Θ(n²) d) Θ(n) , Θ(n²), Θ(n²) e) Θ(n²) , Θ(n²) , Θ(n²)

Insertionsort has best, average and worst-case complexities, respectively, given by: d) Θ(n) , Θ(n²), Θ(n²)

Linear Search has worst-case and best-case complexities, respectively: a) Θ(log n), Θ(1) b) Θ(log n), Θ(log n) c) Θ(log n), Θ(n) d) Θ(n), Θ(log n) e) Θ(n), Θ(1)

Linear Search has worst-case and best-case complexities, respectively: e) Θ(n), Θ(1)

Mergesort has best, average and worst-case complexities, respectively, given by: a) Θ(n) , Θ(n log n) , Θ(n log n) b) Θ(n log n) , Θ(n log n), Θ(n log n) c) Θ(n log n) , Θ(n log n), Θ(n²) d) Θ(n log n), Θ(n²) , Θ(n²) e) Θ(n²) , Θ(n²) , Θ(n²)

Mergesort has best, average and worst-case complexities, respectively, given by: b) Θ(n log n) , Θ(n log n), Θ(n log n)

What Binary Tree Traversal is used to delete all the nodes in a binary tree (destructor)?

Post-order

What Binary Tree Traversal is used to evaluate a binary expression tree?

Post-order

What Binary Tree Traversal is used to perform a deep copy of one binary tree to another (copy constructor)?

Pre-order

What Binary Tree Traversal is used to store a binary search tree in a file so that it can be reconstructed when the file is scanned sequentially?

Pre-order

Quicksort has best, average and worst-case complexities, respectively, given by: a) Θ(n) , Θ(n log n) , Θ(n log n) b) Θ(n log n) , Θ(n log n), Θ(n log n) c) Θ(n log n) , Θ(n log n), Θ(n²) d) Θ(n log n), Θ(n²) , Θ(n²) e) Θ(n²) , Θ(n²) , Θ(n²)

Quicksort has best, average and worst-case complexities, respectively, given by: c) Θ(n log n) , Θ(n log n), Θ(n²)

Radixsort has best, average and worst-case complexities, respectively, given by: a) Θ(n) , Θ(n) , Θ(n²) b) Θ(n) , Θ(n) , Θ(n) c) Θ(n log n) , Θ(n log n), Θ(n²) d) Θ(n) , Θ(n²), Θ(n²) e) Θ(n²) , Θ(n²) , Θ(n²)

Radixsort has best, average and worst-case complexities, respectively, given by: b) Θ(n) , Θ(n), Θ(n)

The average number of updates in computing the maximum element in a list of size n for a uniform distribution is approximately: a) (log₂n) / 2 b) log₂n c) ln n d) n/2 e) nlog₂n

The average number of updates in computing the maximum element in a list of size n for a uniform distribution is approximately: c) ln n

The depth of a complete binary tree having n leaf nodes is approximately equal to: a) 2ⁿ b) n*log₂n c) log₂n d) n² e) n

The depth of a complete binary tree having n leaf nodes is approximately equal to: c) log₂n

The depth of a complete binary tree on n nodes is approximately equal to: a) 2ⁿ b) n*log₂n c) log₂n d) n² e) n

The depth of a complete binary tree on n nodes is approximately equal to: c) log₂n

The formal definition of an algorithm uses the following concept: a) Algorithm machine b) Turing machine c) Phat machine d) AI machine e) Scooby Doo mystery machine

The formal definition of an algorithm uses the following concept: b) Turing machine

The number of binary digits of an integer n is approximately equal to: a) 2ⁿ b) n log₂n c) log₂n d) n² e) n

The number of binary digits of an integer n is approximately equal to: c) log₂n

The number of decimal digits of an integer n is approximately equal to: a) 10ⁿ b) n c) log₁₀n d) n² e) None of the above

The number of decimal digits of an integer n is approximately equal to: c) log₁₀n

The recurrence relation for the worst-case complexity W(n) of the sorting algorithm Mergesort for n a power of 2 is given by: a) W(n) = W(n - 1) + n, Initial Condition W(1) = 0 b) W(n) = 2W(n - 1) + n, Initial Condition W(1) = 0 c) W(n) = 2W(n/2) + 1, Initial Condition W(1) = 0 d) W(n) = W(n/2) + n - 1, Initial Condition W(1) = 0 e) W(n) = 2W(n/2) + n - 1, Initial Condition W(1) = 0

The recurrence relation for the worst-case complexity W(n) of the sorting algorithm Mergesort for n a power of 2 is given by: e) W(n) = 2W(n/2) + n - 1, Initial Condition W(1) = 0

The sequence of computation involved in the left-right binary method for 57 is a) x → x³ → x⁷ → x¹⁴ → x²⁸ → x⁵⁷ b) x → x² → x⁶ → x¹³ → x²⁸ → x⁵⁷ c) x → x³ → x¹⁴ → x⁵⁷ d) x → x² → x⁴ → x⁸ → x¹⁶ → x 3² → x⁵⁷ e) x → x³ → x⁷ → x¹⁵ → x²⁹ → x⁵⁷

The sequence of computation involved in the left-right binary method for 57 is a) x → x³ → x⁷ → x¹⁴ → x²⁸ → x⁵⁷

The smallest worst-case complexity for computing the maximum and minimum elements in a list of even size n is: a) n - 1 b) 3n/2 - 2 c) 2n - 2 d) 5n/2 - 1 e) n²

The smallest worst-case complexity for computing the maximum and minimum elements in a list of even size n is: b) 3n/2 - 2

The smallest worst-case complexity of a comparison-based sorting algorithm is: a) Θ (log n) b) Θ (n) c) Θ (n log n) d) Θ (n²) e) Θ (n²)

The smallest worst-case complexity of a comparison-based sorting algorithm is: c) Θ (n log n)

The total number of nodes of a 2-tree with 40 leaf nodes is: a) 40 b) 70 c) 79 d) 80 e) 89

The total number of nodes of a 2-tree with 40 leaf nodes is: c) 79

The worst-case complexity W(n) of a given algorithm is defined as: a) The fewest basic operations performed b) The most basic operations performed c) The most basic operations performed for an input of size n d) The worst performance of the algorithm e) The expected performance over all inputs of size n

The worst-case complexity W(n) of a given algorithm is defined as: c) The most basic operations performed for an input of size n

The worst-case complexity for the right-to-left binary method of computing powers in terms of the number n of binary digits where the basic operation is multiplication is a) log₂n b) 2n - 2 c) 3n - 2 d) nlog₂n e) n²

The worst-case complexity for the right-to-left binary method of computing powers in terms of the number n of binary digits where the basic operation is multiplication is b) 2n - 2

The worst-case complexity of Euclid's algorithm for gcd(a,b) occurs when a and b are: a) Relatively prime b) Different by one c) Consecutive prime numbers d) Consecutive Exponential numbers e) Consecutive Fibonacci numbers

The worst-case complexity of Euclid's algorithm for gcd(a,b) occurs when a and b are: e) Consecutive Fibonacci numbers

The worst-case complexity of Quicksort occurs when: a) The list is already sorted b) The largest element occurs in the first position c) The input list satisfies a uniform distribution d) The input list has large size e) None of the above

The worst-case complexity of Quicksort occurs when: a) The list is already sorted

Which best describes an algorithm a) Sequence of steps for solving a problem b) Search engine c) Logarithm d) Application e) C++ program

Which best describes an algorithm a) Sequence of steps for solving a problem

Which of the following sorting algorithms is not in-place: a) Bubble sort b) Insertion sort c) Mergesort d) Quicksort e) They are all in-place

Which of the following sorting algorithms is not in-place: c) Mergesort (in-place means it doesn't require extra storage)

Which traversal outputs the nodes of a binary search tree in sorted order: a) Preorder Traversal b) Inorder Traversal c) Postorder Traversal d) Phat Traversal e) None of the above

Which traversal outputs the nodes of a binary search tree in sorted order: b) Inorder Traversal

f(n) satisfies the recurrence relation f(n) = f(n/2) +1, init. cond. f(1) = 0. Then f(n) has order: a) 2ⁿ b) n*log₂n c) log₂n d) n² e) n

f(n) satisfies the recurrence relation f(n) = f(n/2) +1, init. cond. f(1) = 0. Then f(n) has order: c) log₂n

Trace action Euclid GCD for a = 5, b = 121

gcd(5,121) = gcd(121,5) = gcd(5,1) = gcd(1,0) = 1

What is the formula for the trace action of Euclid GCD?

gcd(a,b)=gcd(b,r)


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

EC350 -- Chapter #18: Money, Banks, and the Federal Reserve

View Set

The Aggregate Expenditures Model

View Set

ECON202 CHAPTER 9: INFLATION (the percentage increase (change) in the price level from one year to the next

View Set