{"id":"8b636e36-32d4-4f5c-823f-fc0d967b0942","name":"Display Array","description":"1. You are given a number n, representing the size of array a.\r\n2. You are given n numbers, representing elements of array a.\r\n3. You are required to print the elements of array from beginning to end each in a separate line.\r\n4. For the above purpose complete the body of displayArr function. Don't change the signature.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A number n\r\nn1\r\nn2\r\n.. n number of elements","outputFormat":"n1\r\nn2\r\n.. n elements","constraints":"1 &lt;= n &lt;= 30\r\n0 &lt;= n1, n2, .. n elements &lt;= 10","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid display(int arr[], int idx, int n){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int n;\r\n cin >> n;\r\n int arr[n];\r\n for (int i = 0; i < n; i++)\r\n cin >> arr[i];\r\n display(arr, 0, n);\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n public static void displayArr(int[] arr, int idx){\r\n \r\n }\r\n\r\n}"},"python":{"code":"def display(arr,idx,n):\n # Write your code here\n\n\n\ndef main():\n \n # Write your code here\n\nmain()"}},"points":10,"difficulty":"easy","sampleInput":"5\r\n3\r\n1\r\n0\r\n7\r\n5","sampleOutput":"3\r\n1\r\n0\r\n7\r\n5","questionVideo":"https://www.youtube.com/embed/MOFUK3PyOPw","hints":[],"associated":[{"id":"472fd30a-f563-44c0-92fc-1423e7e1fe39","name":"(Display array in reverse) What should be the base condition of recursive function?","slug":"display-array-in-reverse-what-should-be-the-base-condition-of-recursive-function","type":4},{"id":"9337ad19-e847-4a77-8dca-03beac78999a","name":"(Display in Array) Which of these best describes an array?","slug":"display-in-array-which-of-these-best-describes-an-array","type":4},{"id":"a4dc9d21-e720-4de3-a7ab-2e9c4bb9b427","name":"(Display in Array) What is time complexity of this question?","slug":"display-in-array-what-is-time-complexity-of-this-question","type":4},{"id":"ec863fe7-c5b6-4321-bb34-197614c26194","name":"(Display array in reverse) What will be the faith in the recursive call?","slug":"display-array-in-reverse-what-will-be-the-faith-in-the-recursive-call","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"495df0de-95fc-4819-b863-df80996fb157","name":"Display Array","slug":"display-array","type":1}],"next":{"id":"8b0857ed-4ab5-4790-aabb-3554c404b155","name":"Display Array","type":3,"slug":"display-array"},"prev":{"id":"57655973-da51-40b6-a449-a97a98b974b9","name":"Tower of Hanoi","type":3,"slug":"tower-of-hanoi"}}}

Display Array

1. You are given a number n, representing the size of array a. 2. You are given n numbers, representing elements of array a. 3. You are required to print the elements of array from beginning to end each in a separate line. 4. For the above purpose complete the body of displayArr function. Don't change the signature. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

{"id":"8b636e36-32d4-4f5c-823f-fc0d967b0942","name":"Display Array","description":"1. You are given a number n, representing the size of array a.\r\n2. You are given n numbers, representing elements of array a.\r\n3. You are required to print the elements of array from beginning to end each in a separate line.\r\n4. For the above purpose complete the body of displayArr function. Don't change the signature.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A number n\r\nn1\r\nn2\r\n.. n number of elements","outputFormat":"n1\r\nn2\r\n.. n elements","constraints":"1 &lt;= n &lt;= 30\r\n0 &lt;= n1, n2, .. n elements &lt;= 10","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid display(int arr[], int idx, int n){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int n;\r\n cin >> n;\r\n int arr[n];\r\n for (int i = 0; i < n; i++)\r\n cin >> arr[i];\r\n display(arr, 0, n);\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n public static void displayArr(int[] arr, int idx){\r\n \r\n }\r\n\r\n}"},"python":{"code":"def display(arr,idx,n):\n # Write your code here\n\n\n\ndef main():\n \n # Write your code here\n\nmain()"}},"points":10,"difficulty":"easy","sampleInput":"5\r\n3\r\n1\r\n0\r\n7\r\n5","sampleOutput":"3\r\n1\r\n0\r\n7\r\n5","questionVideo":"https://www.youtube.com/embed/MOFUK3PyOPw","hints":[],"associated":[{"id":"472fd30a-f563-44c0-92fc-1423e7e1fe39","name":"(Display array in reverse) What should be the base condition of recursive function?","slug":"display-array-in-reverse-what-should-be-the-base-condition-of-recursive-function","type":4},{"id":"9337ad19-e847-4a77-8dca-03beac78999a","name":"(Display in Array) Which of these best describes an array?","slug":"display-in-array-which-of-these-best-describes-an-array","type":4},{"id":"a4dc9d21-e720-4de3-a7ab-2e9c4bb9b427","name":"(Display in Array) What is time complexity of this question?","slug":"display-in-array-what-is-time-complexity-of-this-question","type":4},{"id":"ec863fe7-c5b6-4321-bb34-197614c26194","name":"(Display array in reverse) What will be the faith in the recursive call?","slug":"display-array-in-reverse-what-will-be-the-faith-in-the-recursive-call","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"495df0de-95fc-4819-b863-df80996fb157","name":"Display Array","slug":"display-array","type":1}],"next":{"id":"8b0857ed-4ab5-4790-aabb-3554c404b155","name":"Display Array","type":3,"slug":"display-array"},"prev":{"id":"57655973-da51-40b6-a449-a97a98b974b9","name":"Tower of Hanoi","type":3,"slug":"tower-of-hanoi"}}}
plane

Editor


Loading...

Display Array

easy

1. You are given a number n, representing the size of array a. 2. You are given n numbers, representing elements of array a. 3. You are required to print the elements of array from beginning to end each in a separate line. 4. For the above purpose complete the body of displayArr function. Don't change the signature. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

Constraints

1 <= n <= 30 0 <= n1, n2, .. n elements <= 10

Format

Input

A number n n1 n2 .. n number of elements

Output

n1 n2 .. n elements

Example

Sample Input

5 3 1 0 7 5

Sample Output

3 1 0 7 5

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode