Bird
0
0
DSA Cprogramming~5 mins

Array Insertion at Beginning in DSA C - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does 'Array Insertion at Beginning' mean?
It means adding a new element at the first position (index 0) of an array, shifting all other elements one position to the right.
Click to reveal answer
beginner
Why do we need to shift elements when inserting at the beginning of an array?
Because arrays have fixed positions, to insert at the start, all existing elements must move one step right to make space for the new element.
Click to reveal answer
intermediate
What is the time complexity of inserting an element at the beginning of an array?
The time complexity is O(n), where n is the number of elements, because all elements need to be shifted one position to the right.
Click to reveal answer
beginner
Show the steps to insert 5 at the beginning of array [10, 20, 30].
Step 1: Shift 30 to index 3<br>Step 2: Shift 20 to index 2<br>Step 3: Shift 10 to index 1<br>Step 4: Insert 5 at index 0<br>Result: [5, 10, 20, 30]
Click to reveal answer
intermediate
What happens if the array is full when inserting at the beginning?
If the array is full, you cannot insert a new element unless you increase the array size or remove an element first.
Click to reveal answer
What is the first step when inserting an element at the beginning of an array?
AShift all elements one position to the right
BInsert the element at the last position
CDelete the first element
DReplace the first element
What is the time complexity of inserting at the beginning of an array with n elements?
AO(n)
BO(log n)
CO(1)
DO(n^2)
If an array has elements [1, 2, 3] and we insert 0 at the beginning, what is the new array?
A[1, 2, 3, 0]
B[1, 0, 2, 3]
C[0, 1, 2, 3]
D[0, 1, 3, 2]
What must be true about the array size to insert a new element at the beginning?
AArray must be full
BArray must have space for one more element
CArray size does not matter
DArray must be empty
Which data structure allows easier insertion at the beginning than an array?
AHash Table
BStack
CQueue
DLinked List
Explain how to insert an element at the beginning of an array and why shifting elements is necessary.
Think about how arrays store elements in fixed positions.
You got /4 concepts.
    Describe what happens if you try to insert at the beginning of a full array and how to handle it.
    Consider array size and memory limits.
    You got /4 concepts.