Software Engineer Intern Flashcards

1
Q

Q: What is an array?

A

A: An array is a collection of elements stored at contiguous memory locations, identified by an index or key.

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

What is the time complexity for accessing an element in an array?

A

O(1) - constant time, because arrays provide direct access via index.

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

What is the time complexity for inserting/deleting an element at the end of an array?

A

O(1) - constant time, if there’s space available.

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

What is the time complexity for inserting/deleting an element at an arbitrary position in an array?

A

O(n) - linear time, because elements may need to be shifted.

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

Q: What is a dynamic array?

A

A dynamic array automatically resizes itself when it reaches capacity, allowing for flexible sizing.

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

What is the time complexity for resizing a dynamic array?

A

A: O(n) - linear time, because all elements need to be copied to the new array.

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

What is a multi-dimensional array?

A

An array where each element can be accessed using multiple indices (e.g., matrix with rows and columns).

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

What is a linked list?

A

A linked list is a linear data structure where elements are stored in nodes, and each node points to the next node in the sequence.

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

What are the main components of a linked list node?

A

A: A data element and a reference (pointer) to the next node.

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

Q: What is a doubly linked list?

A

A: A linked list where each node has pointers to both the next and previous nodes.

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

Q: What is a singly linked list?

A

A: A linked list where each node points only to the next node in the sequence.

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

Q: What is a circular linked list?

A

A: A linked list where the last node points back to the first node, forming a circle.

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

Q: What is the time complexity for accessing an element in a linked list?

A

A: O(n) - linear time, because you need to traverse from the head.

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

Q: What is the time complexity for insertion/deletion at the beginning of a linked list?

A

A: O(1) - constant time, if you have a reference to the head.

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

Q: What is the time complexity for insertion/deletion at the end of a linked list?

A

A: O(n) for singly linked list (need to traverse), O(1) for doubly linked list if you have a tail reference.

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

Q: What are the advantages of linked lists over arrays?

A

A: Dynamic size, efficient insertions/deletions, no need for contiguous memory.

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

Q: What are the disadvantages of linked lists compared to arrays?

A

A: Higher memory usage (due to pointers), sequential access only (no random access), poor cache locality.

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

Q: What is a stack data structure?

A

A: A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. Elements can only be inserted or removed from one end, called the “top” of the stack.

19
Q

Q: What are the two primary operations of a stack?

A

A: The two primary operations are:

Push: adds an element to the top of the stack
Pop: removes the element from the top of the stack

20
Q

Q: What is the time complexity of push and pop operations in a stack?

A

A: Both push and pop operations have O(1) time complexity (constant time).

21
Q

Q: What happens when you try to pop from an empty stack?

A

A: This results in a stack underflow error/exception.

22
Q

Q: What’s the difference between peek and pop in a stack?

A

A: Peek returns the top element without removing it, while pop returns AND removes the top element.

23
Q

Q: Name real-world examples of a stack.

A

A: A stack of plates, browser history (back button), function call stack in programming, undo functionality in text editors.

24
Q

Q: What is a queue data structure?

A

A: A queue is a linear data structure that follows the First In, First Out (FIFO) principle. Elements are added at one end (rear) and removed from the other end (front).

25
Q

Q: What are the two primary operations of a queue?

A

A: The two primary operations are:

Enqueue: adds an element to the rear of the queue
Dequeue: removes the element from the front of the queue

26
Q

Q: What is the time complexity of enqueue and dequeue operations in a queue?

A

A: Both enqueue and dequeue operations have O(1) time complexity (constant time) when implemented optimally.

27
Q

Q: What is a circular queue?

A

A: A circular queue is an improvement over the standard queue where the last position is connected to the first position to form a circle, preventing wasted space when elements are dequeued.

28
Q

Q: What is a priority queue?

A

A: A priority queue is a special type of queue where elements have associated priorities, and elements with higher priority are served before elements with lower priority.

29
Q

Q: What is a deque (double-ended queue)?

A

A: A deque is a queue that allows insertion and deletion at both ends (front and rear).

30
Q

Q: What data structure is typically used to implement a priority queue efficiently?

A

: A heap data structure (typically a binary heap) is used for efficient priority queue implementation.

31
Q

Q: What is a hash table?

A

A: A hash table is a data structure that implements an associative array abstract data type, a structure that can map keys to values using a hash function.

32
Q

Q: What is a hash function?

A

A: A hash function is a function that converts input data of arbitrary size to a fixed-size value, used to compute an index into an array for storing the data

33
Q

Q: What is a collision in hash tables?

A

A: A collision occurs when two different keys produce the same hash value (index).

34
Q

Q: What are common collision resolution techniques?

A

A: Common techniques include:

Chaining (using linked lists at each index)
Open addressing (linear probing, quadratic probing, double hashing)
Robin Hood hashing
Cuckoo hashing

35
Q

Q: What is a tree data structure?

A

A: A tree is a hierarchical, non-linear data structure consisting of nodes connected by edges, with one node designated as the root.

36
Q

Q: What is a binary tree?

A

A: A binary tree is a tree where each node has at most two children, referred to as the left child and the right child.

37
Q

Q: What is tree traversal?

A

A: Tree traversal is the process of visiting each node in a tree data structure exactly once.

38
Q

Q: What is a heap?

A

A heap is sort of a warehouse, where data is stored, and is not in any particular order.

39
Q

Q: What is the heap property for a min-heap?

A

A: In a min-heap, for every node i, the value of i is less than or equal to the values of its children.

40
Q

Q: What is the difference between time complexity and space complexity?

A

A: Time complexity measures the amount of time an algorithm takes to run as a function of input size, while space complexity measures the amount of memory it uses.

41
Q

Q: What is Big O notation?

A

Big O notation is a way to describe time complexity (how fast an algorithm runs) and space complexity (how much memory it uses).

42
Q

Q: What is Breadth-First Search (BFS)?

A

A: BFS is a graph traversal algorithm that explores all neighbors at the present depth before moving to nodes at the next depth level.