CSCI-203

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

Suppose cursor points to a node in a lined list ( using the node definition with member functions called data and link). What boolean expression will be true when cursor points to the tail node of the list? Please write out first.

(cursor -> link() == 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

Precondition

A statement giving the condition that is required to be true when a function is called.

Postcondition

A statement saying what will be true when a function is completed. If the function is correct and the precondition is true then the function will complete. The result will be true function call being completed.

The operation for removing an entry from a stack is traditionally

pop

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

pop

What is the minimum number of nodes in a full binary treee with depth 3?

15

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a squence that contains 2 left parentheses and 3 right parentheses ( in some order). What is the maximum numver of parentheses that will ever appear on the stack AT ONE TIME during the computation? Please show work

2

How many recursive calls usually occour in the implementation of the tree_clear function for a binary tree?

2

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: ( ( ) ( ( ) ) ) ( ( ) ) ) Please show work

3

Suppose T is a binary tree with 14 node nodes. What is the minimum possible depth of T?

3

What is the minimum number of nodes in a complete binary tree with the depth of 3?

8

What will happen if a function is executed and the precondition for the function is not met?

An error message will be printed The program will loop indefinitely The system will crash Answer: Any of the above results could happen

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

At the tail

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers wll change during an insertion into an EMPTY queue?

Both change

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

DCBA first in first out

suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through data[9]. The CAPACITY is 42. Where does the push member function place the new entry in the array.

Data[10]

Select the one FALSE statement about binary trees: Every binary tree has at least one node Every non-empty tree has exactly one root node Every node has at most two children Every non-root node has exactly one parent

Every binary tree has at least one node

Select the one true statement Every binary tree is either complete or full Every complete binary tree is also a full binary tree Every full binary tree is also a complete binary tree No binary tree is both complete and full

Every binary tree has atleast one node

Answer True or False: For all possible inputs, a linear algorithm to solve a problem must perform faster than a quadratic algorithm to solve the same problem.

FALSE

Answer true or False: for this statement: An algorithm with the worst case time behavior of 3n takes at least 30 operations for every input of size n=10.

FALSE

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

Linear

What kind of list is best to answer questions such as " What is the item at poistion n?"

Lists implemented with an array

What technique is often used to prove the correctness of a recursive function?

Mathematical induction

Express the formula (n-2)*(n-4) using Big-O notation:

None of the above the answer would be O(n^2)

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

O(n^2)

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

O(n^2)

Why does our node class have two versions of the link member function?

One is to use with a const ponter, the other with a regular pointer.

One difference between a queue and a stack is :

Queues use two ends of the structure; stacks use only one

Tree algorithms typically run in time O(d). What is d?

The depth of a tree

Enteries in a stack are " ordered". What is the meaning of this statement?

There is a first entry, a second entry, and so on.

Suppose cursor points to a node in a lined list (using the node definition with member functions called data and link). What statement changes cursor so that it points to the next node? (Please write it down first)

cursor = cursor ->link();

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]

Consider the node of a complete binary tree whose value is stored in data[i] for an array implementation. If this node has a right child, where will the right child's value be stored?

data[2*i +2]

In the linked-list version of the queue class, which operations require linear time for their worst-case behavior?

front push empty None of these operations require linear time

In the circular array version of the queue class (with a fixed-sized array), which operations require linear time for their worst-case behavior?

front push empty Answer: None of these operations

In the array version of the stack class ( with a fixed -sized array), which operations require linear time for their worse-case behavior?

is_empty peek pop push Answer: None of these operations require linear time

I have implemented the queue with a linked list, keeping track of a front pointer and a rar pointer. which of these pointers will change during an insertion into a NONEMPTY queue?

only rear_ptr changes

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

push


Kaugnay na mga set ng pag-aaral

Chapter 15 - Climate Change - Environmental Science (BIO 1127) - SU 2020 - CSCC - Dr. Javadi

View Set