CS 3303

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

A list is...

A finite ordered sequence of data times.

path compression

A method that is designed to create extremely shallow trees is called:

The upper bound for the growth of the Algorithms running time is represented by: A: Big Oh (O) B: Big Omega(Ω) C: Big Theta(Θ) D: Exponential Growth

A: Big Oh(O)

The upper bound for the growth of the algorithms running time is represented by: A: Big Oh(O) B: Big Omega (Ω) C: Big Theta (Θ) D: Exponential growth

A: Big Oh(O)

Select the answer that best defines Huffman Coding: (Or tell us what it is.)

An approach of assigning codes to characters such that the frequency of the code depends upon the relative frequency of the corresponding character in use.

In a stack which option would access the 3rd element from the top of the stack S Option 1. S.push(-1); Option 2. S.dequeue(-3); Option 3. S.pop(); S.pop(); S.pop(); Option 4. S.pop(n-3); Select one: a. Option 1 b. Option 2 c. Option 3 Correct d. Option 4

B. Option 3

Correctly identify the following heap structure by selecting the best answer: A: partially ordered heap B: max-heap structure C: priority heap D: min-heap structure

B: max-heap structure

If A={1, 2, 3, 4} and B={4, 5, 6}, find A∪ B . A: { x | x is all positive integers } B: {1,2,3,4,5,6} C: {1,2,3,4,4,5,6} D: {4}

B: {1, 2, 3, 4, 5, 6}

In linked lists there are no NULL links in: Select one: a. Single linked list b. Linear doubly linked list c. Circular linked list Correct d. None of these

C. Circular Linked List

A binary tree traversal that lists every node in the tree exactly once is called: A: a traversal B: a visitor design pattern C: an enumeration D: natural ordering sequence

C: an enumeration

A leaf is any node that... A: has one child B: is an internal node with no ancestors C: is any node with two empty children D: is the ancestor of the root node

C: is any node with two empty children

According to the properties of logarithms, log(nm) = A: a. log n - log m B: n log n C: log n + log m D: log(n^m)

C: log n + logm

Which of the following is not a mathematical proof technique? A: proof by mathematical induction B: proof by contradiction C. Direct proof D. proof by consensus

D. proof by consensus

Which of the following is not a characteristic of an algorithm? A: It must be correct. B: It must be composed of concrete steps. C: It can have no ambiguity. D: It must be composed of an infinite number of steps.

D: It must be composed of an infinite number of steps.

The freelist ... Select one: a. Provides access to memory within the operating system that has not yet been allocated b. Provides access to memory objects which have no Big O ( n ) time. c. Facilitates and encourages the use of the new operator. d. Holds the list nodes that are no longer in use.

D: holds the list nodes that are no longer in use

True/False: A list is said to be empty when all of its elements have a zero value.

FALSE

A full binary tree has a restricted shape which starts at the root and fills the tree by levels from left to right. true / false

False

A preorder traversal visits every node starting at the leaf nodes and works up the tree. True / False

False

Recursion is when an algorithm uses a series of loop structures to repeat an operation until the answer has been computed. True or false?

False

The full binary tree theorem states "the number of leaves in an empty full binary tree is one more than the number of internal nodes." True / False

False

True/False: A linked list implementation relies upon static memory allocation where static refers to the requirement to pre-allocate all of the memory that will be used for the list.

False

True/False: Inserting or removing an item at position n-1 within a linked list has the same cost in terms Q (n) time as the same operation in an array-based implementation of a list.

False

True/False: In a queue, placing new items in the queue is referred to as a push and taking an item out of the queue is called a pop.

False.

According to Shaffer, a heap data structure has two properties:

It is a complete binary tree AND...the values stored in it are partially ordered.

An important advantage of the sequential tree implementation is that

It saves space because there are no pointers.

A solution is said to be efficient if it:

It solves the problem within the required resource constraints.

For the following code fragment, select the most appropriate asymptotic analysis: // Towers of Hanoi static void solveHanoi(int disks, char fromPole, char toPole, char withPole) { if (disks >= 1) { solveHanoi(disks-1, fromPole, withPole, toPole); moveDisk(fromPole, toPole); solveHanoi(disks-1, withPole, toPole, fromPole); } } static void moveDisk(char fromPole, char toPole) { moves++; } Option 1. O( n ) Option 2. O( 2^n ) Option 3. O( n log n ) Option 4. O( n2 )

O( 2^n )

For the following code fragment, select the option that represents the most appropriate asymptotic analysis: // Recursive Fibonacci generator static long fibr(int n) { if ((n == 1) || (n == 2)) return 1; // Base case return fibr(n-1) + fibr(n-2); // Recursive call } Option 1. O( n ) Option 2. O( 2n ) Option 3. O( n log n ) Option 4. O( n2 ) Select one: a. Option 1 b. Option 2 Correct c. Option 3 d. Option 4

O( 2^n)

For the following code fragment, select option that represents the most appropriate asymptotic analysis: for (i=0; i<n; i++) { // // Search in array a for smallest element starting at i to n-1 // minIndex = findSmallestElement(a, i, n-1) a[i] = a[minIndex]; } findSmallestElement( int a[], int i, int n ) { int largest = a[i]; while(i<n) { if(a[i] >a[largest]) largest = i; i++; } return(largest); } Option 1. O( n ) Option 2. O( 2n ) Option 3. O( n log n ) Option 4. O( n2 )

O( n2 ) index-of-smallest element in a[i..j] takes j-i+1 operations • n + (n-1) + (n-2) + (n-3) + ... + 3 + 2 + 1 • this is n2

For the following code fragment, select the option that represents the most appropriate asymptotic analysis: if (a.length > 0) { return a[a.length - 1]; } else { throw new NoSuchElementException(); } Option 1. O( 1 ) Option 2. O( 2n ) Option 3. O( n log n ) Option 4. O( n2 )

O(1) Explanation: Here n = a.length, and T(n) = 1.

For the following code fragment, select the option that represents the most appropriate asymptotic analysis: for (int i = 1; i <= n; i *= 2) { for (int j = 0; j < n; j++) { count++; } } Option 1. O( 1 ) Option 2. O( 2n ) Option 3. O( n log n ) Option 4. O( n2 )

O(n log n) Explanation: Here the outer loop is done log n times and the inner loop is done n times, so T(n) = n log n. (Note that the default base for logarithms in Computer Science is 2.)

For the following code fragment, select the option that represents the most appropriate asymptotic analysis: for (int i = 0; i < a.length; i++) { System.out.println(a[i]); } A: O(n) B: O(2^n) C: O(n log n) D: O(n^2)

O(n)

Which of the following is NOT one of the design patterns mentioned in our text? Flyweight? Visitor? Composite? Synergy?

Synergy

Asymptotic Algorithm Analysis is primarily concerned with?

The growth rate demonstrated in the algorithm running time equation

The implementation of a data type as a data structure is the physical form of an ADT. True or false?

True

The process of visiting all of the nodes of a binary tree in some order is called a traversal. True / False

True

True/False: A linked list creates order through the use of pointers that link one element to another.

True

True/False: Big Theta (Θ) indicates that the Upper and Lower bounds of an algorithm are the same.

True

A finite set of one or more nodes such that there is one designated node call the root is a: (select the best answer)

a tree

A traversal of a general tree that traverses the roots subtrees from left to right, then visits the root is called a preorder traversal.

false

The most time-consuming operations on an array based list implementation is:

inserting a new element into the head of the list

An ADT is:

the realization of a data type as a software component.

A sequential tree can be represented using a bit vector?

true

A tree whose internal nodes all have exactly K children is called a K-ary tree. true / false

true

The list of children approach uses both pointers and an array structure to represent the tree.

true

The weighted union rule joins a tree with fewer nodes to a tree with more nodes by making the smaller tree's root point to the root of the larger tree.

true

The process of determining if two objects are in the same set and then merging those sets is called:

union / find

For the following code fragment, select the option that represents the most appropriate asymptotic analysis: public static int binarySearch(int[] a, int key) { int left = 0; int right = a.length-1; while (left <= right) { int mid = left + (right-left)/2; if (key < a[mid]) right = mid-1; else if (key > a[mid]) left = mid+1; else return mid; } //not found return -1; } Option 1. Ω( 1 ), O( log n ) Option 2. Ω( n ), O( 2n ) Option 3. Θ( n log n ) Option 4. Θ( log n )

Ω( 1 ), O( log n )


Set pelajaran terkait

Hesi Fundamental - Practice Questions

View Set

Mastering A&P Chapter 4 - Tissue: The Living Fabric

View Set

History Quiz 1 Unit 7 European early American Industrial revolution

View Set

Biology 160 - Chapter 5: Multiple Choice

View Set

Leadership Final Exam ch. 14, 19, 25, 6, 17, 5, 7, 27, 26, 31

View Set

Wound Care Pass Point + Oxygenation

View Set