Applied CS, Questions with accurate answers, VERIFIED.
Applied CS, Questions with accurate answers, VERIFIED. create an array of size x comprised of elements of type y let array = Array(x).fill(y) y could be an array itself, which would yield a multidimensional array. Changing y changes the composed array AND all of its copies, which is often not desired. saying parentArray[0][0] = x is like saying originalArray[0] = x therefore, all of the members in the parent Array change because it's merely a reference and not a copy how do we build an array with the .Array().fill() methods so that we can change the resulting array without changing all the top-level components for (i=0; i5; i++) { const arr = Array(10).fill(0) parentA(arr) } this way, each time you are creating a new subarray, and changing the first one won't alter the remaining because they're not references to the same array but rather separate copies produced via iteration determine if a string is a palindrome create a reverse string by iterating over the string from the back to the front and concatenating to the reverse_string compare the reverse string to the input string accessing array matrices easily declare a row variable and a column variable then if you're trying to access the number visually above a given array element, just subtract 1 from the row variable given row and column numbers, create an array with 0
Written for
- Institution
- Applied CS
- Course
- Applied CS
Document information
- Uploaded on
- December 21, 2023
- Number of pages
- 39
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
applied cs questions with accurate answers veri