Recall & Review
beginner Click to reveal answer
What does 'Array Insertion at End' mean?
It means adding a new element to the last position of an array, increasing its size by one.
beginner Click to reveal answer
In Go, what happens if you try to insert an element at the end of a fixed-size array?
You cannot add elements beyond the fixed size. You must use a slice to insert at the end dynamically.
beginner Click to reveal answer
How do slices help with insertion at the end in Go?
Slices are dynamic and can grow. You can use the built-in append() function to add elements at the end easily.
intermediate Click to reveal answer
What is the time complexity of inserting an element at the end of a slice in Go?
Usually O(1) amortized, because append adds at the end. Sometimes it can be O(n) if the slice needs to grow its capacity.
beginner Click to reveal answer
Show a simple Go code snippet to insert an element at the end of a slice.
numbers := []int{1, 2, 3}
numbers = append(numbers, 4)
// Now numbers is [1, 2, 3, 4]
Which Go data structure allows easy insertion at the end?
✗ Incorrect
Slices are dynamic and support append to add elements at the end.
What function is used to insert an element at the end of a slice in Go?
✗ Incorrect
The built-in append() function adds elements at the end of a slice.
What happens if a slice's capacity is full when you append a new element?
✗ Incorrect
Go automatically grows the slice capacity when needed during append.
Can you insert an element at the end of a fixed-size array in Go?
✗ Incorrect
Arrays have fixed size and cannot grow, so insertion at the end is not possible.
What is the time complexity of appending an element to a slice when capacity is sufficient?
✗ Incorrect
Appending is O(1) when capacity is enough, as it just adds the element at the end.
Explain how to insert an element at the end of an array or slice in Go.
Think about fixed size vs dynamic size and the append function.
You got /3 concepts.
Describe what happens internally when you append an element to a slice that has no extra capacity.
Consider how Go manages slice growth behind the scenes.
You got /4 concepts.
