0% found this document useful (0 votes)
3 views1 page

Array Questions

The document contains practice questions related to array data structures. It includes a question on sorting an array of 0s, 1s, and 2s, and another on inserting an element at a specified position in an array. Each question is accompanied by input and output examples for clarity.

Uploaded by

sranucosta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Array Questions

The document contains practice questions related to array data structures. It includes a question on sorting an array of 0s, 1s, and 2s, and another on inserting an element at a specified position in an array. Each question is accompanied by input and output examples for clarity.

Uploaded by

sranucosta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Array Data Structure – Practice Questions

Question 1:
Write a program to sort an array consisting only of 0s, 1s, and 2s.
Input: An array of size N containing only 0, 1, and 2.
Output: The sorted array.
Example:
Input: [0, 2, 1, 2, 0]
Output: [0, 0, 1, 2, 2]

Question 2:
Write a program to insert an element into an array at a given position.
Input: An array, the element to be inserted, and the position.
Output: Array after inserting the element.
Example:
Array: [10, 20, 30, 40]
Element: 25, Position: 3
Output: [10, 20, 25, 30, 40]

You might also like