CSCI208 - Algorithms and analysis - Final practice

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

If S1 = {1, 2, 3, ..., 20}, S2 ={a, b, c, d}, S3 ={b, d, e, f}, then |(S1 ✕ S2)∪(S1 ✕ S3)| is _____. a. 120 b. 100 c. 40 d. 140

A

Rational numbers do not include.................. a. non terminating decimals b. all fractions c. all integers d. repeating decimals

A

The space factor when determining the efficency of algorithm is measured by counting the ........................ a. maximum memory needed b. minimum disk space needed c. average memroy needed d. minimum memory needed

A

A person wants to visit some places. He starts from a vertex and then wants to visit every place connected to this vertex and so on. What algorithm he should use? Select one: a. Breadth First Search b. Depth First Search

a

Algorithms that require _____ number of operations are practical for solving only problems of very small size a. Exponential b. Logarithmic c. Polynomial d. Linear

a

Arrange the following functions in order of increasing growth rate: !n, n , n, 2 Select one: a. n, n , 2 , !n b. n , n, 2 , !n c. n, n , !n , 2 d. n, 2 , n , !n

a

Assuming to solve our problem perfectly includes solving first some overlapped subproblem; then, which of the below techniques is best fit? a. Dynamic Programming b. All of the above c. Divide-and-Conquer d. Greedy Algorithms

a

Assuming to solve our problem perfectly includes solving first some sub problems, which are not overlapped; then, which of the below techniques is the best fit: a. Divide-and-Conquer b. Brute-Force c. All of the above d. Dynamic Programming

a

Closest pair problem can be solved using divide and conquer approach which yields time complexity of _____. a. Θ(n log n) b. none of the above c. Θ(n^2) d. Θ(n^2 log n)

a

In _____, it starts with no nodes or edges in the spanning tree, and repeatedly it adds the cheapest edge that does not create a cycle. a. Kruskal's algorithm b. Floyd's algorithm c. Warshall's algorithm d. Prim's algorithm

a

In mathematical induction, ---------- proves that a statement is true for the initial value. Select one: a. Base step b. Inductive step c. Iterative step d. Initial step

a

In the algorithm of checking primality of a given integer n, the basic operation is _____. a. key comparison b. division c. multiplication d. summation

a

In trees, _____ is the number of ancestors. a. depth of a node b. degree of a tree c. height of a tree d. degree of a node

a

In trees, external node is also called _____. a. leaf b. root c. subtree d. sibling

a

Merge sort, insertion sort and quick sort are examples of divide and conquer algorithm design paradigm. Select one: a. True b. False

a

Precedence constraints are examples of --------------------- graphs. A.directed B.Undirected

a

Since, recurrence for an algorithm made by the divide-and-conquer approach is T(n) = 3T(n/3) + √n , T(n) ∈ _____. a. Θ(n) b. Θ(√n log n) c. Θ(√n) d. None of the above

a

Solve the following recurrence using Master's theorem. T(n) = 2T(n/2) + n Select one: a. T(n) = O(n log n) b. T(n) = O(n log n) c. T(n) = O(n) d. T(n) = O(n ^ 2 )

a

The purpose of asymptotic notation is to suppress ------------- and ------------. Select one: a. constant factors, lower-order terms b. logarithmic terms, higher-order terms c. logarithmic terms, lower-order terms d. constant factors, higher-order terms

a

The purpose of asymptotic notation is to suppress ------------- and ------------. Select one: a. constant factors, lower-order terms b. logarithmic terms, higher-order terms c. constant factors, higher-order terms d. logarithmic terms, lower-order terms

a

There is a particular problem where its solutions includes solving ksub-problems, but because of the repetition, straightforward solution solves m subproblems where m>k. Also, on average the work done to solve a single subproblem requires noperations. Then, in Dynamic Programming, the *time* complexity is _____ Select one: a. Θ(kn) b. None of the above c. Θ(mn) d. Θ(m) e. Θ(k)

a

Time Complexity of Breadth First Search is? (n - number of vertices, m - number of edges) A.O(n + m) B.O(n) C.O(m) O(n*m)

a

Towers of Hanoi problem can be solved by a recursive algorithm that yields order of growth _____ a. 2^n b. n! c. n^3 d. n^2

a

Worst and average time complexity of Quickhull algorithm are _____ and _____ repectively. Select one: a. Θ(n^2) and Θ(n) b. none of the above c. Θ(n^3) and Θ(n^2) d. Θ(n^2) and Θ(n log n)

a

Y o u can p r o ve t hat 5 n + 2 n is n o t O ( n ) b y - - - - - - - - - - - - -. Select one: a. contradiction b. direct proof c. induction

a

_____ algorithm works as follows: scan the entire given list to find its smallest element and exchange it with the first element, putting the smallest element in its final position in the sorted list. a. Insertion Sort b. Selection Sort c. Bubble Sort d. Unique Array

a

_____ relation is valid when x is related to y and y is related to z and x is related to z. Select one: a. Transitive b. Reflexive c. effective d. symmetric

a

the runtime of insertion sort is............... a. o(n^2) b. o(log n) c. o(n log n) d. o(n)

a

time efficiency is analyzed by determining the number of repetitions of the...............as a function of input size. a. basic operation b. complex function c. global variable d. loop

a

"There is a student in NU who hates programming" could be negated as Select one: a. All the students outside NU hate programming b. All the students in NU do NOT hate programming. c. All the students outside NU do NOT hate programming. d. There is a student in NU who does NOT hate programming

b

Assuming we search a simple balanced binary tree, regardless of the graph representation, which one of the following algorithms requires less allocated storage during computation. Select one: a. Breadth First Search b. Depth First Search c. Both are the same

b

Hamiltonian circuit is a simple circuit that contains all _____ and may not pass through all _____ of the graph. a. edges, vertices b. vertices, edges

b

In mathematical induction, ---------- proves that if the statement is true for the nth iteration, then it is also true for (n+1)th iteration. Select one: a. Iterative step b. Inductive step c. Base step d. Initial step

b

Quicksort's _____ case happens when input array is sorted, _____ case happens when split is in the middle, and _____ case happens when input array is random a. average, worst, best b. worst, best, average c. average, best, worst d. best, worst, average

b

The Data structure used in standard implementation of Breadth First Search is? A.Stack B.Queue C.Linked List D.Tree

b

The _____ approach leads to an algorithm that solves common subproblems more than once and hence is very inefficient a. bottom up b. top down

b

The number of elements in a set is called the _____ of the set. Select one: a. idempotency b. cardinality c. complement d. multiset

b

The number of primitive operations performed by the algorithm you learned in grade school to multiply two n-digit integers scales as: Select one: a. n ^ 1.6 b. n ^ 2 c. n log n d. n ^3

b

The purpose of asymptotic notation is to suppress ------------- which are too system dependent. Select one: a. higher-order terms b. constant factors c. lower-order terms d. logarithmic terms

b

There is a particular problem where its solutions includes solving ksub-problems, but because of the repetition, straightforward solution solves m subproblems where m>k. Also, on average the work done to solve a single subproblem requires noperations. Then, in Dynamic Programming, the *space* complexity is Select one: a. None of the above b. Θ(k) c. Θ(kn) d. Θ(mn) e. Θ(m)

b

Trees are a special case of the graph, where the relationship between its number of vertices and edges are as follows: _____. a. |V| = |E| b. |E| = |V| - 1 c. |V| = |E| - 1 d. |E| = |V| + 1

b

A/an _____ is a circuit which does not have a repeated vertex except for the first and last. a. simple graph b. Euler path c. simple cycle d. simple path

c

ALGORITHM Enigma(A[0..n − 1, 0..n − 1]) for i ← 0 to n − 2 do for j ← i + 1 to n − 1 do if A[i, j] != A[j, i] return false return true What Enigma does? a. Check if matrix is Identity b. Calculate matrix determinant c. Check matrix symmetry d. Calculate matrix transpose

c

ALGORITHM MagicSort(A[0..n − 1]) for i ← 0 to n − 2 do min ← i for j ← i + 1 to n − 1 do ifA[j] < A[min] min ← j swap A[i] and A[min] what does magicSort does? a. Bubble Sort b. Quick Sort c. Selection Sort d. Insertion Sort

c

ALGORITHM MagicSort(A[0..n − 1]) for i ← 0 to n − 2 do for j ← 0 to n − 2 − i do ifA[j +1] < A[j] swap A[j] and A[j + 1] what does magicSort does? a. Insertion Sort b. Selection Sort c. Bubble Sort d. Quick Sort

c

According to Demorgan's laws: _____. Select one: a. A - (B INTERSECTION C) = (A - B) UNION (A - B) b. A - (B UNION C) = (C - B) INTERSECTION (C - A) c. A - (B UNION C) = (A - B) INTERSECTION (A - C) d. A - (A INTERSECTION C) = (A - B) UNION (A - C)

c

Function T(n) is -------------, if and only if there exist positive constants c , c , and n such that: c · f(n) ≤ T(n) ≤ c · f(n) for all n ≥ n0. Select one: a. big-O of f(n) b. big-omega of f(n) c. big-theta of f(n)

c

If p → q then ¬ q → ¬ p rep resen t it s - - - - - -. Select one: a. Inverse b. Converse c. Contra positive

c

In _____, the root is visited before the left and right subtrees. a. postorder traversal b. none of the above c. preorder traversal d. inorder traversa

c

In robot coin collection algorithm using dynamic programming for matrix with size NxM, optimal solution back-tracing can be done in _____. Select one: a. N^2 b. none of the above c. N+M d. N*M

c

In which of Dynamic Programming techniques, we need to recognize the dependencies of each sub-problem, as we want to topologically sort them: _____ Select one: a. Greedy Approach b. none of the above c. Bottom-Up d. Top-Down

c

Karatsuba multiplication is an algorithm for integer multiplication, and it uses a trick to use only ------------- recursive call(s). Select one: a. 1 b. 2 c. 3 d. 4

c

Number of elements in this set {0, 1}^n is _____. Select one: a. (2^n)/2 b. 2*n c. 2^n d. n^2

c

Since, recurrence for an algorithm made by the divide-and-conquer approach is T(n) = 2nT(n/2) + n^n , T(n) ∈ _____. Select one: a. O(n log n) b. O(n^n) c. Does not Apply/Not Applicable d. O(n)

c

Suppose that f (n) = O(g(n)). Which of the following is implied by this fact? Select one: a. g(n) = O(f(n)) b. Neither g(n) = Ω(f(n)) nor g(n) = O(f(n)) is true c. g(n) = Ω(f(n)) d. Both g(n) = Ω(f(n)) and g(n) = O(f(n)) are true

c

The Data structure used in standard implementation of Depth First Search is? a. Tree b. Queue c. Stack d. Linked List

c

the recurrence relation capturing the optimal execution time oof the toowers of hanoi problem with n discs is ................. a. T(n) = 2T(n/2) +1 b. T(n) = 2T(n - 1) + n c. T(n) = 2T(n - 1) + 1 d. T(n) = 2T(n - 2) + 2

c

2 finite sets have m and n elements respectively. the total number of subsets of first set is 112 more than the total number of the second set. The value of m and n respectively are.................... a. 2,5 b. 5,2 c. 4,7 d. 7.4

d

Assuming all the solutions yields the same correct solution, which would MOSTLY be the fastest Select one: a. Brute-Force b. Dynamic Programming c. Divide-and-Conquer d. Greedy Algorithms e. All are the same

d

Assuming y is a constant value in the below function Mysterious(n): if n <= 0: return y else: return Mysterious(n-1) + Mysterious(n-2) + Mysterious(n-3) Its time complexity T(n) is _____ Select one: a. O(n log n) b. none of the above c. Θ(n^10 ) d. Ω(n^10 )

d

Empirical analysis of an algorithm is the use of _____ to convey useful information about the algorithm. a. recurrence relations b. still or animated images c. a combination of natural language and programming language like code d. a program implementing the algorithm on sample inputs

d

Few instances of a problem would require easy and fast approach such as _____. a. None of the above b. divide and conquer c. dynamic programming d. brute force

d

How many cases are there under Master's theorem? Select one: a. 4 b. 2 c. 5 d. 3

d

If|A|=5 and|B|=8 and|A∪B|=11 what is the size of A∩B? _____. Select one: a. 24 b. 13 c. 3 d. 2

d

Suppose that f (n) = O(g(n)). Which of the following is implied by this fact? Select one: a. Both g(n) = Ω(f(n)) and g(n) = O(f(n)) are true b. Neither g(n) = Ω(f(n)) nor g(n) = O(f(n)) is true c. g(n) = O(f(n)) d. g(n) = Ω(f(n))

d

The Data structure used in standard implementation of Breadth First Search is? Select one: a. Linked List b. Stack c. Tree d. Queue

d

There is a particular problem where its solutions includes solving ksub-problems, but because of the repetition, straightforward solution solves m subproblems where m>k. Also, on average the work done to solve a single subproblem requires noperations. Then, in Dynamic Programming, the space complexity is _____ Select one: a. Θ(m) b. None of the above c. Θ(kn) d. Θ(k) e. Θ(mn)

d

Traveling salesman problem can be solved using exhaustive search approach which cost time of _____. a. n^2 b. n^3 c. 2^n d. n!

d

When Karatsuba algorithm is used to multiply two n-digit integers, it is of ------------ complexity. Select one: a. n ^ 1.6 b. n ^ 3 c. n log n d. n ^ 2

d

Which algorithm design technique tends to be ideally suited for parallel computations? a. Heuristic search approach b. Brute force approach c. None of the above d. Divide-and-conquer approach

d

Among elementary sorting methods, bubble sort is a great choice true false

false

Brute-Force algorithms have a common criteria of being effcient in time true false

false

Brute-force string matching algorithm in the worst case, makes m(n − m + 1) character comparisons, which denotes O(n^2). where n=text size and m=pattern size and m = pattern size true false

false

Dynamic Programming is efficient, and faster, because it doest not explore all the possible actions true false

false

Empirical Analysis is more accurate analysis for the algorithm true false

false

Greedy approach is guaranteed to yield a global optimal solution regardless of the greediness criteria. true false

false

In an undirected graph, if vertex u is adjacent to vertex v and vertex w is adjacent to vertex v then vertex w is adjacent to vertex u. true false

false

In inductive logic, when all squares are rectangles and All rectangles have four sides, it tells you that all squares have four sides. true false

false

Internal tree node is a node that has only one child. true false

false

Measuring algorithm efficiency in terms of running time (seconds) is an efficient measure and less sensitive to processor type. true false

false

The convex hull of a set S of points is the largest convex set containing S. true false

false

Theoretical Analysis is hardware dependent. true false

false

There are 6^5 different possible functions from {1,2,3,4,5,6} to {a, e, i, o, u} true false

false

Algorithm that determines whether all the elements in a given array are distinct or not is non-recursive algorithm that belongs to O(n^2). true false

true

Bubble sort algorithm compare adjacent elements of the list and exchange them if they are out of order. True False

true

Divide-and-Conquer explores all the possible actions to solve a problem recursively. true false

true

For a directed graph, the in-degree is the number of edges entering the vertex, and the out-degree is the number leaving it. true false

true

Graph search algorithms, like DFS and BFS, can be used to solve a large set of problems and applications, that might have nothing with graphs like simple games. true false

true

If S is a set and T is another set such that all the elements of T is contained in the set S then T is called a subset of the set S. true false

true

In functions, for every element in the domain, there is a uniquely defined element f(x) and for every element in f(x) it can be assigned to more than one element in the domain true false

true

O(g(n)) is the set of all functions t(n) with lower or same order of growth as g(n) true false

true

O(g(n)) is the set of all functions t(n) with lower or same order of growth as g(n). true false

true

Suppose that g(n) > 0 for all integers n. Then is f (n) = O(g(n)) equivalent to the following simpler definition that avoids n ? true false

true

Theoretical Analysis is done by inspecting the pseudo code, we can determine the maximum number of primitive/basic operations executed by the algorithm, as a function of the input size. true false

true


Kaugnay na mga set ng pag-aaral

Chapter Quiz: life insurance/annuities

View Set

Module 11: Real Estate Appraisal

View Set

Chapter 11 Financial Policies: Risk, Return and CAPM

View Set

Q&A: Placenta Abruption & Previa

View Set

Chapter 4: Interactive Presentation

View Set

There, There - People and Connections

View Set