CS 3330 FINAL

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Suppose that we have numbers between 1 and 100 in a binary search tree and want to search for the number 34. Which of the following sequences CANNOT be the sequence of nodes examined? 10, 56, 45, 18, 25, 31 89, 43, 10, 17, 37, 30 20, 56, 32, 37, 41, 18 42, 9, 11, 29, 39,35

20, 56, 32, 37, 41, 18

What is the dominant term in T (n) = n100 + 2^sq(𝑛) + 3n + 7? (a) n100 (b) 2^sq( 𝑛) (c) 3n (d) 7

2^sq( 𝑛)

If hash function is h(x) = x mod 7, then would be the key value of 13? 5 6 7 8

6

Selection-Sort

A sort algorithm that repeatedly scans for the smallest item in the list and swaps it with the element at the current index. The index is then incremented, and the process repeats until the last two elements are sorted.

Which of the following graph representation method is more space efficient? Adjacency list Adjacency matrix Sparse matrix

Adjacency list

Which of the following is the working principle of Stack data structure?( a) First in first out (FIFO) (b) Last in first out (LIFO) (c) Random Access (d) None of the above

Last in first out (LIFO)

Worst case of binary search algorithm is ..... O(n) O(logn) O(n^2) O(1)

O(logn)

If T (n) = n4 + 7n2 + 3n + 5, which of the following is true? (a) T (n) = O(n2) (b) T (n) = O(n3) (c) T (n) = Θ(n) (d) T (n) = Ω(n2)

T (n) = Ω(n2)

push

inserts an element

Heaps cannot be constructed in O(N) time. True False

False

Which of the following is the working principle of Queue data structure? (a) First in first out (FIFO) (b) Last in first out (LIFO) (c) Random Access (d) None of the above

First in first out (FIFO)

Which of the following is not true about Dijkstra's algorithm? It cannot handle negative edges It is a single source shortest path algorithm Its running time is O(|E|log|V|) It is a divide and conquer algorithm

It is a divide and conquer algorithm

The running time of Prim's algorithm when priority queues (binary heap) are used is ....... O(|V|2) O(|E|log|V|) O(|E|2) None of above

O(|E|log|V|)

In complexity analysis, we usually look at the worst-case of an algorithm True False

TRUE

Hashing is a technique used for performing insertions, deletions, and finds in constant average time. True False

True

dequeue

deletes an element at the front of the queue

enqueue

enters an element to the end of the queue

In hash tables, ......... is used to map objects with appropriate cells. index hash function pointer table

hash function

Which of the following structure is used to implement priority queues? heap hashing stack none of above

heap

Which of the following is not a standard function of Stack class? (a) pop() (b) push() (c) peek() (d) insertAt()

insertAt()

Postorder Traversal

left, right, root

Which of the following is not a common map ADT function? empty() find(k) put(k,v) erase(k) top()

top()

If the graph G is connected, its minimum spanning tree T contains ........ edges. |V| |V|-1 |V|-2 2|V|

|V|-1

If you were to choose a bank account with following balances, which account would be more beneficial in long term? (n is the number of days passed) (a) $1000000 × logn (b) $1000 × n (c) $10 × n2 (d) $1/1000 x 2n

$1/1000 x 2^n

Ω() notation gives the upper bound of run time of an algorithm True False

FALSE

A connected and weighted graph G always has exactly one minimum spanning tree. True False

False

Which of the following is a minimum spanning tree algorithm? Depth First Search Breadth First Search Kruskal's Algorithm Dijkstra's Algorithm

Kruskal's Algorithm

Inorder Traversal

left, root, right

............... is used if the hash table gets too full and running time for the operations will take too much time. splitting heap rehashing chaining

rehashing

pop

removes the last inserted element

Preorder Traversal

root, left, right

Inserting an element into a max-heap takes .... O(1) in best case and O(logn) in worst case O(1) in best case and O(n) in worst case O(logn) in best case and O(n) in worst case None of above

O(1) in best case and O(logn) in worst case

Worst case complexity of searching an element in Binary Search Tree (BST) is ... (a) O(logn) (b) O(n) (c) O(n3) (d) O(1)

O(n)

Running time of heap sort is ..... O(n) O(n^2) O(nlogn) O(n^3)

O(nlogn)

Pre-order tree traversal visits the root first True False

TRUE

Quick-Sort

1. If the list to be sorted is length 1, then finish 2. Pick an item within the list to act as a pivot. Usually left-most item. 3. Split list into two parts - one with items equal to or larger than the pivot and the other contains items smaller than the pivot 4. Repeat process on the two halves

Which of the following is the correct ranking of the functions listed below: logn, log^2n, n^3, 2^n, 234, n^2 logn < 234 < log2n< n2 < n3 < 2n 234 < logn <log2n < n2 < n3< 2n 234 < logn <2n<log2n < n2 < n3 234 < logn < n2 <log2n< n3 < 2n

234 < logn <log^2n < n^2 < n^3< 2^n

In the heap structure, which of the following gives the indexes of left and right child of ith element respectively? i+1, i+2 2i, 2i+1 2i+1, 2i 3i, 3i+1

2i, 2i+1

A binary search tree is generated by inserting in order the following integers: 13, 90, 21, 56, 19, 9, 27, 38, 10, 6 The number of nodes in the left subtree and right subtree of the root respectively is (4,5) (6,3) (3,6) (2,7)

3,6

For the following hash table with linear probing, which index (position) 4 is inserted if the hash function is h(x) =((x^2+1)mod7) Index of top of the table is 0 . 7 . 3 . 5 . ------------- 0 2 4 6

4

For the following hash table with double hashing, which index (position) 20 is inserted if the hash functions are ℎ1(x)=xmod8 and ℎ2(x)=7−(xmod7) Index of top of the table is 0 8 . 18 . 12 . . . ---------- 1 3 5 6

5

The height of the binary search tree is ................. if the following set of numbers are inserted to an empty binary search tree from left to right: 10, 9, 8, 7, 6, 4, 1, 0 Note: The height of a tree with a single node is 0 8 7 6 None of the above

7

Breadth First Search

An algorithm for traversing or searching a tree or graph data structures. It typically starts at the tree root and explores the neighbor nodes first, before moving to the next level neighbors.

Which of the following can be used to determine asymptotic lower bound (best case) of an algorithm ? Big - Omega Big - Theta Big - Oh Little - oh None of the above

Big - Omega

............. can compute the shortest path on an unweighted graph. Topological Sort Breadth First Search Depth First Search None of above

Breadth First Search

Merge-Sort

Divide and conquer (divide array in half and sort each half, then merge back together)

Which of the following would you do to identify time efficiency of an algorithm if theoretical methods are difficulty to apply? Experimental Time Analysis Correctness Analysis Space Efficiency Analysis None of above

Experimental Time Analysis

O() notation gives the lower bound of run time of an algorithm True False

FALSE

In AVL tree, the height difference of left and right child is always zero True False

False

Which of the tree traversal algorithms does visit elements on BST in ascending order? Pre-order In-order Post-order None of the above

In-order

Which of the tree traversal algorithms does visit elements on BST in ascending order? (a) Pre-order (b) In-order (c) Post-order (d) None of the above

In-order

Which of the following cannot be solved using Depth First Search (DFS) algorithm? Finding all articulation points in a connected graph Searching a node in a graph Detecting Euler Circuit in a directed graph Detecting whether a graph is strongly connected or not None of above

None of above

Which of the following is the correct Binary Search Tree (BST) if you add numbers to the tree from left to right order : 10, 15, 9, 3, 11, 25, 1, 17

None of the above

If you have several algorithms that do same job, which of the following considered as the best solution in terms of time complexity O(logn) O(nlogn) O(n) O(n3) O(n2)

O(logn)

Worst case complexity of insertion operation in heap is .......... O(n) O(1) O(logn) None of above

O(logn)

Worst case complexity of searching an element in AVL Tree is ... (a) O(logn) (b) O(n) (c) O(n3) (d) O(1)

O(logn)

Worst case complexity of searching an element in AVL Tree is .............. O(n) O(1) O(n2) O(logn)

O(logn)

Worst case complexity of adding new element to an index in Linked-list is ... (a) O(logn) (b) O(n) (c) O(n3) (d) O(1)

O(n)

What are the worst-case complexities of insertion and deletion of a key in a binary search tree? O(n) for both insertion and deletion O(logn) for both insertion and deletion O(n) for deletion, O(logn) for insertion None of the above

O(n) for both insertion and deletion

Running time of Breadth First Search is ............. as long as adjacency lists are used. O(|V|) O(|V|2) O(|V|+|E|) O(|E|)

O(|V|+|E|)

If exact running time of an algorithm is T(n)=7n^4 +n^3 + 2n^2+ 3n -5 where n is the input size, then which of the following is true? T(n)= O(n2) T(n)=Θ(3n) T(n)=Ω(n6) T(n)=O(n) T(n)=Θ (n4) None of above

T(n)=Θ (n^4)

Θ() notation gives the tight bound of run time of an algorithm True False

TRUE

The min element of the BST is always the left-most child True False

True

The min element of the BST is always the left-most child. True False

True

Depth First Search

Visits the child vertices before visiting the sibling vertices A stack is usually implemented

In hashing, ............... occurs when two keys hash to the same value. conflict overlap collision none of the above

collision

A directed acyclic graph has ................... cycles no cycles no weights no root

no cycles

Which of the following is not a part of a graph? vertices edges root None of above

root


Set pelajaran terkait

California Child Abuse Mandated Reporting

View Set

Principles of Management Ch 12 Quiz

View Set

Processing of Ceramics and Cermets

View Set

Human Resource Management - Exam 1

View Set

Chapter 11 (Project Analysis and Evaluation)

View Set