Font size
WorksheetsCSCI-2210-001 - Data Structures - Final Review
Total questions: 99
Worksheet time: 50mins
What is an Array?
A collection of elements of fixed size, continuous memory, and same data type.
A collection of elements with varying data types.
A dynamic data structure that can change its size during execution.
A data structure that uses pointers to connect its elements.
What makes an Array?
How do you access elements in an Array?
What is a Single Dimensional Array?
These are traditional arrays, collections of elements of the same data type, accessible by a single index, all relate along 1-axis in memory.
Extends the concept of single-dimensional arrays by organizing elements in multiple rows and columns (up to 32 in C#) to represent perfect grid-like data structures.
Arrays of Arrays, each new row/column may be differently sized, useful when grouping together disjoint or incomplete data.
To define a method for comparing instances of a class to enable sorting and ordering of objects based on their natural order.
Which is a Single Dimensional Array?
What is a Multi-Dimensional Array?
Extends the concept of single-dimensional arrays by organizing elements in multiple rows and columns (up to 32 in C#) to represent perfect grid-like data structures.
These are traditional arrays, collection of elements of the same data type, accessible by a single index, all relate along 1-axis in memory.
Arrays of Arrays, each new row/column may be differently sized, useful when grouping together disjoint or incomplete data.
A way to store many variables of the same type.
Which is a Multi-Dimensional Array?
What is a Jagged Array?
Arrays of Arrays, each new row/column may be differently sized, useful when grouping together disjoint or incomplete data.
Extends the concept of single-dimensional arrays by organizing elements in multiple rows and columns (up to 32 in C#) to represent perfect grid-like data structures.
These are traditional arrays, collection of elements of the same data type, accessible by a single index, all relate along 1-axis in memory.
An array is a finite sequence that holds a fixed number of elements.
Which is a Jagged Array?
What is a Generic
Allow for flexible and reusable code by parameterizing types as a “placeholder” and enabling the use of different data types in a consistent manner
Grow or shrink in size and stores a collection of elements in a contiguous block of memory.
To define a method for comparing instances of a class to enable sorting and ordering of objects based on their natural order.
Involve evaluating elements to determine their relative order or equality.
What is an Array List?
An array that grows or shrinks in size and stores a collection of elements in a contiguous block of memory.
A collection of elements with a fixed size and continuous memory.
An array with elements of varying data types.
A linked list that dynamically adjusts its size.
When would you use an Array List?
When you need a flexible and efficient data structure to store and manipulate a collection of elements that may change in size.
To define a method for comparing instances of a class to enable sorting and ordering of objects based on their natural order.
When you need a inflexible and efficient data structure to store and manipulate a collection of elements that stay one size.
When you need a flexible and efficient data structure to store and manipulate a collection of ints that may change in size.
What is the IComparable Interface
To define a method for comparing instances of a class to enable sorting and ordering of objects based on their natural order.
Exchanging elements in a data structure, one of the most expensive operations in a sorting algorithm, good idea to reduce the number of swaps if possible.
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
Builds the final sorted array one item at a time, efficiently inserting each element into its proper place within the sorted part of the array.
What does the CompareTo Method do?
Compares two values together, returning a positive value if the first object is greater, a negative value if it's smaller, and zero if they are equal.
To define a method for comparing instances of a class to enable sorting and ordering of objects based on their natural order.
Involve evaluating elements to determine their relative order or equality.
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
What are Swaps?
Exchanging elements in a data structure, one of the most expensive operations in a sorting algorithm, good idea to reduce the number if possible.
Involve evaluating elements to determine their relative order or equality.
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
Builds the final sorted array one item at a time, efficiently inserting each element into its proper place within the sorted part of the array.
What are Comparisons?
Involve evaluating elements to determine their relative order or equality.
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
Builds the final sorted array one item at a time, efficiently inserting each element into its proper place within the sorted part of the array.
Repeatedly selects the minimum element from the unsorted part of the list and moves it to the beginning.
What is Bubble Sort?
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order; it has an average and worst-case time complexity of O(n^2).
Builds the final sorted array one item at a time, efficiently inserting each element into its proper place within the sorted part of the array; it has an average and worst-case time complexity of O(n^2).
Repeatedly selects the minimum element from the unsorted part of the list and moves it to the beginning, effectively dividing the list into a sorted and unsorted portion; it has an average and worst-case time complexity of O(n^2).
Divides the unsorted list into smaller sublists, sorts them, and then merges the sublists back together to create a fully sorted list; it has a time complexity of O(n log n).
Which is Bubble Sort?
What is Insertion Sort?
Builds the final sorted array one item at a time, efficiently inserting each element into its proper place within the sorted part of the array; it has an average and worst-case time complexity of O(n^2)
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order; it has an average and worst-case time complexity of O(n^2)
Repeatedly selects the minimum element from the unsorted part of the list and moves it to the beginning, effectively dividing the list into a sorted and unsorted portion; it has an average and worst-case time complexity of O(n^2)
Divides the unsorted list into smaller sublists, sorts them, and then merges the sublists back together to create a fully sorted list; it has a time complexity of O(n log n)
Which is Insertion Sort?
What is Selection Sort?
Repeatedly selects the minimum element from the unsorted part of the list and moves it to the beginning, effectively dividing the list into a sorted and unsorted portion; it has an average and worst-case time complexity of O(n^2).
Divides the unsorted list into smaller sublists, sorts them, and then merges the sublists back together to create a fully sorted list; it has a time complexity of O(n log n).
Selecting a "pivot" element, partitioning the other elements into two sub-arrays according to whether they are less than or greater than the pivot, and then recursively sorting the sub-arrays; it has an average time complexity of O(n log n), but can degrade to O(n^2) in the worst case.
Counting the frequency of each element in the input list, then using this information to place the elements in sorted order; it has a time complexity of O(n + k).
Which is Selection Sort
What is Merge Sort?
Divides the unsorted list into smaller sublists, sorts them, and then merges the sublists back together to create a fully sorted list; it has a time complexity of O(n log n).
Selecting a "pivot" element, partitioning the other elements into two sub-arrays according to whether they are less than or greater than the pivot, and then recursively sorting the sub-arrays; it has an average time complexity of O(n log n), but can degrade to O(n^2) in the worst case.
Counting the frequency of each element in the input list, then using this information to place the elements in sorted order; it has a time complexity of O(n + k).
Processing the individual digits or characters of elements in the list, grouping them by each digit's value, and repeating this process for all digits or characters; its time complexity is typically O(nk).
Which is Merge Sort?
What is Quick Sort?
Selecting a "pivot" element, partitioning the other elements into two sub-arrays according to whether they are less than or greater than the pivot, and then recursively sorting the sub-arrays; it has an average time complexity of O(n log n), but can degrade to O(n^2) in the worst case.
Counting the frequency of each element in the input list, then using this information to place the elements in sorted order; it has a time complexity of O(n + k).
Processing the individual digits or characters of elements in the list, grouping them by each digit's value, and repeating this process for all digits or characters; its time complexity is typically O(nk).
Repeatedly selects the minimum element from the unsorted part of the list and moves it to the beginning, effectively dividing the list into a sorted and unsorted portion; it has an average and worst-case time complexity of O(n^2).
Which is Quick Sort?
What is Counting Sort?
Counting the frequency of each element in the input list, then using this information to place the elements in sorted order; it has a time complexity of O(n + k).
Processing the individual digits or characters of elements in the list, grouping them by each digit's value, and repeating this process for all digits or characters; its time complexity is typically O(nk).
Divides the unsorted list into smaller sublists, sorts them, and then merges the sublists back together to create a fully sorted list; it has a time complexity of O(n log n).
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order; it has an average and worst-case time complexity of O(n^2).
Which is Counting Sort?
Which is Counting Sort?
What is Radix Sort?
Processing the individual digits or characters of elements in the list, grouping them by each digit's value, and repeating this process for all digits or characters; its time complexity is typically O(nk).
Counting the frequency of each element in the input list, then using this information to place the elements in sorted order; it has a time complexity of O(n + k).
Selecting a "pivot" element, partitioning the other elements into two sub-arrays according to whether they are less than or greater than the pivot, and then recursively sorting the sub-arrays; it has an average time complexity of O(n log n), but can degrade to O(n^2) in the worst case.
Divides the unsorted list into smaller sublists, sorts them, and then merges the sublists back together to create a fully sorted list; it has a time complexity of O(n log n).
Which is Radix Sort?
What is Unit Tests?
Testing small pieces of code in isolation, usually involves testing a single method or small module.
Testing subsystems and their interactions with other subsystems, usually involves testing with an outside file or database.
Testing the resource footprint of typical operations within a system, usually involves stress testing a system with large quantities of worse-case-scenario data.
Testing the business use-cases of the system, usually involves usability testing to ensure that a system is relatively intuitive for the customer to use.
What is Integration Test
Testing subsystems and their interactions with other subsystems, usually involves testing with an outside file or database.
Testing small pieces of code in isolation, usually involves testing a single method or small module.
Testing the resource footprint of typical operations within a system, usually involves stress testing a system with large quantities of worse-case-scenario data.
Testing the business use-cases of the system, usually involves usability testing to ensure that a system is relatively intuitive for the customer to use.
What is Performance Test?
Testing the resource footprint of typical operations within a system, usually involves stress testing a system with large quantities of worse-case-scenario data.
Testing small pieces of code in isolation, usually involves testing a single method or small module.
Testing subsystems and their interactions with other subsystems, usually involves testing with an outside file or database.
Testing the business use-cases of the system, usually involves usability testing to ensure that a system is relatively intuitive for the customer to use.
What is Acceptance Tests
Testing the business use-cases of the system, usually involves usability testing to ensure that a system is relatively intuitive for the customer to use.
Testing small pieces of code in isolation, usually involves testing a single method or small module.
Testing subsystems and their interactions with other subsystems, usually involves testing with an outside file or database.
Testing the resource footprint of typical operations within a system, usually involves stress testing a system with large quantities of worse-case-scenario data.
Why do Unit Testing?
Allows any developer to quickly verify their program after modification.
Involves usability testing to ensure that a system is relatively intuitive.
Testing the resource footprint of typical operations within a system.
Testing small pieces of code in isolation, usually involves testing a single method or small module.
Which is a Queue?
What is FIFO?
First-In-First-Out.
Place something to the back of the line.
Pull something off the front of the line.
View the thing at the front of the line without removing it from the queue.
What is Enqueue?
Place something to the back of the line.
First-In-First-Out.
Pull something off the front of the line.
View the thing at the front of the line without removing it from the queue.
What is Dequeue?
Pull something off the front of the line.
Place something to the back of the line.
First-In-First-Out.
View the thing at the front of the line without removing it from the queue.
What is Peek?
View the thing at the front of the line without removing it from the queue.
Pull something off the front of the line.
Place something to the back of the line.
First-In-First-Out.
Which is a Stack?
What is LIFO?
Last-In-First-Out.
Place something onto the top of the stack.
Pull something off the top of the stack.
View top of the stack without popping it off.
What is Push?
Place something onto the top of the stack.
Pull something off the top of the stack.
View top of the stack without popping it off.
Last-In-First-Out.
What is Pop?
Pull something off the top of the stack.
View top of the stack without popping it off.
Last-In-First-Out.
Place something onto the top of the stack.
What is Peek?
View top of the stack without popping it off.
Last-In-First-Out.
Place something onto the top of the stack.
Pull something off the top of the stack.
What are Priority Queues?
Priority queues let you maintain a queue that lets some elements
“jump in line”.
Collection of nodes that contain data, each node is “connected” to the next by a reference, starting node is “head” and last node is called “tail".
Collection of nodes that contain data, each node is “connected” to the next and previous by a reference, starting node is “head” and last node is called “tail".
The tail’s next node references the head node.
What is a Singly Linked List
Collection of nodes that contain data, each node is “connected” to the next by a reference, starting node is “head” and last node is called “tail".
Collection of nodes that contain data, each node is “connected” to the next and previous by a reference, starting node is “head” and last node is called “tail".
The tail’s next node references the head node.
The head’s previous node references the tail node.
Which is a Singly Linked List?
What is a Doubly Linked List?
Collection of nodes that contain data, each node is “connected” to the next and previous by a reference, starting node is “head” and last node is called “tail".
Collection of nodes that contain data, each node is “connected” to the next by a reference, starting node is “head” and last node is called “tail".
The tail’s next node references the head node.
The tail’s next node references the head node, the head’s previous node references the tail node.
Which is a Doubly Linked List?
What is a Circular Linked List?
Singly linked list
i) The tail’s next node references the head node.
Doubly linked list:
i) The tail’s next node references the head node.
ii) The head’s previous node references the tail node.
Collection of nodes that contain data, each node is “connected” to the next and previous by a reference, starting node is “head” and last node is called “tail".
Collection of nodes that contain data, each node is “connected” to the next by a reference, starting node is “head” and last node is called “tail".
let you maintain a queue that let’s some elements “jump in line".
Which is a Circular Linked List?
What are the 3 A's of Unit Testing?
Arrange, Act, Assert
Answer, Act, Assert
Arrange, Action, Assert
Arrange, Act, Assist
What is a Tree?
Graph or network of nodes with no cycles
Graph or network of nodes with 1 cycles
Graph or network of nodes with 2 cycles
Graph or network of nodes with 3 cycles
What is a Root?
At the top of the tree, has no parent node
At the bottom of the tree, has one parent node
At the top of the tree, has one parent node
At the bottom of the tree, has no parent node
What is a Leaf?
Node that has no pointer to other nodes
Node that has one pointer to other nodes
Node that has two pointer to other nodes
Node that has three pointer to other nodes
What is a Subtree?
A subtree is a portion of a tree that consists of a node and some of its descendants.
What is Depth?
Number of connections from node to the Root
Number of connections from node to the Leaf
Number of connections from node to the Subtree
Number of connections from node to the the Parent
A tree with 'n' nodes must have how many edges?
What is Height?
Which is "In Order Traversal"
Which is "Pre Order Traversal"?
Which is "Post Order Traversal"?
What is a Binary Tree?
A subset of trees where each node links to at most 2 child nodes
A subset of trees where each node links to at most 3 child nodes
A subset of trees where each node links to at most 1 child node
A subset of trees where each node links 0 child nodes
What is a Binary Search Tree?
Imposes a restriction on child nodes and the data on each node must be comparable
A tree structure where each node has a value greater than its parent node.
A tree with a constant time complexity for all operations.
A tree where all nodes have exactly two children.
What restrictions are placed on child nodes on BSTs?
The value of the data held in the left child is less than the parent node
The value of the data held in the right child is more than the parent node
The value of the data held in the left child is more than the parent node
The value of the data held in the right child is less than the parent node
The value of the data held in the left child is less than the parent node
The value of the data held in the right child is equal to the parent node
The value of the data held in the left child is equal to the parent node
The value of the data held in the right child is more than the parent node
What are the 3 main cases for removing from a BST?
1. Node has no children
2. Node has 1 child
3. Node has 2 children
1. Node has no children
2. Node has 1 child
3. Node has 3 children
1. Node has no children
2. Node has 2 children
3. Node has 4 children
1. Node has 1 children
2. Node has 2 children
3. Node ha s3 children
What is a Heap?
A type of memory leak
A data structure representing a hierarchical tree structure
A type of sorting algorithm
A networking protocol for secure communication
What is a Min-Heap?
The value of each node must be greater than the value of its parent node.
The value of each node must be less than the value of its parent node.
The value of each node must be greater than or equal to the value of its parent node.
The value of each node must be less than or equal to the value of its parent node.
What is a Max-Heap?
The value of each node must be greater than the value of its parent node.
The value of each node must be less than the value of its parent node.
The value of each node must be greater than or equal to the value of its parent node.
The value of each node must be less than or equal to the value of its parent node.
When filling a binary heap, which of the following statements is true?
All levels of the tree must be fully filled, except the last one, which must be filled from left to right.
All levels of the tree must be partially filled, with equal distribution of nodes.
All levels of the tree must be fully filled, including the last one.
The last level of the tree must be fully filled, while the preceding levels can have empty spaces anywhere.
Why is a binary heap commonly used in computer science?
Because it has a runtime of O(N * logN) and a space usage of O(1)
Due to its superior space efficiency
Because it has a runtime of O(logN) and a space usage of O(N)
Because it guarantees constant time complexity for all operations
How is the process of "heapify up" in a binary heap typically implemented?
Compare the last element added to its parent; if bigger, then swap, and repeat as necessary.
Starting from the root, compare the element with its left and right children, swapping as necessary.
Move through the levels of the tree from left to right, ensuring each node is greater than its parent.
Begin at the last leaf node and compare it with its ancestors, swapping if necessary, until the root is reached.
What is a common approach to implementing "heapify down" in a binary heap?
Compare the root node to its children; if the item is smaller than either child, then swap with the largest child.
Move through the levels of the tree from left to right, comparing each node with its children and swapping as necessary.
Starting from the last element added, compare it with its parent, and swap if the value is larger, repeating as necessary.
Swap the last leaf node with the root and trickle it down until it satisfies the heap property.
What best describes a Binomial Heap?
Set of Binomial trees with distinct orders, it squares itself every time you add a node.
A binary tree structure where each node has a value greater than or equal to its parent.
A heap structure with a runtime of O(N * logN) and a space usage of O(1).
A linked list representation of elements with constant time complexity for all operations.
How is a new element typically added to a Binomial Heap?
A new node is added to the "forest" of trees as a new tree of order 0. If there is already a tree of order 0, then merge the two trees. Repeat this process until there is a new tree with a unique order.
The new element is inserted as the leftmost child of the root node.
The element is compared with the root, and if it is smaller, it becomes the new root.
The element is added as a child of the node with the closest value in the heap.
What is a common step in the process of removing an element from a Binomial Heap?
Add all children to the "forest" of trees in the heap.
Replace the element with the last leaf node in the heap.
Compare the element with its children and swap with the larger child if necessary.
Traverse the heap in a bottom-up manner, adjusting nodes to maintain the heap property.
What is a notable advantage of using Binomial Heaps?
Binomial heaps keep heaps shallow, and insertions are O(log N).
Binomial heaps guarantee a space usage of O(1) for all operations.
Binomial heaps maintain a constant time complexity for insertions.
Binomial heaps ensure a sorted order of elements, minimizing search times.
How would you describe a Fibonacci Heap?
Similar to a Binomial Heap, in that it is a set of binomial trees and does not restrict to distinct orders.
A heap structure that allows only distinct orders of binomial trees.
A heap with a runtime of O(log N) for all operations.
A binary tree structure where each node has a value greater than or equal to its parent.
What is a notable advantage of using a Fibonacci Heap?
Insertions are constant time, unions with other Fibonacci heaps are constant time, and if we wait to clean up our heap, minimum extractions are constant time.
Insertions are guaranteed to be logarithmic in time complexity.
Unions with other Fibonacci heaps are logarithmic in time complexity.
Minimum extractions are guaranteed to be logarithmic in time complexity.
What is a primary goal of balanced trees?
Reducing the maximum depth of a tree.
Maximizing the height of the tree for efficient traversal.
Minimizing the space complexity of the tree.
Ensuring all nodes have an equal number of children.
Why is achieving balance in a tree structure desirable?
Faster access times; the shallower the tree, the faster searching will be, and searches can be performed in O(log2N) time.
To ensure equal distribution of nodes.
To reduce memory usage.
To simplify the tree structure and improve readability.
What best describes an AVL tree in computer science?
A self-balancing binary search tree where the height difference between the left and right subtrees of any node is at most 1.
A linked list representation of elements with logarithmic time complexity for search operations.
A binary tree that guarantees constant time complexity for all operations.
A tree structure where each node has a value greater than its parent node.
What are the fundamental rules for a Red-Black Tree?
A node is either red or black; the root and leaves are always black or null. If a node is red, then its children are black.
A node is either red or black; the root and leaves are always red or null.
Nodes can be any color, and the root and leaves are always red.
All nodes must be black, and the root and leaves are always red.
What is a One-Way function?
Given the input, one could deduce the output X. Given the output of a function, one could NOT deduce the input Y
A function where the output is always equal to the input.
Given the output of a function, one could deduce the input X.
A function that only accepts one type of input and produces one type of output.
What is a Associative Array?
A collection of elements, each identified by a unique key or index.
An array where elements are arranged in ascending order
The abstract idea of what we are about to discuss in terms of use and functionality.
An array where elements are grouped based on their similarities.
What is a Hash Table and Hash Tree?
An associative arry whose underlying data structure is an array or tree-like structure.
A table that stores elements in a random order using hash functions.
A tree structure that organizes elements based on their hash values.
A data structure that maps keys to values without the use of hash functions.
What is a dictionary?
An associative array of key-value pairs allowing for quick access to values based on unique keys.
A data structure that uses hashing for efficient element retrieval.
An ordered collection of elements.
A linked list representing elements with constant time complexity for all operations.
What is Probing?
A method for storing values, if an index has a key-value pair, continue to the next index.
A process for resizing a hash table to accommodate more elements.
A method for handling collisions by finding the last used index.
A technique for searching elements in a sorted array.
What is Rehashing?
A method for resizing a hash table to accommodate more elements by rerunning your hashing algorithm.
A technique for searching elements in a hash table.
A process for handling collisions by finding the next available index.
A method for storing values, if an index has a key-value pair, continue to the next index.
What is Chaining?
A method for handling collisions by creating a linked list at each index that house multiple key-value pairs
A technique for searching elements in a hash table.
A process for resizing a hash table to accommodate more elements.
A method for storing values, if an index has a key-value pair, continue to the next index.
For a Queue, what is a underlying data structure that has constant time?
Linked List
Binary Tree
Stack
Array
In what way is the memory formatted in a Linked List?
Disjointed
Fragmented
Overlapping
Continuous
Which snippet of code is most likely to remove a node from a doubly linked list?
current_node.prev.next = current_node.next;
current_node.next.prev = current_node.prev;
current_node.next = current_node.next.next;
current_node.prev.next = current_node.next;
current_node.next.prev = current_node.prev;
Which snippet of code is most likely to insert a new node into a doubly linked list before a given node?
In what scenarios would you typically use a tree data structure?
Any time you have a hierarchy
Any time you need a linear structure for quick access.
Any time you need constant time complexity for all operations.
Any time you need a collection of elements with varying data types.
What is the Big O Notation for a Balanced Binary Search Tree?
O(Log₂ N)
O(N)
O(N*log₂ N)
O(N²)
Why is a Balanced BST better than a regular tree?
Constraints added to BSTs allow for better performance than regular trees.
Balanced BSTs have a more straightforward structure.
Regular trees have a constant time complexity for all operations.
Regular trees have a logarithmic time complexity for all operations.
