Final Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A node that has no incoming arcs but from which every other node in the tree can be reached by following a unique sequence of consecutive arcs is called a(n)

root

A node that has no incoming arcs but from which every other node in the tree can be reached by following a unique sequence of consecutive arcs is called a(n) _____?

root

Keyword _____ introduces a structure declaration.

struct

Given a hash table with M = 13, and hash function h(k) = k mod 13, if collision happens the next three positions for K=21 under the Linear Probing is: 9, 10, 11

t

If T(n) <= 5000n3 for all n >= 100000, then T(n) is O(n3) (True or false)

t

Simple insertion sort performs better for partially sorted lists than for random lists. (True/False)

t

The C++ standard sort 0 algorithm uses quicksort.

t

The C++ standard sort 0 algorithm uses quicksort. True/False

t

The following function prototypes may be in the same library.char f(int x, int y); char f(int x, char y);

t

True or False: c[1] == 1

t

if t(n) less than or equal to 5000n^3 for all n greater or equal to 100000 then t(n) is o(n^4)

t

A nonrecursive function for computing some value may execute more rapidly than a recursive function that computes the same value. ( true or false)

true

For the following recursive function,int f( int n){ if ( n == 0)return 0;elsereturn n + f( n - 1);}infinite recursive calls happens with the function call f(-1).

true

In the early days of computing, which was more important?

space

Which data structure is used by the compiler to implement function calls?

stack

Which data structure is used by the compiler to implement recursion?

stack

The compiler supplies a default copy constructor that simply copies an object member by member (shallow copy). (True or false)

true

The following function prototypes may be in the same library. True/False char f(int x, int y); char f(int x, char y);

true

True or False: a.empty()

true

~C() is a prototype for the destructor of a class named C.(True or false)

true

Binary trees are trees in which each node has at most children.

two

The _____ rule selects the median of the first, middle, and last elements in each sublist as the pivot.

"Median of three"

Perform an inorder traversal of the above binary trees.

(1) 1 2 3 4 5 6 7 (2) 5 12 15 20 30 45 70

Perform a postorder traversal of the Q8 binary trees.

(1) 1 2 4 3 6 7 5 (2) 12 20 15 70 45 30 5

Perform a preorder traversal of the Q8 binary trees.

(1) 5 3 2 1 4 7 6 (2) 5 30 15 12 20 45 70

Name and describe the two parts of a recursive definition of a function

(1) An anchor or base case that specifies the value of the function for one or more values of the parameter(s). (2) An inductive or recursive step that defines the function's value for the current value of the parameter(s) in terms of previously defined function values and/or parameter values.

Convert the postfix expression a b - c - d * to infix notation.

(a - b - c) * d

Suppose cursor points to a node in a linked list (using the node definition with members called data and next). What Boolean expression will be true when cursor points to the tail node of the list?

(cursor->next == NULL)

If data is a circular array of CAPACITY elements, and last is an index into that array, what is the formula for the index after last?

(last + 1) % CAPACITY

Consider the following statements:int *p;int i;int k;i = 42;k = i;p = &i;After these statements, which of the following statements will change the value of i to 75?

*p = 75;

Which of the following operations can be used on a pointer variable in C++?

++

Describe the output produced by cout << d.front() << ' ', << d.back() &laquo; endl;

.88

Finish and test the following two functions append and merge in the skeleton file: (1) function int* append(int*,int,int*,int); which accepts two dynamic arrays and return a new array by appending the second array to the first array.(2) function int* merge(int*,int,int*,int); which accepts two sorted arrays and returns a new merged sorted array. #include <iostream>using namespace std;int* append(int*,int,int*,int);int* merge(int*,int,int*,int);void print(int*,int);int main(){ int a[] = {11,33,55,77,99}; int b[] = {22,44,66,88}; print(a,5); print(b,4); int* c = append(a,5,b,4); // c points to the appended array= print(c,9); int* d = merge(a,5,b,4); print(d,9); }void print(int* a, int n){ cout << "{" << a[0]; for (int i=1; i<n; i++) cout << "," << a[i]; cout << "}\n"; }int* append(int* a, int m, int* b, int n){ // write your codes in the text fields}int* merge(int* a, int m, int* b, int n){// write your codes in the text fields}

// Function Definition// (1) function int* append(int*,int,int*,int);// which accepts two dynamic arrays and return a new array by// appending the second array to the first array.int* append(int* a, int m, int* b, int n){int len = m + n;int* u = new int[len];int i = 0, x = 0;for (i = 0; i < m; i++)u[x++] = a[i];for (i = 0; i < n; i++)u[x++] = b[i]; return u; } // Function Definition// (2) function int* merge(int*,int,int*,int);// which accepts two sorted arrays and returns a new merged sorted array.int* merge(int* a, int m, int* b, int n){int i = 0, x = 0, y = 0;int len = m + n;int* c = new int[len]; while (i < m && x < n){if (a[i] < b[x]){c[y++] = a[i++];}else{c[y++] = b[x++];}} while (i < m)c[y++] = a[i++]; while (x < n)c[y++] = b[x++]; return c;}

For the following recursive function, find f(0)= int f( int n){ if ( n == 0)return 0;elsereturn n + f( n - 1);}

0

d.begin() returns an iterator positioned at _______ in d.

0

Describe the output produced by d. pop_back() ; for (int i = 0; i < d.size(); i++) cout << d[i] << ' ';

0000077

What is a hash function?

A function that computes the location of the key in the array

Describe the divide-and-conquer approach to problem-solving.

A problem is repeatedly partitioned into simpler subproblems, each of which can be considered independently, continuing until subproblems are obtained that are sufficiently simple that they can be solved (ie., conquered).

Define queue as an ADT.

A sequence of data items that can be removed only at one end, called the front, and can be added only at the other end, called the back. Basic operations are: construct an empty queue, check if queue is empty, add a value at the back, retrieve the front value, and remove the front value.

What is a hash table?

A structure that maps keys to values

Mergesort makes two recursive calls. Which statement is true after these recursive calls finish, but before the merge step?

Elements in each half of the array are sorted amongst themselves.

Which sorting algorithm is best when the input is sorted or nearly sorted?

Insertion sort

Which sorting algorithm is best when we need to minimize the number of record swaps? It is sort.

Selection

Which sorting algorithm is best when we need to minimize the number or record swaps?

Selection sort

STL is an acronym for

Standard Template Library

What are some of the ways in which student programs differ from real-world software?

Student programs are smaller in size vs real world programs. Real world programs are also integrated with other software while the student's program is standalone. The errors and lifetime maintenance is also different. The errors don't have a serious consequence because it is not a real world situation while those problems can cost lives in the real world. The errors can also be found easily because the programs are so small. The lifetime/maintenance is short and low when compared to the real world programs which are large and require lots of work.

If a class contains a pointer to dynamically allocated memory, which of the following defaults is likely to be unacceptable?

all of the above

d.end() returns an iterator positioned _______ in d.

behind 88

A(n) is a binary digit; a(n) is a group of eight binary digits.

bit, byte

If T(n) > 5000n3 for all n < 100000, then T(n) cannot be O(n3). (True or false)

f

If the computing time of an algorithm is O(2^n), it should perform acceptably for most large inputs. (True or false)

f

Most of the STL algorithms operate on specific containers.

f

Simple selection sort performs better for partially sorted lists than for random lists. (True/False)

f

Using the first list element as pivot works well for partially-sorted lists.

f

Using the fist list element as pivot works well for partially-sorted lists. (True/False)

f

n-2 *2n/1000 + 100n100 + 250 = O(n100)

f

One of the strengths of linked lists is direct access to each node. True/False

false

One of the strengths of linked lists is to access to each element faster than array. (True or false)

false

Protected inheritance is the most common kind of inheritance. True or False

false

Recursion usually make your code faster.

false

Recursion usually use less memory.

false

The array-based implementation of a list works well for lists with many insertions and deletions. (True or false)

false

The following function prototypes may be in the same library. True/False int f(int x, int y); char f(int x, int y);

false

The following function prototypes may be in the same library.int f(int x, int y); char f(int x, int y);

false

Ture or False: c < d

false

The last element added to a stack is the _______one removed. This behavior is known as maintaining the elements in ________ order.

first, LIFO (last-in-first-out)

In a(n) hash table, the location of an item is determined directly by applying a function to the item. The function is called a(n) function.

hash

In a(n) ______ , the location of an item is determined directly by applying a function to the item. The function is called a(n) ______function.

hash table, hash

In a Binary Search Tree, the largest element must

have at most one child.

A class declaration is usually put in a(n) ___ file whose name has the form ClassName.h.

header

The problem of dynamically-allocated memory getting marooned is called a memory ______

leak

Nodes with no outgoing arcs are called

leaves

What term is used to describe an O(n) algorithm.

linear

Given an array and a linked list, which of these data structures uses more memory space to store the same number of elements? Explain your answer.

linked list

The worst case computing time of binary search is O( ).

log n

Which phase of the software life-cycle is usually the most expensive?

maintenance

In the floating-point representation 1.011 x 25, 1.011 is called the _____

mantissa

Stack s; s.push(111); i = s.top(); s.push(222); s.pop(); s.push(i);

myTop = 1; myArray[O] =111,myArray[1] =111; other elements are undefined

Stack s; for (int i = 0; i < 5; i++) s. push (2*i) ; s.pop(); s.pop();

myTop = 2; myArray[O] = 0, myArray[l] = 2, myArray[2] = 4, myArray[3] =6, myArray[4] =8

Assume that Stack is the class described in this section with StackElement set to int and STACK_CAPACITY or myCapacity set to 5. Give the value of myTop and the contents of the array referred to by myArray in the stack s after the code segment is executed, or indicate why an error occurs. If: Stack s; s.push(123); s.push(456); s.pop(); s.push (789) ; s.pop();

myTop =0; myArray [0] =123, myArray [1] =789; other elements are undefined

Which of the following functions grows fastest?

n log n

Which of the following functions grows fastest?

n^2

The worst-case complexity of quicksort is O (_____), and the average-case complexity is O(_____).

n^2, nlogn

The operation for removing an entry from a stack is traditionally called:

pop

Which of the following stack operations could result in stack underflow?

pop

Describe the output produced by cout << c.front() << ' ', << c.back() &laquo;'endl;

1 1

Describe the output produced by for (int i = 0; i < c.size(); i++) cout << c[i] << ' ';

1 1 1 1 1

Given a hash table with M = 13, and hash function h(k) = k mod 13, state the hash position and the first three positions for K = 21 under the following collision resolution policies: Linear Probing chaining

1) 8, 9, 10, 11 2) 8, 8, 8, 8 (in a linked list pointed from 8)

At most, how many comparisons are required to search a sorted vector of 1023 elements using the binary search algorithm?

10

Assume that each value of type int is stored in 4 bytes, if an array is declared as "int t[10];" and the base address of this array is 100. What is the address of t[2]?

108

For the following recursive function, find f( 5)= int f( int n){ if ( n == 0)return 0; else return n + f( n - 1);}

15

For the following recursive function, int f( int n) { if ( n == 0) return 0; else return n + f( n - 1); } Find f( 5) Find f( 0) What happens with the function call f(-1)? Does the recursive version usually use less memory? Is the recursive version usually faster? Then why use recursion?

15 0 Infinite recursive calls No-- it usually uses more memory (for the stack). No-- it's usually slower (due to the overhead of maintaining the stack) Sometimes it is much simpler to write the recursive version (but we'll need to wait until we've discussed trees to see really good examples...)

If d's capacity must increase, it will become _______.

20

An algorithm that requires __________ operations to complete its task on n data elements is said to have a linear runtime.

2n + 1

An integer stack S is initially empty, then, the following commands are performed.S.push(10);S.push(8);S.pop();S.push(3);S.push(5);S.pop();Which of the following is the correct stack after the commands (assume the top of the stack is on the left).

3 10

Consider the following function:void test_a(int n){cout << n << " ";if (n>0)test_a(n-2);}What is printed by the call test_a(4)?

4 2 0

The value of 5 4 - 3 2 + * is ______

5

The following items are inserted into a binary search tree in this order: 8, 4, 3, 2, 5, 9, 6, 1, 7. Which item is placed at a root?

8

What can be the techniques to avoid collision?

All of the mentioned

Please select the best answer. A class is an initialized object variable. An object is an extension of the class construct whose default access privilege is public. An object is an initialized class variable. The term object is just another way of referring to the public data members of a class.

An object is an initialized class variable.

Which of the following is not a dynamic data structure?

Array.

What is the difference i C++ between class and struct?

Class is more of a cookie cutter or blueprint for objects using the definition of the data and methods within the class. The struct is a datatype and it holds data of various types. The main difference between a class and a struct are the default accessibility of their member variables and methods. The structs have default public access while the class is defaulted to private. A class also contains methods / functions as well. Classes also have the constructor and destructor to create and destroy objects.

Which of the following is not an advantage of linked lists when compared to arrays:

Direct access to any list element

In simple chaining, what data structure is appropriate?

Doubly linked list

Name and define the three fundamental concepts of object-oriented programming.

Encapsulation: Wrapping the data and basic operations used for processing this data within a single entity. Inheritance: A class can be derived from another class, and this derived class then inherits the members of the parent class. Polymorphism(by default, it asks about function overriding): The property of a derived class D and an ancestor class A having a function member with the same prototype, but that behaves differently for A objects than for D objects.

Members of different structures must have unique names.

False

Simple selection sort performs better for partially sorted lists than for random lists.

False

When an ADT is implemented as a C++ class, which of the following should normally be true?

Function members are public, data members are private

Consider storing the names: George, Amy, Alan, and Sandy in a hashtable of size 10, using the hash function: hash(name) = sum of characters mod 10 where a=A=1, b=B=2, etc. Draw the hashtable that would be produced.

Here is the result of the hash function: Name Sum of Characters hash(name) George 57 7 Amy 39 9 Alan 28 8 Sandy 63 3 and the hash table, after all the stores is: 0 1 2 3 4 5 6 7 8 9 Sandy George Alan Amy

If, in the example above, Mammal overrides a function in Animal, which does Dog get, the original or the overridden function?

If Dog inherits from Mammal, it gets the function in the state Mammal has it: the overridden function.

What is the linear probing?

If a collision occurs at index i, examine the locations i + 1, i + 2, i + 3, .... with all operations done modulo the table size, continuing until an empty slot is found where the item can be stored.

When we define and implement operator overloading in C++:

It may or may not be a class member.

Linear search is highly inefficient compared to binary search when dealing with:

Large, sorted arrays.

Describe how selection sorts work.

Make a number of passes through the list or a part of the list, and on each pass, select one element (smallest) to be correctly positioned.

If a node has no successor, its link is set to a special ______ value.

NULL

The following routine violates which rule(s) of recursion? bool recurse( int n ) { if ( n ==1) return recurse(1); else return recurse( n-1)+ n; }

No valid base case

The elements of a linked list are called ________.

Nodes

For the array implementation of the stack, what is the worst-case cost of a single push operation if array doubling is used to increase the capacity?

O( n )

The worst-case runtime complexity of building a balanced BST with n nodes

O(n * log n)

What is the worst-case time for mergesort to sort an array of n elements?

O(n log n)

The height of a Binary Search Tree with n nodes in the worse case is

O(n)

The worst-case runtime complexity of insertion into a BST with n nodes is

O(n)

What are the best, average, and worst-case asymptotic costs for Mergesort?

O(n*log n) for best, average, and worst cases.

Which of the following represented the efficiency of the insertion sort? O(1) O(log n) O(n) O(n^2)

O(n^2)

Which of the following represents the efficiency of the insertion sort?

O(n^2)

Declare and define a class Person in C++ syntax to model the given item - a person with the following features: Define the private portion of the class Person for people consisting of an integer for ID and a char pointer to a dynamic array for name. Define functions below to the Person class and implement these functions: Person(); // default constructor for a person named "Anonymous" and ID is 123456789Person(char name[], int id); // constructor to initialize the name and ID int get_id() const; // accessor to retrieve student's IDvoid set_name(char new_name[]); // mutator to set or change student's name overload output operator << to print the Person information in the format: Person's name (Person's ID), e.g. Anonymous (987654321)//destructor;//copy constructor;

Person Class: class Person{public: Person();Person(char[], int);Person(const Person&);Person& operator=(const Person&);int get_id() const;void set_name(char[]);friend ostream& operator<<(ostream&, const Person&);~Person(); private:int ID;char* Name;}; Person::Person(){Name = new char[strlen("Anonymous") + 1];strcpy(Name, "Anonymous");ID = 123456789;} Person::Person(char name[], int id){Name = new char[strlen(name) + 1];strcpy(Name, name);ID = id;} Person::~Person() { delete[] Name; }; Person& Person::operator=(const Person& x){Name = new char[strlen(x.Name) + 1];strcpy(Name, x.Name);ID = x.ID;return *this;} Person::Person(const Person& y){Name = new char[strlen(y.Name) + 1];strcpy(Name, y.Name);ID = y.ID;} int Person::get_id() const{ return ID; } void Person::set_name(char new_name[]){Name = new char[strlen(new_name) + 1];strcpy(Name, new_name);} ostream& operator<<(ostream& out, const Person& p){out << p.Name << "(" << p.ID << ")";return out;}

In what way is object-oriented analysis and design fundamentally different from other approaches? Answer

Prior to the development of these object-oriented techniques, analysts and programmers tended to think of programs as functions that acted on data. Object-oriented programming focuses on the integrated data and functionality as discrete units that have both knowledge (data) and capabilities (functions). Procedural programs, on the other hand, focus on functions and how they act on data. It has been said that Pascal and C programs are collections of procedures and C++ programs are collections of classes.

What is the difference between object-oriented programming and procedural programming?

Procedural programming focuses on functions separate from data. Object-oriented programming ties data and functionality together into objects, and focuses on the interaction among the objects.

Which data structure represents a waiting line and limits insertions to be made at the back of the data structure and limits removals to be made from the front?

Queue.

_______ is the phenomenon of a function calling itself.

Recursion

Describe how insertion sorts work.

Repeatedly insert a new element into a list of already sorted elements so that the resulting list is still sorted

Which of the following uses the balanced binary search tree to implement?

STL map

Describe how quicksort uses a dive-and-conquer sorting strategy.

Select an element, cal1ed a pivot, and then perform a sequence of exchanges so that al1 elements that are less than or equal to this pivot are to its left and al1 elements that are greater than the pivot are to its right. This correctly positions the pivot and divides the (sub)list into two smaller sublists, each of which may then be sorted independently in the same way.

When is insertion sort a good choice for sorting an array?

The array has only a few items out of place.

What is the best definition of a collision in a hash table?

Two entries with different keys have the same exact hash value.

A chained hash table has an array size of 512. What is the maximum number of entries that can be placed in the table?

There is no maximum

Define what it means to write T(n) is O(f(n)).

There is some constant C such that T(n)< Cf(n) for sufficiently large values of n

Why should data members of a class be private?

This is used to help encapsulate your program aka hide your data. This will prevent manipulation of the data from an outsider that should not have access to your data. If there are errors or something goes wrong you know where to look - aka the functions that have access to your data members. If they were public then the data could be accessed anywhere which could cause havoc on your program.

What is the primary purpose of template functions? To allow a single function to be used with varying types of arguments To hide the name of the function from the linker (preventing duplicate symbols) To implement container classes To permit the use of the debugger

To allow a single function to be used with varying types of arguments

The linear probing is that if a collision occurs at index i, examine the locations i + 1, i + 2, i + 3, .... with all operations done modulo the table size, continuing until an empty slot is found where the item can be stored.

True

Let S be a set of n integers. One can create a data structure for S so that determining whether an integer x belongs to S can be performed in O(1) time in the worst case. (true or false and justify

True, Using hashing.

Are inherited members and functions passed along to subsequent generations? If Dog derives from Mammal, and Mammal derives from Animal, does Dog inherit Animal's functions and data? Answer

Yes. As derivation continues, derived classes inherit the sum of all the functions and data in all their base classes.

An algorithm is a. a standalone function that operates on containers. b. a link between member functions and containers. c. a friend function of a container class. d. a member function of a container class.

a

Given an empty queue Q, what does it look like after the following operations? Q.enqueue(5) Q.enqueue(2) Q.dequeue() Q.enqueue(3) Q.dequeue() a. 3 b. 5 c. 9 d. none of the above

a

Pick the false completion: Stacks and queues a. include time stamps on data elements so that they know what was added when. b. are called linear data structures. c. require just three methods each for adding, removing and peeking. d. force data to be added to and removed from particular ends of the data structure.

a

Inheritance allows you to start with ___________ and derive ___________ from it,which will share common characteristics with it. a. a class, objects b. an object, classes c. a member function, other member functions d. a class, other classes

a class, other classes

An algorithm is

a standalone function that operates on containers.

What is direct addressing?

a) Distinct array position for every possible key

Assume the declarations and that double values are stored in 8 bytes of memory.double * x, y = 1.1;The value of &y will be a(n) _____

address

A program that uses the STL algorithms must contain the directive #include

algorithm

The Standard Template Library contains more than 80 function templates known as generic

algorithms

The Standard Template Library contains more than 80 function templates known as generic _______.

algorithms

In the linked list implementation of the stack class, where does the push member function place the new entry on the linked list?

at the head

In the linked list implementation of the queue class, where does the push member function place the new entry on the linked list?

at the tail

Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

bag<int> b;

Given a 5 element stack S (from top to bottom: 2, 4, 6, 8, 10), and an empty queue Q, remove the elements one-by-one from S and insert them into Q, then remove them one-by-one from Q and re-insert them into S. S now looks like (from top to bottom). a. 2, 4, 6, 8, 10 b. 10, 2, 4, 6, 8 c. 10, 8, 6, 4, 2 d. none of the above

c

A collision strategy in which the hash table is an array or vector of linked lists that store the items is known as

chaining

A collision strategy in which the hash table is an array or vector of linked lists that store the items is known as _______.

chaining

In the tree structure, nodes that are directly accessible from a given node (by using only one directed arc) are called the of that node.

children

Nodes that are directly accessible from a given node (by using only one directed arc) are called the _____ of that node, which is said to be the of _____ these nodes.

children, parent

If several elements are competing for the same bucket in the hash table, what is it called?

collision

The case of two items needing to be placed at the same location in hash table is called a(n)

collision

The case of two items needing to be placed at the same location in the hash table is called a(n) _______.

collision

An iterator over a TreeSet object returns the items in insertion order comparable order random order preorder of the tree

comparable order

The keyword ___ specifies that an object or variable is not modifiable after it is initialized.

const

Suppose that f is a function with a prototype like this:void f(________ head_ptr);// Precondition: head_ptr is a head pointer for a linked list.// Postcondition: The function f has done some computation with// the linked list, but the list itself is unchanged.What is the best data type for head_ptr in this function?

const node*

Suppose cursor points to a node in a linked list (using the node definition with members called data and next). What statement changes cursor so that it points to the next node?

cursor = cursor->next;

An iterator a. acts something like a function. b. cannot step backward through a container. c. always executes the same algorithm over and over. d. points to a specific object in a container.

d

Each element in a linked list has two parts: a(n) _______ part and a(n) _______ part.

data, next

Suppose we have a circular array implementation of the queue class, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the push member function place the new entry in the array?

data[12]

In a software life cycle, what is produced just after the specification phase?

design

When an object's lifetime is over, the object's ______ is called automatically.

destructor

provide the interface between STL algorithms and STL containers.

iterators

Suppose you have the following function prototype and variable declaration:void foo(int z[ ]);int x[10];Which is the correct way to call the foo function with x as the argument:

foo(x);

Write TWO different but equivalent statements to do the same thing: use a "for statement" to print the elements of array int a[10] by using pointer int * ptr

for(int i = 0; i < 10; i++) { cout << *ptr << endl; ptr++; } for(int i = 0; i < 10; i++) { ptr = &a[i]; cout << *ptr << endl; }

Unlike C's structs, C++ structs and classes can contain both data members and ____ members.

function

An iterator

points to a specific object in a container.

A derived class ______ the members of the parent class.

inherits

Which sorting algorithm is best when the input is sorted or nearly sorted? It is sort.

insertion

Linked lists allow

insertions and removals anywhere

The process of constructing a function from a function template or a class from a class template is called _______

instantiation

Assume that the following statements have been executed: vector<int> a, b(5), c(5, 1), d(5); d.push_back(77); d.push_back(88); The type of values stored in a is ________. The capacity of a is _____ and its size is _____. The capacity of b is _____ and its size is _____. The capacity of c is _____ and its size is _____. The capacity of d is _____ and its size is _____.

int 0,0 5,5 5,5 10,7

Compare the C-string in s1 with the C-string in s2, and print the result of the comparison.

int cmp(char*s1, char* s2) { while(*s1) { if (*s1 != *s2) { break; s1++; s2++; } } return *s1 - *s2; }

For the declarations below, which expression is FALSE if it1 and it2 refer to the same object?vector::iterator it1, it2;......

it1 == *it2

In the array based implementation of a stack, which has size n, the pop operation has computing times.

o(1)

What is the search complexity in direct addressing?

o(1)

In the array based implementation of a list, which has size n, insertion in the worst case has computing time

o(n)

The worst-case runtime complexity of a postorder traversal of a BST with n nodes

o(n)

Which of the following formulas in big-O notation best represent the expression n^2+35n+6?

o(n^2)

Which of these is the correct big-O expression for 1+2+3+...+n?

o(n^2)

Iterators are

objects that support uniform access to elements in different STL containers

Iterators are only positioned at the beginning or end of a container counters for arrays objects that support uniform access to elements in different STL containers only used by STL vector and STL list containers.

objects that support uniform access to elements in different STL containers

When you design a program for an object-oriented language, you look first for_________ in real life that will correspond to __________ in the program. a.organizations, data types b.information, data c.things, objects d.actions, functions

organizations, data types

An STL container can be used to

organize the way objects are stored in memory

A name that is used for different functions is said to be

overloaded

A name that is used for different functions is said to be _______.

overloaded

The item properly positioned on each call to a quick sort is called a(n) ______.

pivot

The item properly positioned on each call to quicksort is called a(n) ______.

pivot

Class members specified as ___ are accessible only to member functions of the class and friends of the class.

private

Class members specified as ___ are accessible anywhere an object of the class is in scope.

public

The operation for adding an entry to a stack is traditionally called:

push

is the phenomenon of a function calling itself.

recursion

make it possible for classes and functions to receive not only data values to be stored or operated on via parameters but also to receive the type of data via a parameter.

templates

A deep copy refers to

the duplicates of pointees

A deep copy refers to the copying of basic types, such as integers the copying of big objects the duplicates of pointers. the duplicates of pointees

the duplicates of pointees

A class may contain multiple constructors if

they have different argument lists.

In most current applications, which is the most important?

time

What two criteria are usually used to measure an algorithm's efficiency?

time and space

List two criteria that are usually used to measure an algorithm's efficiency: and .

time, space

timePtr is a pointer to an object mealTime of class Time (i.e. Time * timePtr;) with data member myHours in the class. Which of the following is equivalent to myHours?

timePtr->myHours

Write the function swap which swaps the integer values pointed at by its two parameters. (4 lines of code)

void swap(int a, int b) { int tmp = a; a = b; b = temp;}

A popular model of software development in which the phases are carried out sequentially, moving from one phase to the next, is known as the____ model.

waterfall

Suppose you have the following function prototype and variable declaration:void foo(int z[ ]);int x[10];Suppose that this foo function changes the value of z[1]. Does this change effect the value of the actual argument?

yes


संबंधित स्टडी सेट्स

Chapter 4 Choosing A Form of Business Ownership

View Set

HEALTH ASSESSMENT MIDTERM MOCK REVIEW/TEST

View Set

(UNIT 3 - FUNCTIONS) Algebra 1 exam prep

View Set