






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







The end at which the insertions and deletions occur in a stack is called the ____ of the stack. CORRECT ANSWERS top In the Reverse Polish notation, the operators are written before the operands. CORRECT ANSWERS False In a stack, the ____ operation adds an element onto the stack. CORRECT ANSWERS push The method ____ from the Java class Stack returns and removes the top element of the stack. CORRECT ANSWERS pop The push method of the stack can be compared with the method ____ for a general list. CORRECT ANSWERS insertFirst Physical simulators include wind tunnels used to experiment with the design of car bodies. CORRECT ANSWERS true A stack is also called a ____data structure. CORRECT ANSWERS LIFO As in a stack, the middle elements of the queue are inaccessible, even if the queue elements are stored in an array. CORRECT ANSWERS false Simulating the behavior of an expensive or dangerous experiment using a computer model is usually more expensive than using the real system. CORRECT ANSWERS false In a queuing system, the term ____represents the time it takes to serve a customer. CORRECT ANSWERS transaction time In a queuing system, when a server becomes free, the customer at the rear of the queue moves to the free server to be served. CORRECT ANSWERS false You can use stacks to convert recursive algorithms into nonrecursive algorithms. CORRECT ANSWERS true Adding or pushing an element onto the stack is a two-step process. CORRECT ANSWERS true
Elements are deleted from a queue at one end, called the ____. CORRECT ANSWERS front The ____ method from the interface QueueADT adds a new element to the rear of the queue. CORRECT ANSWERS addQueue An array is a random access data structure; that is, you can directly access any element of the array. CORRECT ANSWERS TRue A technique in which one system models the behavior of another system is called ____. CORRECT ANSWERS simulation The method isFullQueue from the interface QueueADT initializes the queue to an empty state. CORRECT ANSWERS false Adding an element to a full stack would generate an error or exception called ____. CORRECT ANSWERS stack overflow exception Postfix or Reverse Polish notation has the advantage that the operators appear in the order required for computation. CORRECT ANSWERS true What are the two steps in pushing a value onto a stack? CORRECT ANSWERS First, you must determine if there is room on the stack for another value. If there is, you push the value onto the stack; otherwise, you don't. A ____list is a linked list in which every node has a next pointer and a back pointer. CORRECT ANSWERS doubly linked If first points to the first node in a list and first is ____, the list is empty. CORRECT ANSWERS null One of the basic operations performed on a list is to process each node of the list. CORRECT ANSWERS True An unordered list can be built in two ways: in the forward manner and in the backward manner. CORRECT ANSWERS true A doubly linked list can be traversed in either direction. CORRECT ANSWERS true When building an unordered list in the forward manner, you need ____ reference variables. CORRECT ANSWERS 3
To delete a given item from an ordered linked list, you do not need to search the list to see whether the item to be deleted is in the list. CORRECT ANSWERS false Every node in a linked list has two components. CORRECT ANSWERS true The value nullin the link of the last node means that this link points to the first node in the list. CORRECT ANSWERS false You can use the variable head to traverse a list without losing the nodes of the list. CORRECT ANSWERS false The info part of a node cannot be a reference variable. CORRECT ANSWERS false The address of the first node in the list is stored in a separate location, called the ____ or first. CORRECT ANSWERS head Because an unordered linked list is not a random access data structure, you must sequentially search the list starting from the first node. CORRECT ANSWERS true When building an unordered list in the forward manner, a new node is always inserted at the ____ of the linked list. CORRECT ANSWERS end When the system's automatic garbage collector runs and if no reference variable points to a node, then the memory occupied by the node will be reclaimed by the system. CORRECT ANSWERS true You can issue the statement ____ to run the garbage collector. CORRECT ANSWERS System.gc(); The method ____ does not apply to an ordered linked list because the new item must be inserted at the proper place in the list. CORRECT ANSWERS insertFirst In a doubly linked list, every node contains the address of the next node except the first node. CORRECT ANSWERS false The iterator method hasNext gives access to the next element in the list. CORRECT ANSWERS false When drawing a linked list, a down arrow on a node means that the link part of the node does not point to anything. CORRECT ANSWERS true To insert an item in an ordered linked list, you first find the place the new item is supposed to be inserted, and then you insert the item in the list. CORRECT ANSWERS true
To delete a given item from an ordered linked list, you do not need to search the list to see whether the item to be deleted is in the list. CORRECT ANSWERS false Every node in a linked list has two components. CORRECT ANSWERS true The value nullin the link of the last node means that this link points to the first node in the list. CORRECT ANSWERS false You must traverse the list using another reference variable of the same type as head. CORRECT ANSWERS true You can use the variable head to traverse a list without losing the nodes of the list. CORRECT ANSWERS false The statement ____ copies the value of head into current. CORRECT ANSWERS current = head; The info part of a node cannot be a reference variable. CORRECT ANSWERS false The address of the first node in the list is stored in a separate location, called the ____ or first. CORRECT ANSWERS head Because an unordered linked list is not a random access data structure, you must sequentially search the list starting from the first node. CORRECT ANSWERS true A(n) ____ is an object that produces each element of a collection, such as a linked list, one element at a time. CORRECT ANSWERS iterator When building an unordered list in the forward manner, a new node is always inserted at the ____ of the linked list. CORRECT ANSWERS end When the system's automatic garbage collector runs and if no reference variable points to a node, then the memory occupied by the node will be reclaimed by the system. CORRECT ANSWERS true In a doubly linked list, every node contains the address of the previous node (except the ____ node). CORRECT ANSWERS first You can issue the statement ____ to run the garbage collector. CORRECT ANSWERS System.gc(); The method ____ does not apply to an ordered linked list because the new item must be inserted at the proper place in the list. CORRECT ANSWERS insertFirst
Because you need to determine the middle element of the list frequently, the binary search algorithm is typically implemented for array-based lists. CORRECT ANSWERS false In a search algorithm, the dominant operations are item assignments. CORRECT ANSWERS false Associated with each item in a data set is a special member that uniquely identifies the item in the data set. This unique member of the item is called the ____of the item. CORRECT ANSWERS key What is the maximum number of key comparisons made when searching a list L of length n for an item using a binary search? CORRECT ANSWERS 2 * log2n + 2 Consider the following list. list = {20, 10, 17, 2, 18, 35, 30, 90, 48, 47}; Suppose that sequential search as discussed in the book is used to determine whether 2 is in list. Exactly how many key comparisons are executed by the sequential search algorithm. CORRECT ANSWERS 4 Suppose that you have the following list: int[] list = {2, 5, 8, 11, 14, 17, 20}; Further assume that sequential search on an ordered list is used to determine whether 11 is in list. When the loop terminates the value of the index variable loc is 3. CORRECT ANSWERS true A sequential search is faster than a binary search on sorted lists. CORRECT ANSWERS false To search through a list you need to know the length of the list. CORRECT ANSWERS true Consider the following list. list = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; Suppose that sequential search on an ordered list as discussed in the book is used to determine whether 55 is in list. Exactly how many key comparisons are executed by this search algorithm. CORRECT ANSWERS 10
In a linear search, you search an array starting from the middle component. CORRECT ANSWERS false Consider the following list. list = {20, 10, 17, 2, 18, 35, 30, 90, 48, 47}; Suppose that sequential search as discussed in the book is used to determine whether 95 is in list. Exactly how many key comparisons are executed by the sequential search algorithm. CORRECT ANSWERS 10 Suppose that you have the following list: int[] list = {0, 10, 20, 30, 40, 50, 60, 70, 80}; Further assume that binary search is used to determine whether 45 is in list. When the loop terminates the value of the index variable first is 5 and the value of the inde variable last is 4. CORRECT ANSWERS true To design a general-purpose search method, searchList, to search a list, which of the following must be parameters of the method searchList. (i) The array containing the list. (ii) The length of the list. (iii) The search item. (iv) A boolean variable indicating whether the search is successful. CORRECT ANSWERS (i), (ii), and (iii) The binary search algorithm is an optimal worst-case algorithm for solving search problems by the comparison method. CORRECT ANSWERS true The maximum number of comparisons made by the merge sort algorithm is ____. CORRECT ANSWERS O(nlog2n) A selection sort can be implemented by selecting the largest element in the sorted portion of the list and moving it to the bottom of the list. CORRECT ANSWERS false The sorting algorithms bubble sort, selection sort, and insertion sort are O(nlog2n). CORRECT ANSWERS false The sequential search algorithm given in this chapter uses a(n) ____ control structure. CORRECT ANSWERS iterative On average, a successful sequential search searches two thirds of the list. CORRECT ANSWERS false
Consider the following list. int[] intList = {35, 12, 27, 18, 45, 16, 38}; What is the minimum number of comparisons that have to be made to find 18 using a sequential search on intList? CORRECT ANSWERS 4