Data Structures Final Exam
A node without children is called a
Leaf node
Most operations on singly linked structures run in
Linear time
The index-based operations on a linked implementation of a list run in
Linear time
The insert and remove operations on an array-based indexed list run in
Linear time
Most of the operations on a list iterator connected to a linked list run in
Constant time
Random access supports
Constant time access to data
In Python, a type conversion operation for two collections
Creates copies of the objects in the source collection and adds these new objects to a new instance of the destination collection
Assume that data are inserted into a binary search tree in the order D B A C F E G. A preorder traversal would return these data in the order
D B A C F E G
The array implementation of a stack places the top element at the
Position after the last element that was inserted
Operations that access list elements by moving a cursor are called
Position-based operations
A postorder traversal of an expression tree returns the expression in
Postfix form
A hierarchical collection can represent a
File directory system
When an array runs out of memory to hold data, it is best to create a new array that
Has twice as many as the old array
Operations that access list elements at integer positions are called
Index-based operations
The filter function creates a sequence of the
Items in a given collection that pass a Boolean test
Profiling
is a way to measure the time cost of an algorithm using the computer's clock to obtain an actual run time
An array length
is fixed in size after it is created
______________ is a strategy that saves computed values for subsequent use, so they will not have to be recomputed
memoization
What is the difference between a SHALLOW COPY and a DEEP COPY?
shallow copy- are NOT cloned before being added to a new list, are references to the objects being copied deep copy- clones its items before adding them to the new collection
___________ and ____________ is the two most significant resources that we try to optimize seriously in algorithm analysis.
time, memory
Which of the following link list operations has a running time of O(n) on average case?
- Access at ith position - Replacement at ith position - Insert at ith position - Remove from ith position
Which of the following array operations has a running time of O(1) on average case?
- Access at ith position - Replacement at ith position - Insert at logical end - Remove from logical end
Examples of queues are (choose all that apply):
- Customers waiting in a checkout line - A line of cabs - VIP lines and regular lines in the airport
Queues are also known as
- First-in first-out data structures - Last-in last-out data structures
Which of the following link list operations has a running time of O(1) on average case?
- Insert at beginning - Remove from beginning
Which of the following array operations has a running time of O(n) on average case?
- Insert at ith position - Increase capacity - Decrease capacity - Remove from ith position
Stacks are also known as
- Last-in first-out data structures - First-in last out data structures
The operations that modify a queue are called
- enqueue() and dequeue() - pop(0) and append() - add() and pop()
The operations that modify a stack are called
- push() and pop() - append() and pop()
Put these Big O categorization name into the right order from the fastest to the slowest
1. Constant 2. Logarithmic 3. Linear 4. Quadratic 5. Exponential 6. Combinatoric
Put these sorting algorithms into the right order from the fastest to the slowest according to their average case
1. Counting Sort 2. Merge Sort 3. Insertion Sort 4. Bubble Sort with Tweak 5. Bubble Sort 6. Selection Sort
Put these Big O growth functions into the right order from the fastest to the slowest
1. O(1) 2. O(log n) 3. O(sqrt(n)) 4. O(n) 5. O(n**2) 6. O(2**n) 7. O(n!) 8. O(n**n)
Sort this unit abstraction from the smallest unit to the largest unit
1. function and methods 2. classes 3. modules
The value of the postfix expression 5 6 + 2 * is
22
Each level k in a full binary tree contains
2^k + 1 nodes
Assume that data are inserted into a binary search tree in the order D B A C F E G. An inorder traversal would return these data in the order
A B C D E F G
Examples of stacks are
A deck of playing cards
The for loop on a list visits its items
At each position, from the first one through the last one
The worst-case running time of an insertion into a singly linked structure occurs when you insert
At the tail of the structure
Choose all the examples of a Hierarchical Collection
Binary Search Tree, Heap, Organizational Tree
The index operation on an array-based sorted list uses
Binary search
One of the important algorithm techniques is the divide and conquer methods. Explain divide and conquer with your own words and give an example.
Binary search, splits data into 2 parts
The == operation for two lists must
Compare pairs of items at each position for equality
The running time of the three queue mutator operations is
Constant
Arrays and linked structures are examples of
Data Structures
A linked list is best implemented with a
Doubly linked structure
Assume that data are inserted into a binary search tree in the order A B C D E F G. The structure of this tree resembles that of a
List
Examples of linear collections are
Lists and stacks
Choose all the HETEROGENEOUS data structures
Lists, Tuples, Sets, Dictionaries
Insertions and removals from a heap are
Logarithmic operations
A graph collection best represents a
Map of flight paths between cities
An array uses less memory than a singly linked structure when
More than half of its positions are occupied by data
Who is the author of a book entitled "Algorithms + Data Structures = Program"
Niklaus Wirth
Data in a singly linked structure are contained in
Nodes
The linked implementation of a queue uses
Nodes with a link to the next node and an external pointer to the first node and an external pointer to the last node
What is the Big O of the Recursive Fibonacci?
O(2**n)
What is the Big O of the binary search function?
O(log n)
What is the Big O of the merge sort function?
O(n log n)
The worst-case behavior of the search of a binary search tree is
O(n)
What is the Big O of the counting sort function?
O(n)
What is the Big O of the sequential search function?
O(n)
What is the Big O of the bubble sort function?
O(n**2)
What is the Big O of the bubble sort with a tweak function?
O(n**2)
What is the Big O of the insertion sort function?
O(n**2)
What is the Big O of the selection sort function?
O(n**2)
The positional list operation next has
One precondition that hasNext returns True
The map function creates a sequence of the
Results of applying a function to the items in a given collection
The distinguished node at the beginning or top of a tree is called the
Root node
Examples of unordered collections are
Sets and dictionaries
Choose all the examples of an Unordered Collection
Sets, Dictionaries, Bags
It requires constant time to remove the first item from a(n)
Singly linked structure
The items in a priority queue are ranked from
Smallest (lowest priority) to largest (highest priority)
The item removed from a min-heap is always the
Smallest item
Choose all the FUNDAMENTAL data structures in Python
Strings, Lists
Choose all the examples of a Linear Collection
Strings, Lists, Tuples, Stacks, Queues
Choose all the IMMUTABLE data structures
Strings, Tuples
In the circular array implementation of a queue
The front index chases the rear index around the array
A doubly linked structure allows the programmer to move
To the next node or the previous node from a given node
The == operation for two sets must
Verify that the sets are of the same size and that each item in one set is also in the other set
From a user's perspective, a collection is an abstraction, and for this reason, in computer science, collections are also called _________________________.
abstract data types
The operation that inserts an element after the tail of a list is called
add
How is a binary search tree different from a binary tree?
binary tree- a tree whose elements have at most 2 children binary search tree- type of binary tree in which each item in a node's left subtree is less than the item in that node, and each item in the node's right subtree is greater than the item in that node
_____________________ is a method of determining the efficiency of algorithm by counting their basic operation such as addition, multiplication, comparison using simple algebra, pencil and paper.
complexity analysis
Describe one benefit and one cost of a doubly linked structure, as compared to a singly linked structure. Give also an application of a doubly linked structure.
doubly linked structure benefit- accesses data in the next or previous node in constant time singly linked structure benefit- good to use when not accessing the last element because it runs in linear time, thus traversing the entire collection application of doubly linked structure- manages systems with smaller amounts of data for a faster runtime
A sorted collection imposes a ______________________ on its items.
natural ordering