Write Scheme functions to do the following. You are only allowed to use the functions introduced in our lecture notes and the helper functions written by yourself. (a) Return all rotations of a given list. For example, (rotate ’(a b c d e)) should return ((a b c d e) (b c d e a) (c d e a b) (d e a b c) (e a b c d)) (in some order). (b) Return a list containing all elements of a given list that satisfy a given predicate. For example, (filter (lambda (x) (< x 5)) ’(3 9 5 8 2 4 7)) should return (3 2 4).

Answers

Answer 1

Answer:

Check the explanation

Explanation:

solution a:

def Rotate(string) :

n = len(string)

temp = string + string

for i in range(n) :

for j in range(n) :

print(temp[i + j], end = "")

print()

string = ("abcde")

Rotate(string)

solution b:

nums = [3,9,5,8,2,4,7]

res = list(filter(lambda n : n < 5, nums))

print(res)


Related Questions

Trace the complete execution of the MergeSort algorithm when called on the array of integers, numbers, below. Show the resulting sub-arrays formed after each call to merge by enclosing them in { }. For example, if you originally had an array of 5 elements, a = {5,2,8,3,7}, the first call to merge would result with: {2, 5} 8, 3, 7 ← Note after the first call to merge, two arrays of size 1 have been merged into the sorted subarray {2,5} and the values 2 and 5 are sorted in array a You are to do this trace for the array, numbers, below. Be sure to show the resulting sub-arrays after each call to MergeSort. int[] numbers = {23, 14, 3, 56, 17, 8, 42, 18, 5};

Answers

Answer:

public class Main {

public static void merge(int[] arr, int l, int m, int r) {

int n1 = m - l + 1;

int n2 = r - m;

int[] L = new int[n1];

int[] R = new int[n2];

for (int i = 0; i < n1; ++i)

L[i] = arr[l + i];

for (int j = 0; j < n2; ++j)

R[j] = arr[m + 1 + j];

int i = 0, j = 0;

int k = l;

while (i < n1 && j < n2) {

if (L[i] <= R[j]) {

arr[k] = L[i];

i++;

} else {

arr[k] = R[j];

j++;

}

k++;

}

while (i < n1) {

arr[k] = L[i];

i++;

k++;

}

while (j < n2) {

arr[k] = R[j];

j++;

k++;

}

printArray(arr, l, r);

}

public static void sort(int[] arr, int l, int r) {

if (l < r) {

int m = (l + r) / 2;

sort(arr, l, m);

sort(arr, m + 1, r);

merge(arr, l, m, r);

}

}

static void printArray(int[] arr, int l, int r) {

System.out.print("{");

for (int i = l; i <= r; ++i)

System.out.print(arr[i] + " ");

System.out.println("}");

}

public static void main(String[] args) {

int[] arr = {23, 14, 3, 56, 17, 8, 42, 18, 5};

sort(arr, 0, arr.length - 1);

}

}

Explanation:

See answer

Double any element's value that is less than minValue. Ex: If minValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4, 12, 18, 20}.
import java.util.Scanner;
public class StudentScores {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_Points = 4;
int[] dataPoints = new int[NUM_POINTS];
int minValue;
int i;
minValue = scnr.nextInt();
for (i = 0; i < dataPoints.length; ++i) {
dataPoints[i] = scnr.nextInt();
}
/* Your solution goes here */
for (i = 0; i < dataPoints.length; ++i) {
System.out.print(dataPoints[i] + " ");
}
System.out.println();
}
}

Answers

Answer:

Following are the code to this question:

for(i=0;i<dataPoints.length;++i) //define loop to count array element  

{

if(dataPoints[i]<minValue) // define condition that checks array element is less then minValue

{

dataPoints[i] = dataPoints[i]*2; //double the value

}

}

Explanation:

Description of the code as follows:

In the given code, a for loop is declared, that uses a variable "i", which counts all array element, that is input by the user. Inside the loop and if block statement is used, that check array element value is less then "minValue", if this condition is true.  So, inside the loop, we multiply the value by 2.

Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bits memory address references given as word addresses. 0x03, 0xb4, 0x2b, 0x02, 0xbf, 0x58, 0xbe, 0x0e, 0xb5, 0x2c, 0xba, 0xfd For each of these references identify the binary word address, the tag, and the index given a direct mapped cache with 16 one-word blocks. Also list whether each reference is a hit or a miss, assuming the cache is initially empty.

Answers

Answer:

See explaination

Explanation:

please kindly see attachment for the step by step solution of the given problem.

Other Questions
Which of the following BEST describes the main difference between scarcity and a shortage? 20 POINTS!! FASTEST ANSWER GET BRAINLY!!!A.While a shortage is a temporary market condition, scarcity is an ongoing condition in the world.B.While scarcity is a temporary market condition, a shortage is an ongoing condition in the world.C.Scarcity is found throughout the world, but shortages only occur in wealthy countries.D.Shortages occur everywhere, but scarcity happens only in countries with very high poverty levels. HELP PLEASE write down a formula for the nth term of these patterns. The first term is n = 1.14 ,23 ,32 ,41, 50 = nth term = ?????????-4, -11, -18, -25, -32 = nth term = ??????????? 5 x 10 to the 6th power is how many times larger than 5 x 10 to the 4th power. PLEASE RESPOND FAST PLEASE HELP!! DUE!!!!Write the slope-intercept form of an equation for the line that passes through the given point and is parallel to the graph of the given equation. (5, 6) and 12x+9y=3 Free trade agreements have failed in opening up markets to US exports. True or False? Why had African Americans lost many of the rights gained during Reconstruction by the late 1800s?A) because of the growing power of ConservativesB) because of northern efforts to maintain controlC) because of intervention by the federal governmentD) because of the rise of white southern Republicans *WILL MARK BRAINLIEST IF ANSWERED IN LESS THAN 10 MIN* Oxygen released during photosynthesis comes fromA. ATPB.H2OC.CO2D.C6H12O6 Find the mean, median, and mode(s) of the data. Choose the measure that best represents the data. Explain your reasoning. Find the mean, median, and mode(s) of the data with and without the outlier. Which measure did the outlier affect the most? 8, 10, 10, 11, 16, 17, 19, 21, 41 can someone tell me the answer for both of these pleaseeee i need it asap!!! i will give brainlist!! please help me simplify 4^8/4^5 Four students were asked to label angles in pairs of triangles. Their drawings are shown below. Tatyanna Triangle A B C. Angle B is 54.3 degrees and angle C is 61.2 degrees. Triangle X Y Z. Angle Z is 64.5 degrees and angle Y is 54.3 degrees.[Not drawn to scale] Simon Triangle A B C. Angle A is 63.2 degrees and angle B is 58.4 degrees. Triangle X Y Z. Angle Z is 63.2 degrees and angle Y is 58.4 degrees.[Not drawn to scale] Anders Triangle A B C. Angle A is 59.8 degrees and angle B is 60.6 degrees. Triangle X Y Z. Angle X is 59.8 degrees and angle Z is 60.6 degrees.[Not drawn to scale] Kai Triangle A B C. Angle B is 60.9 degrees and angle C is 57.7 degrees. Triangle X Y Z. Angle X is 61.4 degrees and angle Z is 57.7 degrees. [Not drawn to scale] Which student labeled the triangles such that Triangle A B C is similar to X Y Z? Tatyanna Simon Anders Kai Identify the slope and yintercept of the function y= -2x+ 3. PLEASE HELP ASAP!!!!!!!!Write the first five terms of the sequence defined by the function below. 3. Which of the following are NOT types of microorganisms?a. Prionsb. Virusesc. Bacteriad. Earthworms Ill help you if you help me Find the volume of the cone. Either enter an exact answer in terms of \pipi or use 3.143.143, point, 14 for \pipi and round your final answer to the nearest hundredth. How has ancient Rome influenced the modern world? ANCIENT ROME!! sailors in navy may spend time in submarines Which of the following are in the correct order from least to greatest?2 pi, StartFraction 7 pi Over 6 EndFraction, 80, StartFraction pi Over 4 EndFraction, 3838, 80, StartFracton pi over 4 EndFraction, StartFraction 7 pi Over 6 EndFraction, 2 pi 38, StartFraction pi Over 4 EndFraction, 80, StartFraction 7 pi Over 6 EndFraction, 2 pi 2 pi, 38, 80, StartFraction pi Over 4 EndFraction, StartFraction 7 pi Over 6 EndFraction Please help ASAP! Will give BRAINLIEST! Please read the question THEN answer correctly! No guessing.