Basic Knowledge Flashcards

Basic Programming questions that are asked (23 cards)

1
Q

How do you test for nulls in an array in a language of your choice?

A

To test for None values in a Python array:

```python
arr = [1, None, 3, None, 5]
has_none = any(x is None for x in arr)
print(has_none) # True
~~~

Summary: Use any(x is None for x in array) to check for None values in Python.

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

What is the space complexity for Quicksort?

A

Space Complexity of Quicksort:
- Best/Average Case: ( O(\log n) ) due to recursive stack usage.
- Worst Case: ( O(n) ) when the pivot selection is poor (e.g., sorted arrays without optimization).

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

What is a collision in hashing?

A

Collision in Hashing:
A collision occurs when two different inputs produce the same hash value, causing both to map to the same index in a hash table.

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

What is Unit Testing?

A

Unit Testing: Test individual functions or components.

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

What is integration testing?

A

Integration Testing: Test combined modules to ensure proper interaction.

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

What is system testing?

A

System Testing: Validate the complete system’s functionality.

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

What is acceptance testing?

A

Acceptance Testing: Ensure the code meets user requirements

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

Name all of the possibilities for Big O notation

A

“Calm Lions Need Lots of Nap Snacks”
C = Constant (O(1))
L = Logarithmic (O(log n))
N = Linear (O(n))
L = Linearithmic (O(n log n))
N = Quadratic (O(n²))
S = Super-exponential (O(2ⁿ))

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

Explain logarithmic time:
O(log n)

A

Halves the input with each step, which drastically reduces work.

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

Explain Linear Time:
O(n)

A

Time grows directly with the size of the input.

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

Explain Linearithmic Time:
O(nLogn)

A

Divides and conquers, like O(log n), but repeats the divide step for each input.

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

Explain Quadratic Time:
O(n²)

A

Time grows proportionally to the square of the input size (nested loops).

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

Explain Exponential Time:
O(2ⁿ)

A

Time doubles with each additional input.

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

What is a list

A

An ordered, mutable collection of items, supporting different data types and duplicates.

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

What is a Tuple

A

An ordered, immutable collection of items. Often used when data should not be changed.

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

What is a Set

A

An unordered collection of unique elements, useful for removing duplicates.

17
Q

What is a dictionary

A

An unordered collection of key-value pairs for fast lookups.

18
Q

What is an Array

A

Similar to lists but optimized for storing large amounts of numeric data with fixed type.

19
Q

What is a Stack?

A

A Last-In-First-Out (LIFO) data structure. You can implement stacks using lists or deque.

20
Q

What is a Queue?

A

A First-In-First-Out (FIFO) data structure. Use queue.Queue or deque for queue-based operations.

21
Q

What is a Heap?

A

A binary heap (priority queue) where the smallest element is always at the top.

22
Q

What is a Binary Tree?

A

A hierarchical data structure where nodes are connected by edges. The root node is the top, and each node has children.

23
Q

What is a Deque

A

A double-ended queue for adding/removing items efficiently from both ends.