Test 1 Data structures Ch 1,2,3

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Array member of the Built-in Structure array: (page 60-61) A. is stored in contiguous memory B. has unique ordinal subscript could be thought of as node number C. has nodes that are stored sequentially based on the node number D. All of above

D. All of above

Give an efficient circular array-based queue Q capable of holding 10 objects.After the following code is executed:for (int k = 1; k <= 7; k++ ) Q.enqueue(k);for (int n = 1; n <=7; n++ ) Q.enqueue (Q.dequeue());The result on the queue as follows: true In the queue structure, the node is inserted at front and is removed at rear

false

In the queue structure, the node is inserted at front and is removed at rear

false

For convenience of typing, the Java code replaces the subscript with the index for an array n elements. which one is NOT correct about it (page 63) A. x[i] reference for the element at the index i B. index i start by 0 C. index i ends by n D. the last element in array x is x[n-1]

index i ends by n

Which one is the programmer-defined array structure? (page 66)

D. All of above

A stack will be initialized with top = 0 and data[i] = null with i = 0 to size True False

False

Nodes A, B and C are placed on a Queue in the order first A, then B and finally C, if invoking dequeue method on this queue, which node will be dequeued

Node A

Nodes A, B and C are placed on a stack in the order first A, then B and finally C, if invoking pop method on this stack, which node will be popped

Node C

The speed of Enqueue operation of Queue structure is:

O(1)

The speed of Push operation of Stack structure is:

O(1)

Which type of error that occurs if a Push operation is invoked on a full stack?

Overflow error

The linear list access function: AN = A0 + N * wthat is used to calculate the location of an element of the array from its node numberwhere Ao is the byte address of the first node called the base addressw is the node width (number of bytes per node) andN is the number of the node, starting from 0

True

Which one is NOT the feature of the programmer-defined array structures (page 66) a. They are accessed in the node number mode b. They use an array of objects to store the data set c. They are fully encapsulated d. hey can store data sets of multiple nodes

a. They are accessed in the node number mode

Which one is not correct for the speeds of Unsorted-Optimized Array Structure operations? Fetch: O(log2n) The initialized state of Unsorted Array structure n elements named data, which one is NOT correct: (page 66)

next is set to n-1

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

pop

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

push

What is the reason for using a "circular queue" instead of a regular one?

reuse empty spaces

onsider the following pseudocode:declare a stack of characters while ( there are more characters in the word to read ) { read a character push the character on the stack } while ( the stack is not empty ){write the stack's top character to the screen pop a character off the stack} What is written to the screen for the input "carpets"?

steprac

A stack will be initialized with top = 0 and data[i] = null with i = 0 to size false Give an efficient circular array-based queue Q capable of holding 10 objects.After the following code is executed: for (int k = 1; k <= 7; k++ ) Q.enqueue(k); for (int n = 1; n <=7; n++ ) Q.enqueue (Q.dequeue()); The result on the queue as follows:

true

Which one is not correct for the speeds of Sorted Array Structure operations

Insert: O(3)

They are the operations that perform on the Queue structures Enqueue, Dequeue int[ ] values = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 }; Stack s = new Stack(10); for (int i = 0; i < 10; i ++) s.push(values[ i ]); int sum = 10;for (int n = 0; n <3; n++) sum = sum + s.pop(); System.out.println (sum); What is the output?

61

Two objects, objectA and object, are objects of one class. The objectA is copied to objectB. How many objects exist after the copy if the copy is performed as a shallow copy? A. 1 B. 2 C. cannot know D. 1 or 2 depending on real cases

A. 1

Three criteria are used to determine whether a data structure is acceptable for a particular application are: A. Cost, Speed, and memory overhead B. Cost, type of storage, type of memory C. a and b D. None of above

A. Cost, Speed, and memory overhead

The basic operations performed on data structures: A. Insert, delete, fetch, update B. Insert, search, delete, update C. Remove, search, insert, update D. fetch, modify, delete, read

A. Insert, delete, fetch, update

The Binary Search algorithm speed at the worst case is? A. O(log2n) B. O(n log2n) C. O(n) D. O(n2)

A. O(log2n)

Tell what of the following does the acronyms LIFO describes for: A. Stack B. Queue C. Hashtable D. none of above

A. Stack

Which of the following access modes cannot be used to access restricted structures? A. Update B. Fetch C. Insert D. None

A. Update

The Insert algorithm of Sorted Array Structure has the following steps, put the following steps in correct order (page 76) Step A: Using Binary Search Algorithm to search until finding two adjacent keys that backed the new node's key Step B: Move all the nodes below these two nodes and the larger of the two braked nodes down one element to open up a spot for the new node Step C: The content of the node that we want to insert is deep copied to the spot for the new created node then a reference to that node is placed in the array element that has been opened up

ABC

Which one is the programmer-defined array structure? (page 66) A. The Unsorted array B. The Sorted array C. The Unsorted-Optimized Array D. All of above

All of above

Unsorted array is array-based structure that ____ (page 66) A. is accessed in the key field mode B. uses an array of objects to store the data set C. the size is equal to the max number in the structure D. All of above are correct

All of above are correct

There are 2 nodes stored in a linear list. Which node comes just before and just after the first node? A. None and last node B. Node 0 and Node 2 C. None and Node 2 D. A and C

D. A and C

Which one is not correct for the speeds of Unsorted-Optimized Array Structure operations? A. Insert: O(3) B. Delete: O(<=n) C. Fetch: O(log2n) D. Update: O(<= n + 3)

Fetch: O(log2n)

Which of the four basic operations do the restricted structures support?

Insert

I am going to execute this code with THREE pushes and ONE pop: stack <int> s; s.push(1); s.push(2); s.push(3); System.out.println(s.pop( )); What is the output?

3

Give a 5 elements stack S (from top to bottom: 2, 4,6,8,10 ) and an empty queue Q. Remove the elements one by one from the stack S then insert them into queue Q; then remove them one by one from queue Q and re-insert to the stack S.Now S looks like (from top to bottom):

10, 8, 6, 4, 2

Recall that the linear list access function: AN = A0 + N * w that is used to calculate the location of an element of the array from its node numberwhere Ao is the byte address of the first node called the base addressw is the node width (number of bytes per node) andN is node number, starting from 0Apply this function to calculate the memory address of the node stored at index 4 where base address = 100, node width = 10

140

The initialized state of Unsorted Array structure n elements named data, which one is NOT correct: (page 66)

B. next is set to n-1

Two objects, objectA and objectB, are objects of one class. The objectA is copied to objectB. How many objects exist after the copy if the copy is performed as a deep copy?(PAGE 41) A. 1 B. 2 C. cannot know D. 1 or 2 depending on real cases

B. 2

They are the operations that perform on the Queue structures A. Pop, push B. Enqueue, Dequeue C. Insert, Delete, Fetch, Update D. Add, Remove, get, set

B. Enqueue, Dequeue

The programmer-defined array structures support the following operations A. Fetch, Insert B. Fetch, Insert, Delete, Update C. Fetch, Update D. Fetch, Delete

B. Fetch, Insert, Delete, Update

Which one is true for Linear List? A. It is a collection of n nodes if there is a unique first node N1, unique last node Nn and only one node in the list B. It is a collection of n nodes if there is a unique first node N1, unique last node Nn and for any other node, only one node comes before it and only one node comes after it C. It is a collection of n nodes if there is a unique first node N1, unique last node Nn and for any other node, it can have one or more nodes come before or after it D. None of above

B. It is a collection of n nodes if there is a unique first node N1, unique last node Nn and for any other node, only one node comes before it and only one node comes after it

They are the operations that perform on the Stack structures A. Enqueue, Dequeue B. Pop, push C. Insert, Delete, Fetch and Update D. Add, Remove, get, set

B. Pop, push

A = 23n + 36n2 B = 6 + nlog2(n) + n C = log2n + 36n2 Which one of the following is correct? A. TA = O(n2) TB = O(n) TC = O(log2n) B. TA = O(n2) TB = O(nlog2(n)) TC = O(n2) C. TA = O(n2) TB = O(+ nlog2(n)) TC = O(log2n) D. TA = O(n2) TB = O(n) TC = O(n2)

B. TA = O(n2) TB = O(nlog2(n)) TC = O(n2)

Procedural abstraction is: A. We do not need to know what the method is to use it B. We do not need to know the implementation details of the method in order to use it C. We do not need to know what methods the class has to use it D. We do not to know anything about the method to use it

B. We do not need to know the implementation details of the method in order to use it

Built-in data structures are ____? A. Schemes for storing data that are conceived and implemented by the programmer of a particular program B. schemes for storing data that are part of a programming language C. constructed from structures, such as, parallel arrays, class definitions, hashing schemes, link lists, trees, stacks and queues. D. None of above

B. schemes for storing data that are part of a programming language

Fetch algorithm of Unsorted -Optimized Array Structure with the key targetKey has the following steps, put them in correct order (page 69-70 and 80) Step A: return a deep copy of it Step B: Use Sequential Search Algorithm starting at element 0 and down the array until an object with the given key is found Step C: Move the node reference up one index in the array unless the node being fetched is reference by element at zero

BCA

The Delete algorithm of Sorted Array Structure has the following steps, put them in correct order (page 74) Step A: next = next-1 and assign data[next] to null (reclaim unused storage) Step B:Use Binary Search algorithm to locate the node i to be deleted Step C: Move all the references below node i to node next-2 up one index

BCA

The Delete algorithm of Unsorted Array Structure has the following steps, put them in correct order (page 67) Step A: Set the array element that stores the reference to the node to null Step B:Use sequential search to locate the node to be deleted, the search begins at element zero and terminates when the node with the given key is located. Step C: Move all the node references below the deleted node up one element in the array and then decrement the memory cell next

BCA

The Delete algorithm of Unsorted-Optimized Array Structure has the following steps, put them in correct order (page 67 and 81) Step A: Move the last node reference into the deleted node's position. Step B:Use sequential search to locate the node to be deleted, the search begins at element zero and terminates when the node with the given key is located. A. AB B. AB and need another step C. BA D. BA and need another step

C. BA not correct

Which one is correct operation list of ArrayList (page119)? A. Insert, Update, Fetch, Remove B. Add, Update, Fetch, Remove C. add, get, remove and set D. add, get, delete and set

C. add, get, remove and set

The factors that determine the cost of software? A. Lines of code that the software contains B. Design, implement, testing, documentation, burdened labor rate C. A and B D. None of these are correct

C. A and B

Fetch algorithm of Unsorted Array Structure with the key targetKey has the following steps, put them in correct order (page 69-70) Step A: return a deep copy of it Step B: Use Sequential Search Algorithm starting at element 0 and down the ar ray until an object with the given key is found (page 71) A. AB B. AB and need one more step C. BA D. BA and need one more step

C. BA

The Insert algorithm of Unsorted Array Structure has the following steps, put the following steps in correct order (page 66) Step A: index next is incremented by one to prepare for the next insertStep B: A new node object is allocated with its contents initialized to the contents of the node to be insertedStep C: A reference to it is placed into the array at data[next] A. ABC B. BAC C. BCA D. CBA

C. BCA

The following is not true about Binary Search : A. Binary Search algorithm is a technique for rapidly finding a data item stored in an array B. Binary Search algorithm will return the index of the array elements where the search value is stored C. Binary Search algorithm can be applied on the unsorted arrays D. Binary Search algorithm assumes that the data in array are already sorted. in ascending order

C. Binary Search algorithm can be applied on the unsorted arrays

Basic operations that are supported by built-in structure array support are (page 63) A. Fetch and Delete B. Insert and Delete C. Fetch and Update D. Delete and Update

C. Fetch and Update

Which one is not correct for the speeds of Unsorted-Optimized Array Structure operations?

C. Fetch: O(log2n)

Put the terms, node, field and data set in size order from small to large: (page 11-12) A. Data set, field, node B. Field, data set, node C. Field, node, data set D. Node, data set, field

C. Field, node, data set

Which one is not correct about the object (page 40)? A. Object is an instance of a class B. After an object is declared, the client code can invoke any public accessible methods declared in the class by using objectName.methodName() C. In Java, accessing information in objects requires only one memory access as primitive variable (page 40) D. In Java, accessing information in objects requires two memory

C. In Java, accessing information in objects requires only one memory access as primitive variable (page 40)

Which of the four basic operations do the restricted structures support? A. Update B. Fetch C. Insert D. none of above

C. Insert

Nodes A, B and C are placed on a stack in the order first A, then B and finally C, if invoking pop method on this stack, which node will be popped A. Node A B. Node B C. Node C D. You need to determine which node to pop

C. Node C

The speed of Dequeue operation of Queue structure is: A. O(n) B. O(nlog2n) C. O(1) D. O(n2)

C. O(1)

The speed of Pop operation of Stack structure is:

C. O(1)

Which statement is not correct about data? A. Data is information B. Data can be input data or output data C. Studies show that programs spend only 10% of their execution time for searching through memory to locate the data they process D. The source of data can be any device attached to a computer system

C. Studies show that programs spend only 10% of their execution time for searching through memory to locate the data they process

Assume 16 lines of code per person per day. Estimate a program will consist of 300,000 lines of code. If the burdened cost of a programmer's efforts is $150 per hour, determine the code of the program (page 10) A. 45 million dollars B. 10 million dollars C. 90 million dollars D. 22.5 million dollars

D. 22.5 million dollars

Class abstraction is: A. We do not need to know anything about the data structure to use it B. We do not need to know what data structure about to use it C. We do not need to know the implementation details of a data structure in order to use it D. We do not need to know what the data structure is about to use it

C. We do not need to know the implementation details of a data structure in order to use it

Data Structure is ____ A. An organization of information usually in the memory B. For better algorithm efficiency and improves the program's performance C. a and b D. none of above

C. a and b

Generic Data Structure is: (page 106) A. a data structure can store any kind of node and can be used in an application B. a data structure could not only be used to store the data for a telephone listing application but also an employee record application, a store inventory application or any other type of data application without modifying its code C. a and b D. none of above

C. a and b

Which one is correct about array? A. int [ ] myInt = new int; B. int [3] myInt = new int; C. int [ ] myInt = new int[3]; D. int [ ] myInt = new int(3);

C. int [ ] myInt = new int[3];

The operation for removing an entry from a stack is traditionally called: A. delete B. peek C. pop D. remove

C. pop

Big-O analysis is __________ A. An analysis technique that is used to set a bound of the upper limit of a mathematical function. B. An analysis technique that is based on the assumption that one of the term of the function will dominate all but negligible portion of the value of the function as the independent variable gets large. C. An analysis that is used to evaluate functional relationships D. All of above

D. All of above

Which one is not correct about the class? A. Class is a programmer-defined type B. Class consists of data definitions and methods that operate on the data C. Public class allows a method in any application to declare a reference variable of this class type D. Class is a primitive data type that Java defines in the Java library

D. Class is a primitive data type that Java defines in the Java library

Update algorithm of Unsorted Array Structure with the key field as targeKey will combine two following operation in this order (page 71) A. Fetch - Insert B. Insert - Fetch C. Insert - Delete D. Delete - Insert

D. Delete - Insert

Which one is not correct about encapsulation? A. Encapsulation helps to reduce the cost of the software development. and maintenance B. Encapsulation produce the code is more easily reused C. Encapsulation is the idea that we write the code in a way that establishes compiler enforced protocols for accessing the data that the program process D. Encapsulation provides the code such that all the fields can be access from everywhere outside the class

D. Encapsulation provides the code such that all the fields can be access from everywhere outside the class

Algorithm speed will consider the following factors: A. relative speed of the algorithm B. absolute speed of the algorithm C. do not need to consider anything D. a and b

D. a and b

Which one is not correct for the speeds of Unsorted Array Structure operations A. Insert: O(3) B. Delete: O(log2n) C. Fetch: O(n) D. Update: O(2n + 3)

Delete: O(log2n)

There are two Access Modes that are used to specify the node to be accessed: A. The node number mode B. The type of the node mode C. The key field mode D. a and b E. a and c

E. a and c

A real-world example of the queue data structure can be seen in the cafeteria trays, where the last tray placed onto is the first tray removed.

False

The built-in data structure array is fast and its memory overhead is low TRUE The built-in data structure array supports the key field access mode

False

The pop function in the stack retrieve the value from the top of the stack. It does not removes it.

False

The pop function in the stack retrieve the value from the top of the stack. It does not removes it. True False

False

The queue is initialized with the top = -1 and data[ i ] = null where i = 0 to size True False

False

Which one is NOT correct about ArrayList (page 118)? A. ArrayList is class provided in Java Application Programmer Interface (API) B. ArrayList object can expand at run-time beyond its initial size to accommodate unanticipated Insert Operation C. ArrayList boston = new ArrayList();//initial size defaults to 10 nodes D. Insert, Fetch, Delete, and Update are 4 operations of ArrayList

Insert, Fetch, Delete, and Update are 4 method names of ArrayList

Which statement is NOT correct for Built-in Structure Array: (page 60) A. All of the values stored in the variable are of the same type B. Each array member is distinguished by the variable name and a unique ordinal subscript C. It can grow and shrink, therefore, Insert and Delete operation would be allowed D. There is a minimum and maximum value of the subscript

It can grow and shrink, therefore, Insert and Delete operation would be allowed

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

Pop

Tell what of the following does the acronyms FIFO describes for:

Queue

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();

Queue Q stores 3

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. Queue Q stores 3 B. Queue Q stores 5 C. Queue Q stores 2 D. Queue Q stores none of above

Queue Q stores 3

The built-in data structure array is fast and its memory overhead is low

TRUE

Describe the ability of Peek operation on the Expandable Model of a stack

The ability to pop a node from the stack without deleting it from the structure

Which one is not correct about Inheritance?

The classA is called the parent class and the classB is called the child class

The Java syntax for two dimension array element is x[i] [j]. Which one is NOT correct: a. index I and j always start at zero b. i represents the row number, j represents the column number c. There are r rows and c columns in the array x then xrc is the last element d. All of above are correct

There are r rows and c columns in the array x then xrc is the last element

All the nodes of an array data structure are located on contiguous memory address. Therefore, the nodes are stored sequentially based on the node number.

True

All the nodes of an array data structure are located on contiguous memory address. Therefore, the nodes are stored sequentially based on the node number. True All the programmer-defined Array structures access nodes by using the key field mode

True

Array is a built-in data structure to store values of the same type that is called a homogeneous structure

True

Give an efficient circular array-based queue Q capable of holding 10 objects. After the following code is executed: for (int k = 1; k <= 7; k++ ) Q.enqueue(k); for (int n = 1; n <=7; n++ ) Q.enqueue (Q.dequeue()); The result on the queue as follows: 0 1 2 3 4 5 6 7 8 9 4 5 6 7 1 2 3

True

The first item placed onto a stack is always the last item removed from the stack

True

The pop function in the stack retrieve the value from the top of the stack. It does not removes it. False Enqueue each letter of the word "Welcome" to the queue then print out the result of dequeue each letter from the queue will get the same word "Welcome

True

Working with built-in array data structure, Insert and Delete operations cannot be allowed

True

In the implementations of the Stack operation presented in this chapter, what does the memory cell top store? a. the index of the array where the next push or the next pop will be performed b. the index of the array where the last push or the last pop was performed c. the index of the array where the next push or the last pop was performed d. the index of the array where the last push or the next pop is performed

d. the index of the array where the last push or the next pop is performed

The first item placed onto a stack is always the last item removed from the stack True Which type of error that occurs if a Pop operation is invoked on an empty stack?

underflow error


Ensembles d'études connexes

SERE 100.2 Level A Pre Test Answers

View Set

ISM V2 Module 3 - Data Protection - Raid

View Set

MindTap Module 13: Reviewing the Basics Quiz

View Set

ef3 beg 2B Wh- and How questions with be

View Set