Linear Data Structures Flashcards

1
Q

What is Big O notation?

A

Big O is a mathematical notation that describes the limiting behavior of a function where the argument tends toward a particular value or infinity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Big-O?

A

Helps us determine if an algorithm is scale-able or not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When do we use Big O notation?

A

Describe the performance of an algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the five common Big-O curves?

A

O( 1 ) - constant time

O ( n ) - linear time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the five common time complexity curves?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does linear big - O grow?

A

Linearly and in direct proportion to the size of the input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is O(n^2)?

A

Quadratic.

Nested loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does the logarithmic curve behave?

A

It slows down as the input size grows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is exponential time complexity?

A

The exponential curve grows faster as the input grows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the shortcut to run JVM in debug?

A

Control + D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When would we have a quadratic Big-O value?

A

When we use nested loops that each performs an iteration over the entire set of values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the linear data structures?

A
  1. Arrays
  2. Linked Lists
  3. Stacks
  4. Queues
  5. Hash Tables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are arrays?

A

Reference type

fixed-length data structure.

Values are indexed sequentially in memory.

Optimal for looking up values by their index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What can we use arrays for?

A

We use arrays to store lists of values like strings, objects or anything.

These items are stored sequentially in memory.

Can store strings, objects, numbers or anything.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the pro’s of arrays?

A

Looking up the index is very fast

why?

item index lookup doesn’t involve loops or complex data access operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the disadvantages of arrays?

A

They’re fixed length.

Not good for storing values that need to be added or deleted frequently.

Adding or deleting an item requires copying old array into a new array with a cost of O(n).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do we keep track of the number of items in our array?

A

Using a private variable “count

increment count for each new item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do we implement resizeIfRequire ( ) in our addItem method of our array class?

A

Create a new array x 2 size

copy items into new array

O ( n ) operation!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How do we implement the removeAt ( ) method in our array class?

A

Shift items left

Copy items from [index + 1] into [index]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How can we implement the print ( ) method in our custom array class?

A

Use a for loop to iterate over each index

+ print on console

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How can we implement the max ( ) method in our Array class?

A

What is run time complexity?

O(n):

have to iterate over the entire array to find the largest number.

This number may be at the end of the array (worst case scenario).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How to implement the insertAt ( ) method in our Array class?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How to implement the reverse ( ) method in our Array class?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How to implement the intersect ( ) method in our Array class?

A

Foreach loop + nested if loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is the Big-O of the addItem ( ) to an array?

A

It’s O(n)

linear time complexity

Why?

Array’s are static in size.

In the worst case, we have to create a new array, copy all items to this array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the Big O of the removeAt ( ) operation in arrays?

A

O(n) - Linear time complexity.

Why?

Worst case it’s the first item in the array, then we have to shift all items over which is an O(n) operation!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is the Big O of find by value in an array?

A

O ( n )

Worst case have to iterate the entire array!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the Big-O of lookup by index in an array?

A

O(1)

why?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is the syntax for working with Arrays in Java?

A

Two ways :

Create with an empty array

Insert values, omit the new operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is the Array’s class in Java?

A

Declared in Java.util

Static methods to perform operations on Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What are the two implementations of dynamic arrays in Java?

A

Vector class:

will grow by 100% of size when full

methods are synchronized (single thread access)

ArrayList class:

will grow by 50% of size when full

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What are useful ArrayList methods?

A

.add(item) - dynamic adds item

.remove(index) - removes item at index

.contains(item) - boolean if item is in list

.size( )- # of items in array

.toArray - converts to regular array object, not arrayList class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

AA What are circular arrays?

A

Very important, powerful concept in data structures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What is covered in the linked-list collection?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What are linked lists?

A

A data structure consisting of a group of nodes in sequence.

Each node contains one value and one address for the next node.

Unlike array’s linked-lists can grow automatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

When do we use linked-lists?

A

In building more complex data structures

they are the second most common after Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What are the key differences between Arrays and LinkedLists?

A

Dynamic arrays:

ArrayList - Grow by 50-100% of the size, wasting memory

LinkedLists:

Don’t waste memory

require extra memory for storing the next node location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How do you work with a linked-list in java?

A

java.util.LinkedList package

can access pre-built methods

.insert ( )

.delete ( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What should we always access when we use java.util LinkedList class?

A

Integer class (primitive wrapper)

Because we are using the integer class

A wrapper class for the primitive integer

Not, a primitive type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

LL If we don’t declare the type in a LinkedList class what can we store automatically?

A

Any type of object

could be a string

could be an integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

What are the operations on Linked Lists?

A

AddLast ( )

AddFirst ( )

IndexOf ( )

Contains ( )

RemoveFirst

RemoveLast

Reversing LinkedList

kth-node from end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

LL What are the run time complexities of the insert ( ) method on linked - lists?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

What is the Big-O time complexity for various operations on linked-lists?

A

addFirst - O(1)

addLast - O(1)

removeFirst - O(1) - update head to point to next item

removeLast - O(n) - getPrevious method is an O(n) operation

contains - O(n) - traverses entire list to look for item (worst case))

indexOf - O(n) - traverses entire list to look for item (worst case))

toArray - O(n) - traverse entire list of nodes, storing into an array

getPrevious - O(n) - traverse entire list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What is the run-time complexity of the various linked operations?

A

Lookup

By value = O(n) - because the value we are looking for may be stored in the last node (worst case).

By index = O(n) - the nodes of the linkedlist may be all over in memory, each node has to keep a reference of the next node, in worst case scenario you have to traverse all the nodes to find the index.

Insert

At end = O(1) - Just need to create a new node and have end (tail) point to it.

at beginning = O(1) - just need to create a new node and have start (head) point to it.

middle = O(n) - have to iterate over entire list, incrementing an index variable before inserting new node.

Delete

at end = O(n) because have to interate entire list to find the reference to the last node (tail).

at beginning = O(1)

middle = O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

How do we implement the private Node class in our LinkedList class in Java?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

How do we implement the addLast method in our LinkedList class in Java?

A

O(1) operation -

create a new node, update last.next to point to it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

How do we implement the addFirst method?

A

O(1) operation

Create a node, set node.next to first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

How do we implement the removeFirst method in our LinkedList class?

A

O(1) operation

update the second item as the first item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

How do we implement the removeLast ( ) method in our LinkedList class?

A

O (n) operation

getPrevious ()

iterates the entire list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

How do we implement the IsEmpty( ) method in a clean modern way?

A

Extract into a private method and call that method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

How do we implement the indexOf (int item) method in our LinkedList class?

A

O(n) operation

traverses entire list search for item (worst case)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

How do we implement the contains ( ) method in our LinkedList class?

A

O(n) operation

indexOf ( ) method

Searches entire list worst case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

How do we implement the getPrevious ( ) method in our LinkedList class?

A

O(n) operation

search entire list for node worst case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

How do we implement the toArray ( ) method in our LinkedList?

A

O (n) operation

copy every node in the list into an array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

How do we implement the reverse ( ) method in our LinkedList class?

A

Popular interview question:

Reverse LinkedList in place.

O(n) runtime complexity

Establish two pointer variables

previous (last) and current (first)

Keep track of the last node with a variable next (n)

iterate through changing the direction of links

then set the last and first nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

How do we implement the getKthFromEnd ( ) in our Linked List class?

A

O(n) operation

Iterate until the end!

Popular Interview Question:

Find the Kth node from the end of a Linked List in one pass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

LL How do we implement printMiddle ( ) in our Linked List class?

A

Find relationships between pointers

Nodes increases by 2 as middle increases by one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

How do we implement hasLoop ( ) method in our Linked List class?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

What are circular LinkedLists?

A

Last node references first node

Doubly and Singly LinkedLists can be circular!

Benefits:

circular navigation!

UI in a form that moves to the first item after completion

Playlists that repeat after the last song

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What is a doubly linked-list?

A

Doubly LinkedList:

O(1) operation for removeLast ( ) !

It has an extra field to reference the next node and the previous node!

Singly linked-lists:

Only have a reference to the next node!

O(n) for delete at end.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

What are stacks?

A

A wrapper around Arrays or LinkedLists

Allows special data access (LIFO)

62
Q

How can we solve real-world problems with stacks?

A

solve many complex real-world problems.

undue feature

forward/backward navigation in a web browser

build compilers

evaluate arithmetic expression

63
Q

What is the LIFO principle?

A

Think of a stack of books

Imagine a stack of books.

Can only add/remove the top book.

Last In First Out Principle (LIFO)

64
Q

What are the four stack operations?

A

Imagine a stack of books.

push ( ) : adds item on top

pop( ) : removes item on top

peek( ) : returns item without removing

isEmpty( ): determine if empty.

65
Q

S What is the internal implementation of stacks?

A

Internally, data and objects are stored in a LinkedList or an Array

Stacks are a special data access wrapper (LIFO)

66
Q

S What is the runtime complexity of various operations on stacks?

A

O ( 1 ) operation

push ( ) : adds item on top

pop( ) : removes item on top

peek( ) : returns item without removing

Why?

addLast ( ), addFirst ( ) , removeLast ( ) are all O ( 1 ) operations in LinkedLists.

67
Q

How can we work with Stacks in Java.util package?

A

Defined in Java.Util package like other data structure classes!

Stacks are generic - can work with any data type (characters, strings, custom objects, integers)

68
Q

How can we implement the reverse ( ) method using a stack?

A

O (n) operation!

Stacks are best friends for reversing the order.

Popular Interview Question:

Write code to reverse a string.

69
Q

What is wrong with how data structure books teach implementation of isBalance ( ) using a stack?

A

It’s really ugly!

refactor using private helper methods and arraylists

70
Q

How do we implement the isBalanced ( ) method using a stack?

A

O (n) operation! forreach ch in input

Popular Interview Question:

Write code to example whether order and pairs of brackets are balanced in a string.

71
Q

How do we implement the push() method using an array in our stack class?

A
72
Q

How do we implement the pop () method using an array in our Stack class?

A
73
Q

How can we implement the peek () method in our stack class?

A
74
Q

How do we implement the isEmpty ( ) using an array in our Stack class?

A
75
Q

How do we implement two stacks using one array to support push ( ), pop ( ), isEmpty ( ) , isFull ( ) on both stacks?

A
76
Q

S How do we implement a MinStack using two stacks?

A
77
Q

What is a queue?

A

A data structure uses removeLast ( )

(FIFO) - first in first out

Think of a line at a restaurant.

First in line, first out of line

78
Q

What real-world problems can queues solve?

A

Specific:

printers

OS allocation

Web Servers

live chat applications

General:

Any application in which a client (mobile device) needs access to a single resource (server).

79
Q

What are the queue operations?

A

enqueue ( ): add the item to back of the queue

dequeue ( ): remove the item from the front of the queue

peek ( ): look at the item at front of the queue without removing it

isEmpty( ): check if queue is empty

isFull( ) : check if queue is full

80
Q

What are the various run-time complexities for operations on queues?

A
81
Q

What is a queue in Java?

A

An interface - cannot instantiate it

Implementing class (Java):

ArrayDeque (double-ended) - uses resizeable array

LinkedList (90% of time) - uses linkedlist

**Interface - tells implementing classes what methods a queue should have

82
Q

What are the two most common implementations of the queue interface?

A

ArrayDeque

LinkedList

*two most common interface implementation

*interface cannot be instantiated

*interface contains methods

83
Q

What are the queue methods in Java?

A

Computer Science:

enqueue ( )

dequeue ( )

Java Programming:

add ( ) - adds item to queue, throws exception if full

offer ( ) - adds item to queue

poll ( ) - removes item from queue, if empty returns null

remove ( ) - removes item from queue, if empty returns exception

84
Q

What are the three ways to implement the queue data structure?

A

Array, LinkedList, Stack

Popular Interview Question:

implementations queue using Array, Stack or LinkedList

85
Q

How do we implement the reverse( ) method on a queue using a stack?

A

Popular Interview Question:

Reverse a queue

86
Q

What is the algorithm for implementing dequeue ( ) using an array?

A

O (1) operation!

87
Q

How do we implement enqueue() using an array?

A
88
Q

How do we implement the dequeue() method using an array?

A

create a variable front.

change item in front to 0

increase front++

89
Q

Why do we need circular arrays for our queue class?

A

The deQueue operation causes empty spaces in the array.

The rear variable eventually points to an index out of bounds

we need a way to store items in the previous index positions while maintaining our queue order

the array index from previously deleted elements could be used to increase array capacity using an equation

90
Q

What is the circular array implementation of dequeue() method?

A
91
Q

What is a circular array?

A

Technically, we don’t have circular memory

Use this algorithm to find the next index position

the algorithm provides circular indexing

92
Q

How can we implement a queue using a stack?

A

use two stacks

use stack 1 for enqueue method

use stack 2 for dequeue method (reverse)

93
Q

Q What is a popular queue interview question involving stacks?

A

Create a queue using stacks

94
Q

Q How do we implement enqueue ( ) and dequeue ( ) using circular array indexing?

A
95
Q

What is the implementation of the dequeue ( ) method using two stacks?

A
96
Q

How can we refactor our code?

A

Extract the method

97
Q

What are priority queues?

A

processed in the order of their importance

not the order in which they are added to the queue!

In Java, the smallest numbers come out first!

All numbers are sorted!

98
Q

What is an application of priorty queues?

A

OS system uses PriorityQueue to schedule tasks (highest priority task first)

99
Q

What is the algorithm for sorting items in a priority queue using an array?

A

Sorting algorithm

100
Q

How do we implement the enqueue() method in our priority queue using an array?

A

Sort based on values then insert at index

101
Q

How do we implement the dequeue ( ) method in a priority queue using an array?

A

updating the pointer position

value is still stored in the array

could copy over item

use a circular array

102
Q

What is an interview question?

A

removeFirst ( )

addLast ( )

103
Q

Q What’s an interview question?

A
104
Q

Q What is an interview question?

A
105
Q

What are hash tables?

A

Data structures

superfast lookup and many applications.

Come up in interviews often!

106
Q

HT What real-world problems can hash tables solve?

A

spell-checkers

dictionaries

compilers

code editors

Why?

Can lookup words amongst thousands super fast

Quickly lookup a word and translation

Lookup address of functions and variables

optimizing many algorithms​

Anywhere to lookup an item super fast!

107
Q

How do hash tables work?

A

Internally, uses an array to store values

Items stored as key-value pairs

Key is passed to hash function

The hash function gives the index of object in memory!

Give hash function the same input (key), it will give us the same output (value)!

Read / Write

108
Q

What are the hash table operations?

A

.put ( ) - maps specified key to the spefiied value in the hashtable

O(1) operation

.putIfAbsent ( ) - if specified key is not associated w/ a value, associates it with the given value, otherwise returns current value

O(1) operation

.contains ( ) - tests if some key maps into a specified value in the hashtable

O(1) operation

.containsKey ( ) - Tests if the specified object is a key in the hashtable

.get ( ) - returns value to which spefieid key is mapped

O(1) operation

.remove ( ) removes entry for the specified key only if it is currently mapped to a specified value

O(1) operation

Why?

The hash function tells us where a value is stored in memory

We don’t have to iterate over the entire array

109
Q

What are the names for hash maps in various programming languages?

A

Exactly the same things!

110
Q

How do we work with hash maps in Java?

A

Java map interface:

generic map interface declares all methods map data structures should provide

HashMap (80% of time used)

ConcurrentHashMap (multi-threaded applications)

111
Q

How do we refactor this if-statement into a ternary operator?

A
112
Q

Do hash maps allow null keys and null values?

A

Yes!

113
Q

HT How do we iterate over hash maps?

A
114
Q

What are the hash table operations in HashMap class?

A

.put ( ) pass key-value pair

.remove ( ) pass key, removes key-value pair

.get ( ) pass key, returns value

.containsKey ( ) pass value to hash function, returns boolean

.containsValue ( ) O(n) - iterate over all objects

.keySet ( ) returns list of keys

.entrySet ( ) returns list of key-value pairs

115
Q

How do we implement findFirstRepeatingChar ( ) in a hash map using a ternary operator?

A

Popular Interview Question:

Find first non-repeated character in a string

116
Q

What is a set?

A

A data structure using a hash function

but only storing keys.

117
Q

How can we use a set to remove duplicates in a list?

A
118
Q

Why are sets useful in solving a lot of problems?

A

Don’t allow duplicate keys

Ex.

remove duplicates

add each item to a set

unique list of items

119
Q

What are sets in Java?

A

Generic Interface

Implementing Class:

HashSet (​most often)

120
Q

What are the set operations?

A

.remove pass key, removes key

.removeAll removes all keys in set

.contains pass key, returns boolean

.clear

121
Q

How can we findFirstRepeatedChar ( ) using a set?

A

Popular set interview question!

O(1) operation!

122
Q

How does the hash function work?

A

It maps a number (key) to an index in the array

Hash function maps a key

to an index value in an array

we call this index..

hash value,

hash code,

digest or

just hash!

123
Q

HT How does the hash function work?

A

Gets a value and matches it to another value

Maps a key value to an index value

124
Q

Where are hash functions used?

A

In cryptography

125
Q

How do we map a key to an index in an array?

A

Using the modulus operator

hash % array.length = index

126
Q

How can a string-hash map to an array index?

A

Numeric representation of characters summed

total number (hash) % array.size = index in array

127
Q

What is special about the hashing function?

A

It’s Deterministic

every time we give it the same input (key)

it will return the same value (object)

Store and Retrieve

128
Q

What is a collision in a hash map?

A

It’s when the hash function generates the same hash (index location) to store two separate values!

129
Q

Why do collisions happen?

A

It is possible that two unique keys generate the same hash value.

This is called a collision.

130
Q

What is the first way to handle a collision?

A

Chaining

Wrap the values in a LinkedList node at each index in an array.

If there is a collision, store the value in the next node of the LinkedList.

131
Q

What is chaining in hash tables?

A

Each key-value pair is stored in the node of a LinkedList

If there is a collision, the second value is added to the next node in the LinkedList at that index.

132
Q

What are buckets or slots?

A

Each index in an array points to a LinkedList

133
Q

What is the second way to handle a collision?

A

Open addressing

Finding an open index to store the second value

Various algorithms for finding open indexes:

Linear Probing

Quadratic Probing

Double Hashing

134
Q

What is probing?

A

Array index not determined by the hash function.

open addressing algorithms:

linear probing - look in next index

quadratic probing - look in index squared

double hashing - two hash functions

135
Q

What are the equations linear, quadratic and double hashing probing algorithms?

A

Linear - i + 1

Quadratic - i * i

Double - i * secondHash function

136
Q

What is linear probing?

A

going to next index to store a collided value

If we cannot find a slot, the table is full, must resize array

Formula:

hash (key) + i % array.length

137
Q

What is a cluster?

A

Dense groups of filled indexes

Why?

Linear probing creates clusters by storing values in next open index

Result?

The next probe will take longer!

cluster will get bigger!

138
Q

What is quadratic probing?

A

Look for next open index at position index squared

Why?

Solves the clustering problem

But

can create an infinite loop!

Formula:

hash (key) +i^2 % array.length

139
Q

What is double hashing?

A

Find the next open index by

Multiplying i by a second hash function then apply modulus operator to find array index.

Formula:

index = [hashOne(key) + i * hashTwo (key)] % array.length

140
Q

How do we create a hash table from scratch?

A

Interview Question:

Create a hash table from scratch

use chaining (using LinkedLists)

Hint: create a class KeyValue with two fields (int, char)

141
Q

How do we implement hash ( ) method in our HashTable class?

A
142
Q

How do we implement the Entry class in our HashTable class?

A

create a private class inside Entry the HashTable class

143
Q

What is the final refactored implementation of the put method in our hash table?

A
144
Q

How can we refactor our put ( ) method in our HashTable class?

A
145
Q

How can we refactor the get ( ) method in our HashTable class?

A
146
Q

How can we refactor the remove ( ) method in our HashTable class?

A

Extract getBucket ( ) and getEntry ( ) helper methods

147
Q

HT How can we refactor this if-statement using the ternary operator?

A
148
Q

Why shouldn’t our getBucket ( ) method create a new bucket if no bucket is found?

A

Command-Query Separation:

Software design principle

Methods/functions should either be queries, return answer

OR

or be commands, change the state

149
Q

What is an interview question using Hash Tables?

A
150
Q

What is another interview question for Hash Tables?

A
151
Q

What is another interview question for Hash Tables?

A
152
Q

HT What is another interview question for Hash Tables?

A