Questions And Answers Already
Passed | Updated
A C++ class can have more than one constructor CORRECT ANSWERS true
In a preorder traversal of a binary tree, for each node, first the node is visited, then the
left tree subtree is visited, then the right subtree is visited CORRECT ANSWERS true
The general case in a recursive function is the case for which the solution is obtained
directly CORRECT ANSWERS false
The elements at the top of the stack have been in the stack the longest CORRECT
ANSWERS false
A linked list in which the last node points to the first node is called a circular linked list
CORRECT ANSWERS true
Every call to a recursive function requires the system to allocate memory for the local
variables and formal parameters CORRECT ANSWERS true
A doubly linked list is a linked list in which every node has a next pointer and a previous
pointer CORRECT ANSWERS true
In the analysis of algorithms, the key comparisons refer to comparing the key of the
search item with the position of an item in the list CORRECT ANSWERS false
You have analyzed a function and determined its runtime is characterized by E^n,
subscript i=1, i
what is the Big Oh for the analyzed code? CORRECT ANSWERS O(n^2)
What is the Big Oh best associated with the following code?
void donald(int n, int x, int y)
{
for (int i = 0; i < n; ++i)
{
if (x < y)
{
for (int j = 0; j < n + n; ++j)
cout << "j= " << j << endl;
} else
, cout << "i= " << i << endl;
}
} CORRECT ANSWERS O(n^2)
A data structure in which the elements are added and removed from one end only is
known as a__________ CORRECT ANSWERS stack
The sequential search is also called a _______________ search CORRECT
ANSWERS linear
Sequential and binary search algorithms are called _________ search algorithms
CORRECT ANSWERS comparison-based
A hash table has which two major components? CORRECT ANSWERS "bucket" array
and hash function
In quicksort, all the sorting work is done in _____________ the list CORRECT
ANSWERS partitioning
In heapsort, after we convert the array into a heap, the ______________ phase begins
CORRECT ANSWERS sorting
Problem: Inheritance
Given there exists a C++ class named Person (ie class Person {...}; is declared in file:
Person.h) Write the code to declare a class named Student that is derived from class
Person. Include the appropriate header file. Use the public specifier. You do NOT need
to have a "using namespace" line. CORRECT ANSWERS #include "Person.h"
class Student: public Person
{
}
Problem: Templates
Write a templated function named LessThanOrEqual. Which will take two parameters: a
and b (of the templated type) and return true if a <= b, else return false CORRECT
ANSWERS template <typename T>
T LessThanOrEqual (T a, T b)
{ return (a <= b ? a : b); }
Problem: Runtime for Data Structures
Data Structure: Ordered Array or Vector
Insert: ____________ CORRECT ANSWERS O(n)