Easy

Program to print all the elements of an array

Explaination

We will use a for loop to print all the elements.

  • Initialize a counter and traverse through the array
  • At each iteration, print the element at counter position

 

Java Code:

int[] elements = {2,5,3,8,5,1};
for(int i = 0; i < elements.length(); i++){
    System.out.print(elements[i] + " ");
}

 

### Complexity Analysis * **Time Complexity**: O(N) where N is total elements. * **Space Complexity**: O(1).



Thanks for feedback.



Read More....
Convert a sorted array into a binary search tree - recursive approach
Check if an array is a min heap
Minimum number of merge operation to make an array palindrom
Find the duplicate value in an array
Find the minimum element in a sorted and rotated array
Find the missing and repeated element in the given array