CSIT Final

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

A full binary tree of height n has _________________ leaves. a) 2^n b) 3n c) 2n d) 2(n+1) e) 3(n+1)

2^n

One method of implementing a tree using an array involves storing the child of the element at the index n in the array at indexes ______________________________ . a) n+1 and n+2 b) 2^n and 2^2n c) 2n+1 and 2n+2 d) n-1 and n-2 e) none of the above will work

2n+1 and 2n+2

Which of the following best describes a balanced tree? a) A balanced tree has all nodes at exactly the same level. b) A balanced tree has no nodes at exactly the same level. c) A balanced tree has half of the nodes at one level and half the nodes at another level. d) A balanced tree has all of the nodes within one level of each other. e) None of the above correctly describe a balanced tree.

A balanced tree has all of the nodes within one level of each other.

Of the classes below, the one that is most likely to be declared abstract is _________________. a) Bat b) Squirrel c) Animal d) Iguana e) Parrot

Animal

15. In a recursive solution, _______________ is(are) always necessary. a) Short, efficient coe. b) Several variables. c) Numerous lines of code. d) Base case.

Base case

Sort which orders a list of values by repetitively comparing neighboring elements and swapping their positions if necessary - scan the list, exchanging adjacent elements if they are not in relative order; this bubbles the highest value to the top - scan the list again, bubbling up the second highest value - repeat until all elements have been placed in their proper order

Bubble sort

A tree whose nodes represent decision points, and whose children represent the options available; the leaves represent the conclusions that might be draw. Ex Diagnosis

Decision tree

Tree that shows the relationships among operators and operands in an expression; evaluated from the bottom up.

Expression tree

What order do elements go in and out in a queue?

FIFO

Like trees, __________ are made up of nodes and the connections between those nodes.

Graphs

Suppose that Horse is a subclass of Animal, and neither class is abstract. Which of the following is an invalid declaration and initialization? a) Horse h = new Horse(); b) Horse h = new Animal(); c) Animal a = new Animal(); d) Animal a = new Horse(); e) all of the above are valid

Horse h = new Animal();

Lists whose elements can be referenced using a numeric index.

Indexed list

14. A solution with exponential complexity is ____________________ . a) Efficient. b) Inefficient. c) Easy to implement. d) Difficult to implement.

Inefficient

3. __________________ recursion results from the lack of a base case. a) Indirect b) Direct c) Infinite d) Spiral

Infinite

Which of the following traversals traverse the left subtree, then visit the root, then traverse the right subtree? (LVR) a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Inorder

Sort that orders a value by repetitively inserting a particular value into a sorted subset of the list. - consider the first item to be a sorted sublist of length 1 - insert the second item into the sorted sublist, shifting the first item if needed - insert the third item into the sorted sublist, shifting the other items as needed - repeat until all values have been inserted into their proper positions

Insertion sort

Consider the following code. *Animal a = new Dog(); a.wagTail();* Which of the following is true about this code? a) It will result in a compile-time error. b) It will result in a run-time error. c) It will call the speak method defined in the Animal interface. d) It will call the wagTail method defined in the Dog class. e) none of the above are true.

It will result in a compile-time error

Used to define a collection from which an iterator can be extracted.

Iterable

An object that provides a way to access each element in a collection in turn.

Iterator

Pseudocode for Postorder traversal:

LRV - Left, Right, Visit

Pseudocode for Inorder traversal:

LVR - Left, Visit, Right

Which of the following traversals is implemented using a queue as a supporting data structure? a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Level-order

Which of the following traversals is not easily implemented recursively? a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Level-order

Which of the following traversals visits the nodes that are closer to the top of the tree before visiting those that are closer to the bottom? a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Level-order

List composed of objects that each point to the next object in the list.

Linked list

Structure that uses object references to create links between objects; can be used to form non-linear structures.

Linked structure

What sort has a time complexity of O(n log n)? (Logarithmic sort)

Merge

Sort that orders values by recursively diving the list in hald until each sub-list has one element, then recombing - divide the list into two roughly equal parts - recursively divide each part in half, continuing until a part contains only one element - merge the two parts into one sorted list - continue to merge parts as the recursion unfolds

Merge sort

A spanning tree where the sum of the weights of the edges is less than or equal to the sum of the weights for any other spanning tree for the same graph

Minimal Spanning Tree

Which of the following is always true when adding an element to a heap? a) The new element will always be a leaf. b) The new element will always be the root. c) The new element will always be an internal node. d) The new element will always have 2 children. e) None of the above is always true

None of the above is always true

All Java classes are subclasses of the ___________________ class. a) String b) java.lang c) Java d) Class e) Object

Object

Lists whose elements are ordered by some inherent characteristic of the elements.

Ordered list

What are the 3 major types of list collections?

Ordered lists, Unordered lists, Indexed lists

Which of the following traversals visits the root *after* visiting the left and right subtrees? (LRV) a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Postorder

Which of the following tree traversals traverses the subtrees from left to right and then visits the root? a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Postorder

Which of the following traversals visits the root *before* visiting the left and right subtrees? (VLR) a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

Preorder

Sort that orders values by partitioning the list around one element, the sorting each partition. - choose one element in the list to be the partition element - organize the elements so that all elements less than the partition element are to the left and all greater are to the right - apply the quick sort algorithm (recursively) to both partitions

Quick sort

Sort that makes 3 passes through the data, for each position of 3-digit numbers - A value is put on the queue corresponding to that position's digit - Once all three passes are finished, the data is sorted in each queue

Radix sort

Sort that orders a list of values by repetitively putting a particular value into its final position. - find the smallest value in the list - switch it with the value in the first position - find the next smallest value in the list - switch it with the value in the second position - repeat until all values are in their proper places

Selection sort

What are some types of sorting algorithms?

Selection, Insertion, Bubble, Quick, Merge, Radix

Which sorts have a time complexity of (On^2)? (Quadratic sorts)

Selection, insertion, and bubble

The node to remove is a leaf; it can simply be deleted

Situation 1

The node to remove has one child; the deleted node is replace by the child

Situation 2

The node to remove has two children; an appropraite node is found lower in the tree and used to replace the node

Situation 3

7. Which of the following statements is true? a) Recursion should be used in every program. b) Recursion should be avoided all the time. c) Solutions that are easily expressed recursively should be programmed recursively. d) Solutions that are easily expressed recursively should be programmed iteratively.

Solutions that are easily expressed recursively should be programmed recursively.

The process of arranging a group of items into a defined order based on particular criteria

Sorting

8. Which of the following will usually result from infinite recursion? a) The program will hang as though there is an infinite loop. b) The program will not compile. c) The program will run out of memory. d) None of the above.

The program will run out of memory.

Consider the following code. *Animal spot = new Dog(); spot.speak();* Which of the following is true? a) This code will result in a compile-time error. b) This code will result in a run-time error. c) The speak method defined in the Animal class will be called. d) The speak method defined in the Dog class will be called. e) The speak method will not be called at all.

The speak method defined in the Dog class will be called.

A graph where the pairings representing the edges are unordered

Undirected graph

Lists whose elements have no inherent order but are ordered by their placement in the list.

Unordered list

Pseudocode for Preorder traversal:

VLR - Visit, Left, Right

The derived class created using inhertitance is called __________________. a. a child class b. a superclass c. a parent class d. all of the above e. neither a, b, nor c

a child class

A _______________________ class represents a generic concept in a class hierarchy. a) super b) abstract c) interface d) shadow e) generic

abstract

A graph that has no cycles

acyclic

The original class that is used to derive a new class using inheritance is called ____________________ . a. a superclass b. a parent class c. a base class d. all of the above e. neither a, b, nor c

all of the above

In Java, polymorphic method binding occurs ____________________ . a) at run time b) at compile time c) never d) when a programmer writes the code e) during the testing phase of software development

at run time

Search that eliminates large parts of the search pool with each comparison; compare target number to the middle value.

binary search

A tree that, for each node: - the left subtree of n contains elements less than the element stored in n - the right subtree of n contains elements greater than or equal to the element stored in n

binary search tree

The commitment to execute certain code to carry out a method invocation is referred to as _________________. a) execution b) binding c) polymorphism d) inheritance e) none of the above

binding

A class declared as final _________________________________ . a) cannot be changed. b) cannot have subclasses. c) cannot have superclasses. d) has several abstract methods. e) cannot be used in a program.

cannot have subclasses

A regular array that is treated as if it loops back around on itself.

circular array

A _______ is a path in which the first and last vertices are the same and none of the edges are repeated.

cycle

A _________________ can be used as the basis for an expert system. a) queue b) stack c) ternary tree d) 4-ary tree e) decision tree

decision tree

A binary search tree that is highly unbalanced is called a ________________ tree. a) full b) complete c) degenerate d) unsearchable e) none of the above

degenerate

Nodes that can be reached by following a parth from a particular node are the _______________ of that node.

descendants

Sometimes referred to as a digraph, is a graph where the edges are ordered pairs of vertices

directed graph

Which of the following key words indicates a new class is being derived from an existing class? a) super b) final c) extends d) inherits e) expands

extends

In a binary search tree, the elements in the right subtree of the root are __________________ the root element. a) greater than b) less than c) greater than or equal to d) less than or equal to e) equal to

greater than or equal to

A ____________________ is a complete binary tree in which each element is greater than or equal to both of its children. a) binary search tree b) stack c) full tree d) heap e) none of the above

heap

The __________ of a tree is the length of the longest path fro the root to a leaf

height

When designing a class hierarchy, it is important that common features be ________________________ . a) higher in the class hierarchy. b) lower in the class hierarchy. c) near the middle of the class hierarchy. d) in abstract classes. e) in the Object class.

higher in the class hierarchy

In order to create a class that implements an interface, the __________________ keyword is used. a) extends b) interfaces c) implements d) finalizes e) abstracts

implements

In Java, polymorphic references can be created through the use of __________________ and ________________. a) inheritance, interfaces b) inheritance, abstract classes c) interfaces, abstract classes d) interfaces, iterators e) none of the above

inheritance, interfaces

In Java, a(n) ___________________ is a collection of constants and abstract methods. a) polymorphic reference b) abstract class c) implementation d) interface e) iterator

interface

A node that is not the root and has at least one child

internal node

The process of inheritance should establish a(n) ____________________ relationship. a. is-a b. has-a c. static d. not-a e. none of the above

is-a

When adding a new element to a binary search tree, the element is added as a(n) ______________. a) internal node b) subtree c) leaf d) root e) none of the above

leaf

A node that has no children.

leaf node

Rotation that corrects an imbalance caused by a long path in the right subtree of the left child of the root - make the right child element of the root the new root element - make the former root element the left child element of the root - make

left rotation

Late binding is _______________ than _______________ . a) more efficient, compile-time binding b) less efficient, compile-time binding c) more efficient, run-time binding d) less efficient, run-time binding

less efficient, compile-time binding

In a binary search tree, the elements in the left subtree of the root are __________________ the root element. a) greater than b) less than c) greater than or equal to d) less than or equal to e) equal to

less than or equal to

The __________ of a node is the length of the path from the root to the node.

level

When removing an element from a binary search tree, we must always ______________________. a) make sure that the new tree is a binary search tree b) build a new tree c) find its inorder successor d) remove all of its children e) An element should never be removed from a binary search tree

make sure that the new tree is a binary search tree

What property of the tree does its order specify? a) maximum height b) maximum number of leaves c) maximum number of internal nodes d) maximum number of edges e) maximum number of children per node

maximum number of children per node

A polymorphic reference is one that can refer to _______________ type(s) of object(s). a) exactly one b) zero c) multiple d) abstract e) static

multiple

A _________________ is a nonlinear structure in which elements are organized into a hierarchy. a) binary b) ternary c) n-ary d) general e) graph

n-ary

A __________ can only have one parent, but may have multiple children. Those that have the same parents are siblings.

node

Which of the following traversals never visits the root? a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above

none of the above

A sequence of edges that connects two vertices in a graph

path

The _________ ___________ is the number of edges followed to get from the root to the node.

path length

In order for derived classed to have access to encapsulated data members and methods of superclasses, the data members and methods should be declared using the ____________________ modifier. a) private b) public c) protected d) final e) static

protected

A ________ is a collection whose elements are added on one end and removed from theother; FIFO - elements are removed in the same order they arrive. Ex. Checkout line

queue

A series of integers that determine how much each character is shifted.

repeating key

When removing an element from a binary search tree that has two children, _______________________ will ensure that the resulting tree is still a binary search tree. a) replacing it with its only child b) replacing it with its inorder successor c) simply deleting it d) all of the above e) neither a, b, nor c

replacing it with its inorder successor

When removing an element from a binary search tree that is a leaf, ______________ will ensure that the resulting tree is still a binary search tree. a) replacing it with its only child b) replacing it with its inorder successor c) simply deleting it d) all of the above e) neither a, b, nor c

replacing it with its only child

Rotation that corrects an imbalance caused by a long path in the left subtree of the left child of the root - make the left child element of the root the new root element - make the former root element the right child element of the new root - make the right child of what was the left child of the former root the new left child of the former root

right rotation

Operations on binary search trees to assist in the process of keeping a tree balanced

rotations

A _____________________ is a tree whose elements are organized to facilitate finding a particular element when needed. a) full tree b) complete tree c) binary tree d) search tree e) none of the above

search tree

A tree whose elements are organized to facilitate finding a particular element when needed.

search tree

The process of finding a target element among a group of items, or determing that it doesn't exist

searching

When a variable is declared in a subclass has the same name as a variable declared in a superclass, it is called a _______________ variable. a) final b) shadow c) static d) dead e) this is not allowed in Java

shadow

A tree that includes all of the vertices of a graph and some, but not possibly all, of the edges

spanning tree

A tree structure that makes up part of another tree

subtree

The special reference _________________ is used to refer to the parent class in a child class. a) this b) super c) null d) parent e) none of the above

super

To invoke a parents constructor in a subclass, we use the ______________ method. a) abstract b) construct c) parent d) super e) extends

super

If a subclasses constructor does not make an explicit call to a superclass's constructor, ______________________ . a) a run-time error will result. b) a compile-time error will result. c) the constructor will be called anyway. d) the class will be implicitly declared as abstract. e) none of the above

the constructor will be called anyway

In a maxheap, the largest element in the structure is always ______________________ . a) a leaf b) an internal node c) the root d) the left child of the root e) the right child of the root

the root

Which of the following methods are included in every class created in Java by inheritance? a) next b) toString c) compareTo d) charAt e) none of the above

toString

A _________________ is a non-linear structure in which elements are organized into a hierarchy. a) graph b) tree c) queue d) stack e) linked-list

tree

If a binary search tree becomes unbalanced after an element is added, it is sometimes possible to efficiently rebalance the tree by ___________________ . a) using left and right rotations b) selecting a leaf node to use as a new root c) reconstructing the tree from scratch d) all of the above e) it is impossible to rebalance a tree efficiently

using left and right rotations

Sometimes called a network, is a graph with weights (or costs) associated with each edge; undirected or directed

weighted graph


Kaugnay na mga set ng pag-aaral

Q/exp contains pharm Q gout **REVIEW** Practice week 5

View Set

Review Questions 2B 1-7 (Earth Science)

View Set

Pathopharmacology Endocrine Practice Questions

View Set

vocabulary workshop level H unit 8 answers

View Set

Week 10: Conflict Types and Conflict Management, Difficult Conversations

View Set

Comms Leadership; Chapter 5 Quiz

View Set

World Geography - South Asia Physical Features (NIHART)

View Set

Chapter 10: Infrastructure Security

View Set

Pharm III Exam practice questions from Saunders

View Set