Data Structures Final

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

When you solve a problem by solving two or more smaller problems, each of the smaller problems must be ________ the base case than the original problem

closer to

A Constructor __________________________________________

creates and initializes a new instance of a class

Which of the following will be true when the reference variable curr references the last node in a linear linked list?

curr next == null

A recursive solution that finds the factorial of n ( ie. n) generates how many recursive calls? !!!!!!!!!!!!!!!!!!!!!!!

n

A bubble sort requires at most how many passes to sort an array of n items?

n-1

Which of the following statements is used to insert a new node, referenced by newNode, at the end of a linear linked list?

newNode.next = curr; prev.next = newNode;

Which of the following is the code to insert a new node, referenced by new Node into an empty queue represented by a circular linked list?

newNode.next = newNode; lastNode = newNode;

An algorithm's execution time is related to the # of _______ it requires

operations

Which of the following operations leave a queue unchanged?

peek

Which of the following methods of StackInterface does NOT throw a StackException

popAll

Which of the following would result in an error?

popping an empty stack

A ___ allows the deletion of a node from a linked list without the need to traverse the list to establish a trailing reference (i.e. a prev reference) !!!!!!!!!!!!!!

precede reference

Which of the following statements deletes the node that curr references?

prev.next = curr.item

A Client is a ____________________________

program or module that uses the class

Which of the following is not an ADT operation:

push

Which of the following operation of the ADT list changes the list? !!!!!!!!!!!!!!

remove

An array-based implementation of an ADT list:

requires less memory to store a data element than a reference-based implementation.

Procedural abstraction ________________________

separates the purpose and use of a module from its implementation

Which of the following is an example of a syntax error?

the beginning of a while loop is written as "whille" instead of "while"

In a linear linked list ____________________ !!!!!!!!!!!!!!!!!

the next reference of the last node has the value null

Operations on a stack can be carried out at _________

the top only

The two types of simulations are event-driven and _____________

time-driven

A reference-based implementation of a queue that uses a linear singly linked list would need at least _____ external references. A circular linked list implementation would need at least ___ external references

two, one

ADT

Abstract Data Type

Suppose that a selection sort of n items requires n^2/2 + 5 * n/2 - 3 basic operations - the selection sort is

O(n^2)

The insertion sort is ___________ in the worst case

O(n^2)

During the specification phase of the life cycle of software, the programmer should indicate what enhancements to the program are likely in the future (T/F)

True

If 10 items are added to a stack, the first item to be removed from the stack is the last test item that was added to the stack (T/F)

True

In a fully parenthesized algebraic expression, there is no need for precedence or associativity rules (T/F)

True

In encapsulation, methods are usually defined as public (T/F) !!!!

True

Low-order terms can be ignored in an algorithm's growth-rate function (T/F)

True

Node node in a circular linked list contains the value null in its next reference (T/F) !!!!!!!!!!!!!!!!!!!

True

Queues are FIFO (first in, first out) data structures (T/F)

True

Stacks are used by compilers to implement recursion (T/F)

True

The deletion of an item from a one-element reference-based queue is a special case (T/F) !!!!!!!!!!!!!!!!!!!!

True

The program does not need direct access to the data structure. (T/F) !!!!

True

The specifications of an ADT indicate what the ADT operations do, but not how they are implemented (T/F)

True

The use of a dummy head node eliminates the special case for insertions (T/F)

True

When a linked list is empty, the value of the head reference is null (T/F)

True

When infix expressions are converted to post-fix expressions, the operands always stay in the same order with respect to one another (T/F)

True

Operations on a queue can be carried out at _____________

both the front and the back

The _____ compares adjacent items and exchanges them if they are out of order

bubble sort

A client application can use the operations of an ADT without knowing how the ADT is implemented (T/F)

True

A queue can be used to preserve the order of occurrences (T/F) !!!!!!!!!!!!!!!

True

A recursive solution can have more than one base case (T/F)

True

A reference variable contains the location of an object in memory (T/F)

True

A reference-based implementation of the ADT list does not shift items during insertion or deletion (T/F)

True

Which of the following is the prefix form of the infix expression (8+6)/ (16-4) ?

/+ 86-164

A growth-rate function of ____ implies a problem whose time requirement is constant

1

What are the following phases of the life cycle of software as discussed in class with their correct order from the beginning phase?

1)Specification 2)Design 3)Coding 4)Maintenance

What is the value of the prefix expression -*38+65

13

Suppose that we have an ordered array of 980 entries. How many elements would need to be moved/shifted if it was determined that an element was to be inserted at position 401? !!!!!!!!!!!!!!!!!

580

What is the value of the postfix expression 67+82-*

78

Which of the following IS NOT TRUE of a modular program? Easier to read Easier to write Easier to modify All of these are true !!!!!!

All of these are true

________________ is a problem-solving technique for guessing at a solution recursively and backing up when an impasse is reached

Backtracking

Which of the following is NOT a means of implementing a queue

Circular array Circularly Linked LIst Linear array Linearly linked list ___> Alll of THESE

A ____________ allocates memory for an object and can initialize the object's data

Constructor

In ___________ recursion, there can be multiple activation's of the same method existing at the same time. !!!!!

Direct

Which of the following is true about all doubly linked lists?

Each node references both its predecessor and its successor

_________ can be used to enforce the walls of an ADT ** Repeated

Encapsulation

_____________ can be used to enforce the walls of an ADT

Encapsulation

All members in a class are public unless the programmer designates them as private (T/F) !!!!!

False

By default, equality operators (== or !=) used with objects will compare the value associated with those objects (T/F)

False

Logical errors of a program are removed during the coding phase of the software life cycle. (T/F)

False

Recursion cannot be used for list traversal or node insertion (T/F)

False

The analysis of an algorithm must take into consideration the computer that will be used to run a program that implements the algorithm (T/F)

False

The binary search algorithm is a quadratic algorithm (T/F)

False

The instance of an object is called a class (T/F) !!!!!

False

When implementing a queue using a reference-based approach, the operation dequeueAll is not needed (T/F)

False

When implementing a queue, a naive array approach is more efficient in terms of memory when compared to a circular array approach (T/F)

False

When implementing a stack as a linked-list, you must make sure the stack isn't full before you can push a new item onto it (T/F)

False

When working with a stack, peek removes the values from the top of the stack (T/F)

False

Suppose you are using a queuing system to simulate the movement of pallets in a warehouse. What would represent the server in the simulation?

Forklift

Which of the following represents the most efficient order for an algorithm?

O(log 2 n)

Which of the following would not be a good use of a stack?

Keyboard buffer

In the following scenario, indicate what data structure you would use: SCENARIO:::::: A grocery list ordered by the occurrence of items in the store

List

Which of the following is true about algebraic expressions? !!!!!!!!!

Postfix expressions do not require association rules

Which of the following is NOT a part of the maintenance phase of the software life cycle?

Proving the correctness of algorithms

In the following scenario, indicate what data structure you would use: SCENARIO:::::: Customers at a dell counter who take numbers to mark their turn

Queue

Comparing recursion with iteration, which of the following is TRUE:

Recursion reduces the size of the code

According to the basic tenet of software engineering, more than 50% of the cost and time for software is perpetuated within the maintenance phase of the software life cycle (T/F)

True

An algorithm's time requirement can be derived as a function of the problem size (T/F)

True

In the following scenario, indicate what data structure you would use: SCENARIO:::::: A word processor that allows you to correct typing errors by using backspace

Stack

Which of the following is NOT true about converting infix expressions to post-fix expressions?

The operators always stay in the same order with respect to one another

If a stack is used by an algorithm to check to balanced braces which of the following is true once the end of the string is reached?

The stack is empty

Which best describes the purpose of this code snippet? for(Node curr = head; curr!= null; curr = curr.next) { // code goes in here }

Traversing a linked list

The syntax errors of a program are removed during the _______ phase of the program's life cycle. !!!!!!!!!!!!

Verification WRONG

Data Structure is

a construct that is defined within a programming language to store a collection of data

In a recursive method that checks if a given string is palindrome, the base case(s) should be __________.

a string with length of zero or one.

!!!!!!!!!!!!!!!!!! Which of the following is the postfix form of the prefix expression * +abc

ab+c*

Which of the following is the postfix form of the infix expression a*b-(c+d) ?

ab+cd+-

The enqueue operation throws a QueueException when it tries to:

add an item to an array-based implementation of a queue that is already full

In a reference-based implementation of an ADT list ______

an item explicitly references the next item.

The pop operation throws a StackException when it tries to:

delete an item from an empty stack

In all circular linked lists _________________________

every node references a successor

Which of the following statements deletes (i.e. marks as garbage) the first node of a linear linked list? !!!!!!!!!!!!!!!!

head = head.next;

Encapsulation __________________________________

hides the implementation details of the ADT from the programmer that uses it

Data structures are part of an ADT's ____________!!!!!!!!!!!!!

implementation

The Subclass ____________________________

inherits the contents of the super-class

An Object is an _______________________

instance of a class


Set pelajaran terkait

Case Management Process Practice Questions from courses

View Set

Introduction to Applied Behavior Analysis

View Set

Chapter 5- Finance and Accounting

View Set

Drugs Used in Psychosis, Agitation & Extrapyramidal Symptoms

View Set

TCU Linux System Administration Final Scherger

View Set