






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!







A list ADT is commonly implemented using - ANSarrays or linked list data structures. A list ADT's underlying data structure has no impact on the program's execution. t/f - ANSf. different underlying data structures will require different algorithms to perform same list ADT operation, which will have different runtimes. Ex: For prepending an item to a list, a linked list-based implementation is more efficient than an array-based implementation. A list node's data can store a record with multiple subitems.True/False - ANSTrue A node in binary tree can have zero, one, or two children.True/False - ANSTrye abstract data type (ADT) is a - ANSdata type described by predefined user operations, such as "insert data at rear," without indicating how each operation is implemented. Abstraction means - ANSto have a user interact with an item at a high-level, with lower-level internal details hidden from the user. Abstraction simplifies________.ADTs allow programmers to focus on choosing which ______ best match a program's needs. - ANS- programming.
Complexity analysis is used - ANSto identify and avoid using algorithms with long runtimes or high memory usage. Computational complexity is - ANSthe amount of resources used by the algorithm. Computational Problem - ANScomputational problem specifies an input, a question to be answered about the input that can be answered using a computer, and the desired output. computational problems and common algorithms: DNA analysis-- CP: Given two DNA sequences from different individuals, what is the longest shared sequence of nucleotides? What is the common algorithm? - ANSLongest common substring problem: A longest common substring algorithm determines the longest common substring that exists in two inputs strings.DNA sequences can be represented using strings consisting of the letters A, C, G, and T to represent the four different nucleotides. computational problems and common algorithms: Navigation---Given a user's current location and desired location, what is the fastest route to walk to the destination? - ANSDijkstra's shortest path: Dijkstra's shortest path algorithm determines the shortest path from a start vertex to each vertex in a graph.The possible routes between two locations can be represented using a graph, where vertices represent specific locations and connecting edges specify the time required to walk between those two locations. data structure - ANSway of organizing, storing, and performing operations on data Do two student essays share a common phrase consisting of a sequence of more than 100 letters? - ANSlongest common substring. if the longest common substring between the two essays is greater than 100, then the two essays share a common phrase consisting of more than 100 letters.
Ex: ADT- A list is a common ADT for holding ordered data, having operations like - ANSappend a data item, remove a data item, search whether a data item exists, and print the list. Ex: The space complexity of an algorithm that duplicates a list of numbers is
How can knowing a problem is NP-complete help? - ANSinstead of trying to find an efficient algorithm to solve the problem, a programmer can focus on finding an algorithm to efficiently find a good, but non-optimal, solution. how is algorithm efficiency measured?? - ANSis most commonly measured by the algorithm runtime, and an efficient algorithm is one whose runtime increases no more than polynomially with respect to the input size. Inserting an item at the beginning of a 999-item array requires how many items to be shifted? - ANS999.Inserting at the beginning requires making room for the new item. So every current item must be shifted once. inserting an item at the beginning of a 999-item linked list requires how many items to be shifted? - ANS0. No shifting of other items is required, which is an advantage of using linked lists. Inserting an item at the end of a 999-item array OR linked list requires how many items to be shifted? - ANS0. Appending an item just places the new item at the end of the array. No shifting of existing items is necessary Items stored in an array can be accessed using a positional index. T/F - ANSarray elements are stored in sequential locations, so can be easily accessed using an index Knowledge of an ADT's underlying implementation is needed to analyze or impove the runtime efficiency. t/f - ANSt. Different ADTs' implementations may have different runtimes for various operations. Ex: Accessing the ith list element is more efficient in an array-based implementation than a linked list implementation. LinearSearch(numbers, numbersSize, key) { i = 0 while (i < numbersSize) {
if (numbers[i] == key) return i i = i + 1 } return -1 // not found } // numbers: 54 79 26 91 29 33 key= 26(neither best nor worst case) key=24: best case key = 82: worst case - ANS-The search for 26 is neither the best nor the worst case. -Searching for 54 only requires one comparison and is the best case: The key is found at the start of the array. No other search could perform fewer operations. -Searching for 82 compares against all array items and is the worst case: The number is not found in the array. No other search could perform more operation linked list - ANSA linked list is a data structure that stores an ordered list of items in nodes, where each node stores data and has a pointer to the next node. list (adt) - ANSitems are ordered based on how items are added. Duplicate items are allowed.
set (adt) - ANSItems are not ordered. Duplicate items are not allowed. Some algorithms utilize data structures to __________ during the algorithm execution. Ex: An algorithm that determines a list of the top five salespersons, may use an array to store salespersons sorted by their total sales. - ANSstore and organize data space complexity - ANSis a function, S(N), that represents the number of fixed-size memory units used by the algorithm for an input of size N. t/f A programmer must know the underlying implementation of the list ADT in order to use a list. - ANSf. A programmer need not have knowledge of the underlying implementation to use a list ADT. T/F: A linked list stores items in an unspecified order. - ANSF. A linked list stores an ordered list of items. The links in each node define the order in which items are stored. T/F: An algorithm with a polynomial runtime is considered efficient. True False - ANST. An efficient algorithm is generally one whose runtime increases no more than polynomially with respective to the input size. In contrast, an algorithm with an exponential runtime is not efficient. t/f: The linear search algorithm's best case scenario is when N = 0. - ANSf: The variable value N cannot be replaced with a constant of 0 to describe a best case scenario. A best case scenario must describe the contents of the data being processed.
the _____ ADT is the better match for the program's requirements. - ANSlist. The list ADT provides an abstraction that satisfies each program requirement, including iterating in reverse order, which the queue ADT doesn't provide. The underlying data structure for a list data structure is the same for all programming languages. t/f - ANSf. The underlying data structures used to implement ADTs may vary between implementations. Some programming languages allow programmers to select a specific implementation. Ex: Java's list ADTs can be implemented using arrays or linked lists. Two different algorithms that produce the same result have the same computational complexity. True False - ANSF: Two different algorithms can produce the same result in various ways and may have different computational complexities. Using abstract data types enables programmers or algorithm designers to focus on _______, thus improving ________ - ANS-higher-level operations and algorithms. -programmer efficiency. What is the problem output? - ANSThe computational problem's question can be phrased as: How many times does the user-specified word appear on the list? The answer to that problem is an integer value for the frequency of the specified word. Which can be used as the problem input? - ANSThe input must include a list of all words and the specific word for which determining the frequency is desired.