Data Structure And Algorithms
What is interpolation search?
An improved binary search for numbers that are longer where binary search would be inefficient for example phone numbers
What are the ways you can implement a queue?
Array and Linked List
What Are The Different Implementations Of A Stack
Array, and LinkedList
What Are The Methods Used For A Queue?
Constructor create a new queue that is empty. And Returns The Empty Queue. Enqueue(item) adds new item to the rear of the queue and returns nothing. Dequeue() removes the front item from the queue and return the item. isEmpty() returns a boolean. size() returns the number of items in the queue.
When would you want to use hash table over binary search tree?
Hash table is faster with O(1) to binary O(logn). But When You Want To Sort Binary Search Tree Is Better.
What Is The Space Complexity Of A Singly Linked List?
O(n)
What is the big O of interpolation search?
O(n)
What Is The Best, Average, Worst, and Space Complexity Of Bubble Sort?
O(n), O(n2), )(n2), and O(1)
What Is The Best, Average, Worst, and Space Complexity Of Selection Sort?
O(n2),O(n2),O(n2),0(1)
What Is The Best, Average, Worst, and Space Complexity Of Quick Sort?
O(nlogn), O(nlogn), O(n2), O(logn)
What Is Best, Average, Worst, and Space Complexity Of Heap Sort?
O(nlogn), O(nlogn), O(nlogn), O(1)
What Is The Best, Average, Worst, and Space Complexity Of Merge Sort?
O(nlogn), O(nlogn), O(nlogn), O(1)
When working with a single linked list which nodes should we know?
Only The Header
What Are The 4 Methods Of A Stack And What Do They Do?
Push, Pop, Peek, isEmpty
What Are The Three Methods Of A Queue?
Queue Has Enque Which Adds, And Deque Which Deletes, also isEmpty
What Is A Queue?
Queue is a FIFO data structure
What Is Recursion?
Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem (as opposed to iteration).
What Is A Binary Search Tree?
Same as binary tree, but data is sorted. Right Is Higher, and Left Is Less
What Is A Double Linked List?
Same as single linked list, but has a previous pointer together with a next pointer.
When should you use linked list over array?
You want to insert into a middle of a list, or you need constant-time insertions and deletions
What Are The Methods We Should Use In Creating A Doubly Linked List
class DoublyLinkedList(object): def __init__(self, value) self.value = value; self.next_node = None self.prev_node = None
Create The Node Class Of A Linked List.
class Node { int value; Node next; }
What does the node class in a binary tree have?
class Node{ int value; Node left; Node right; }
What are the methods and parameters for the node class of a singly linked list?
constructor(value) self.value = value self.nextnode = None
What attributes should we have?
n the size, capacity, and A.
What is a example of a base case in recursion?
n! if n == 0 then it is 1
What does the tail node of a singly linked list reference?
null
What does the node constructor look like in a double linked list?
struct Node { int data; struct Node *next; struct Node *prev; }
What does the node class store in a singly linked list?
value, and reference
How Do you create a two-dimensional array with javascript?
var items = [ [1, 2], [3, 4], [5, 6] ];
What are the 4 steps to inserting a node into a linked list?
1. Create A New Code. 2. Set Its Element To The New Element. 3. Set Its Next Link To Refer To The Current Head 4. Set The List's Head To Point To The New Node
What are the 4 steps to inserting a node into the tail of a singly linked list?
1. Create A New Node. 2. Assign Its Next Reference to None. 3. Set the next reference of the tail to point to this new node. 4. Then update the tail reference itself to this new node.
What Is A Hash Table?
A Data Structure With A Key Value Pair.
What Is A Queue?
A First In First Out Data Structure.
What is a queue?
A First In First Out Data Structure.
What Is A Stack
A LIFO Or FILO Data Structure.
What Is A Stack?
A LIFO, last-in first-out data structure.
What Is A Linked List?
A Linear Data Structure With A Node Class That Had Nodes That Are Linked With Pointers.
What Is A Singly Linked List?
A collection of nodes that collectively form a linear sequence/
What Is Deque?
A double-ended queue. Where new items can be added at either the front or the rear. Also Existing Items Can Be Removed From Either End.
What Is A Priority Queue?
A priority queue is different from a "normal" queue, because instead of being a "first-in-first-out" data structure, values come out in order by priority. A priority queue might be used, for example, to handle the jobs sent to the Computer Science Department's printer: Jobs sent by the department chair should be printed first, then jobs sent by professors, then those sent by graduate students, and finally those sent by undergraduates.
What Is A Binary Tree?
A tree has a node and no more two childs can have 0,1, or 2 children. In a tree we only have a root node.
What Is Big O Complexity Of Arrays
Access: O(1) Search: O(n) Insertion: O(n) Deletion: O(n)
What Is The Complexity Of A Queue?
Access: O(n) Search: O(n) Insert: O(1) Delete: O(1)
What Is Big O Complexity Of Stack
Access: O(n) Search: O(n) Insertion: O(1) Deletion: O(1)
What Is The Complexity Of A Single Linked List?
Access: O(n) Search: O(n) Insertion: O(1) Deletion: O(1)
What Is The Worst Code Complexity Of A Singly Linked List?
Access: O(n) Search: O(n) Insertion: O(1) Deletion: O(1)
What is The Average Code Complexity Of A Singly Linked List?
Access: O(n) Search: O(n) Insertion: O(1) Deletion: O(1)
What is the complexity of a doubly linked list?
Access: O(n) Search: O(n) Insertion: O(1) Deletion: O(1)
What methods should we have in a dynamic array, and what should they do?
Constructor which makes attributes n = 0, capacity equal 1, and A call self.make_array. len return length; getItem takes k parameter and returns at index k. Append with ele paramater. A Resize method with new_cap as parameter that makes array larger. new_array that takes new_cap parameter.
What Are The Methods We Need To Create A Deque And What Do They Do?
Deque() creates a new deque that is empty. addFront(item) adds item to front and returns nothing. addRear(item) adds a new item to the rear of the deque and returns nothing. removeFront() removes the front items and returns the item. removeRear() removes and returns the item.isEmpty() returns boolean. size() returns the number of items.
What Is The Difference Between A Singly Linked List, and A Doubly Linked List?
Doubly Linked List Node Keeps A Reference To The Node Before, and After.
What are the two reasons to use recursion?
First is when Recursion is used as a technique in which a function makes one or more calls to itself.Second is when a data structure uses smaller instances of the exact same type of data structures when it represents itself.
What is binary search?
For this to work your data has to be sorted we then search the middle element and compare if value is greater or less then. Once this is answered we can then cut the elements in half. So after every loop the elements are cut in half. We go from 8->4->2->1 so the complexity of this is O(logn)
What Makes A Hash Table Powerful?
Look up of associated values in constant time.
What is linear search?
Looping through each item in a array one by one.
What Does The Nodes Last Pointer Refer To In A Single Linked List?
Null
How Does Search Work In A Linked List?
You access the first Node Then Go Through Each Node.
What Is Quick Sort?
Say We Have An Array 6-8-2-4-3-8-1 First thing we have to do is find the pivot we choose 4, so now we have a left array, and right array. Then we check first element on left which is 6 if 6 > 4 then we stop and then we check if 1 < 4 and stop, then we switch then no we have. Once finished we repeatedly make an array half smaller again and do again.
When To Use Interpolation Search?
Say we have longer numbers in are array like 1166. Binary search would be inefficient. And we would use interpolation
What Is The Worst Case Time Complexity Of A Hash Table?
Search: O(n) Insert: O(n) Delete: O(n) Access: O(n)
What Is The Average Cast Time Complexity Of A Hash Table?
Search:O(1) Insertion:O(1) Deletion:O(1) Access:O(n)
What Is a Hashset?
Similar to linked list, but elements must be unique
What Are The Methods We Should Have If We Created A Stack Class?
Stack() creates a new stack that is empty. It needs no parameters and returns an empty stack. push(item) adds item to top of stack and returns nothing. pop() removes item and returns it. peek() returns the top item no params. isEmpty() returns a boolean. size() returns number of items on the stack and it needs no parameters
What Are The Three Linear Structures That Are Similar To Arrays, But Are Different By How It Adds And Removes Items.
Stack, Queues and Deques
What Is Big Theta Notations?
The Average Case Scenario Of The Code Written.
What Is Big Omega Notation?
The Best Case Scenario Of The Code Written
What Is Big O Notations?
The Studying Of The Worst Case Scenario Of The Code We Wrote
What are the two parts to recursion?
The base case, and recursive method.
What is Bubble Sort?
To do the bubble sort, take the first element, and compare to the seconds element and swap if not sorted. Then move to compare 2nd and 3rd. Then 3rd and 4th. Once finished we would then only compare up to 3.
What methods for implementing a double linked list?
Traverse, Insert, Remove, and isEmpty
What is the process of going through all the nodes in a linked list?
Traversing
What Is Merge Sort?
Uses divide and dequeue.If we have an array of 8 we divide it to 2 arrays of 4, then 4 of 2, then 8 of 1, and solve each individually and merge back together to 4 arrays of 2, then 2 arrays of 4, then 1 array of 8. The time complexity is O(nlogn), the space complexity is O(n)
What Are The Two Parts Of The Node Class In A Linked List?
Value and Pointer
What is advantage over single linked list?
We can have a traversal that goes both ways.
What Is Selection Sort?
We first find the minimum value in the array.The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list.
What are methods to implement a hash table?
get(K key), getSize(), add(), remove(), isEmpty()
What are the names of the first and last node in linked list?
head and tail
We add special nodes in a doubly linked list what are they , and where do they go?
header and the beginning, and a trailer at the end
What Is Heap Sort?
heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. The improvement consists of the use of a heap data structure rather than a linear-time search to find the maximum.[2]