R programming: provide code and explanation
b.
If we try to insert NULL value to the 4th position in the vector, we get an error.
> a<-1:10
> a[4] <- NULL
Error in a[4] <- NULL : replacement has length zero
NULL is a zero length special object in R. We cannot assign this object to a specific element of a vector object in R. You may however assign it to the vector object itself.
16.
<- operator is used to assign variable in the same environment
<<- operator is used to assign variable in the global environment
For e.g.
Using the global environment assignment operator
> x <<- 10
Below is a function which assigns value to x in its local environment using <- operator
> test <- function(y) {x<- y
+ print(x)}
> test(2)
[1] 2
Now if we print x, the value from the global environment would be printed.
> print(x)
[1] 10
15. Yes we can have a data frame with 0 rows and 0 columns.
> df <-data.frame()
> df
data frame with 0 columns and 0 rows
R programming: provide code and explanation b. -Here's an integer vector . what happens if you...
Let V, W, and U be three finite dimensional vector spaces over R and T:V + Wand S : W → U be two linear transformations. Show that null(SoT) < null(T) + null(S)
C++ READ CODE: 8. Below is a code fragment; assume x is an integer with the value 40 at the start of the code fragment. Execute each code fragment and show the output below that code fragment. if (x 25) if (x 0) x=x*2; x=x+1; else ( x1i cout < xi
3. What does this code do? Write an explanation in English python n=1 while (n <1000): print(n) n-n
(2) Velocity Vectors Consider the curve given by the position vector: r(t) =< 3cos(t), 5sin(t), 4cos(t) > (2a) Find the velocity vector for this trajectory. (2b) Find the speed for a particle moving along this trajectory. (20) At what point (a,b,c) does the position vector pass through the xy-plane?
What is the output of the following code: int numbers [] {99,87,66,55,101}; cout << numbers[i] « " ";
What is the time and space complexity of this code with explanation? public static int getv(int num, List<Integer> rating, int target) { int count 0; HashMap<Integer, Integer> map = new HashMap<>(); for(int i = 0; i < num; i++){ if(!map.containsKey(rating.get(i))){ map.put(rating.-get(i), 0); } map.put(rating.get(i), map.get(rating.get(i))+1); } for(int i = 0; i < num; i++){ if(map.get(target -rating.get(i)) != null){ count += map.get(target-rating.get(i)); } if(target-rating.get(i) == rating.get(i)){ count--; } return count/2; }
What will be printed for the code below: age = 15 if (age < 13) { print ("child") } else if (age >= 13 & age <=19) { print ("teenager") } else { print ("adult") } What will be the output of the code below: for(i in 1:100) { if(i <= 20){ print (i) }
Question 25 What is output when the following code is executed? 65 score = group if score <= 60: group group + 'A' if score <= 70: group group + 'B' if score <= 80: group group + 'C' else: group group + 'D' print(group) BC AB с D
Consider the following method. public static ArrayList<Integer mystery(int n) ArrayList<Integer seg - new ArrayList<IntegerO; for (int k = n; k > 0; k--) seq.add(new Integer(k+3)); return seq What is the final output of the following Java statement? System.out.println(mystery(3)); a. [1,2,4,5) b. [2,3,4,5) c. [6,5,4,3] d. [7, 7, 8, 8] e. [7,8,9, 8) O Consider the following method: public static int mystery(int[] arr, int k) ifk-0) return 0; }else{ return arr[k - 1] + mystery(arr, k-1):) The code segment below is...
Consider the following Java method: public static ArrayList<Integer nums ArrayList<Integer values new ArrayList<Integer0; for(int i=10; i<30; i-i+3) if(i%) values.add(i); return values: What is returned after the method call nums()? a. [12] b. [13] c. [14] d. [15] e. [16] O Which of the following represents the final output of the code segment below? int k: int[]A; A new int[3]: fork-0; k<A.length;k++) A[k]-A.length-k; forſk-0; k<A.length-1; k++) A[k+1]-A[k) for(int i-0;i<A.length;i++) System.out.print(A[i]+" "); a. 222 O b. 333 c. 444 d. 555 O...