Array
Array
1. Data Structures: These are ways to organize, store, and manage data
efficiently. Common data structures include arrays, linked lists, stacks,
queues, hash tables, trees, and graphs. Each type has specific use cases
and advantages in handling different kinds of data or operations.
Question 5: How would you find the smallest and largest element in an array?
Answer: To find the smallest and largest elements in an array, one common
approach is to iterate through the array and keep track of the smallest and
largest elements encountered so far.
Question 8: How would you reverse an array in-place in linear time and
constant space?
Answer: One approach is to use two pointers starting from the beginning and
end of the array and swap the elements until they meet in the middle.