int a[10]={23, 45, 10, 0, 98, 36, 2, 56, 34, 12}; for (int i=0; i<9 ; i++) for (int j=0; j<9; j++) if (alj] > alj+1]) swap(&a[j], &a[j+1]); end-if end-for end-for Convert the following code into descriptive code, and verify using White Box Testing. a = 2 b= 10 c = a * b for(i=a, i
Q: Let S be an unsorted array of n integers. Write an algorithm to find the pairs (x, y.) where x,, y;…
A: Algorithm: /* First sort the given array elements */ Read the unsorted array of n integers begin…
Q: Suppose the following array were passed in to a mergesort algorithm: 42 39 87 21| 56 93 43 35 Draw…
A: I have applied the merge sort algorithm in the array and I have show how our array will be…
Q: Overflows You have learned the concept of overflow (with say n! that overflows at 13! for integer)…
A: In fibonacci series next number is the sum of previous two numbers.
Q: I need these codes to be sorted in descending order instead of ascending order. Program #1 – Bubble…
A: Program 1: import java.util.*;import java.lang.*;import java.io.*; class BubbleSort{ void…
Q: ARRAY[] = [50, 11, 33, 21, 40, 50, 40, 40, 21] ARRAY[] = [11, 21, 33, 40, 50]
A: Given java ARRAY[] = [50, 11, 33, 21, 40, 50, 40, 40, 21] ARRAY[] = [11, 21, 33, 40, 50] ATTN…
Q: Consider an integer array a of length n with indexing starting at 0, where n is a positive integer.…
A: As per the company guidelines answer will be provided to the only one question. Please ask another…
Q: Suppose you have the following sorted list [3, 5, 6, 8, 11, 12, 14, 15, 17, 18] and are using the…
A: Given a sorted array : [3, 5, 6, 8, 11, 12, 14, 15, 17, 18] Size of array : 10 Subscript Range : 0-9…
Q: In Merge sort, what is the effect of dividing the array into three parts then merge them, instead of…
A: In Merge sort, what is the effect of dividing the array into three parts then merge them, instead of…
Q: convert this python code into java? Python code is as shown below: # recursive function def…
A: Given: convert this python code into java? Python code is as shown below: # recursive function def…
Q: Ridbit begins with an integer n. In one action, he can perform one of the accompanying tasks:…
A: Here have to determine about the Subtract or Divide programming problem statement.
Q: Suppose you are writing an algorithm to merge k sorted arrays of size n into a single sorted array…
A: Given: As per our policy, "Since you have asked multiple questions, we will solve the first question…
Q: a. System.out.println (x); for (int i -0; i < x.length - 1; i++) System.out.println (x); for (int i…
A: EXPLANATION: The index in the array starts from 0 and goes up to n-1 where n is the total number of…
Q: java Given Array : ARRAY[] = [11, 21, 33, 40, 50] Write a full and complete recursive…
A: Task :- Write a Java code to implement binary search. Java code :- import java.io.*; class Main…
Q: Let A[1...n,1...n] be a 2D array of positive integers with n rows and n columns. Let…
A: Answer :
Q: 2) We consider the following code: public void Sorting(Object[] data) { for (int i = 0; i i; -j) if…
A: Bubble sort is a simple sorting algorithm that can be used as a rearrangement of the set of elements…
Q: For a Given array of Size 100, do the following implementations - 1. Write a program to implement…
A: Following is the version of bubble soft this code, not iterate again if sorted elements in the…
Q: 6, 20, 24, 28, 32, 36, 40, 44, 48} and int B[4][3] = {5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35,…
A: We can have the general formula as, C[m][n]=A[m][n]+2*B[m][n] [from given int C[4][3] = A[4][3] +…
Q: IN JAVA Exploration: Test the sorting algorithms as follows. For input sizes n = 500, n = 1,000, n =…
A:
Q: Read in two integers n and m (n, m < 50). Read n integers in an array A. Read m integers in an array…
A: Intersection finds all the common elements in A and B array. Union finds all the elements of A and B…
Q: Q/ Write a java program to find the key = 15 by using binary search algorithm for Array…
A: code: //import the required packagesimport java.util.Scanner;//class definitionclass Main {…
Q: (1) A shifted sorted array can be defined as follows. Start with a sorted array for example…
A: A sorted array of distinct integers is shifted to the left by an unknown offset and don't have a…
Q: Use recursion [ a. Write a Java method to find the largest element in the array using recursion.…
A: Java Code for the given problem :- class Main { // method to find largest element recursively…
Q: (IN C++) Write a program to implement Quicksort. Also implement one of the slow sorts (Bubble,…
A: ANSWER:-
Q: Example input and output: Enter a value for n: 3 3, 10 , 5, 16 , 8, 4, 2, 1 Number of terms: 8…
A: #include <iostream>using namespace std;int sequence(int N){ int x,count = 1;…
Q: ÁLGORITHM WYSIWYG (a: sorted array of n integers) i:= 1 p:= 1 while (i < n) if (a[i+1] = di1-p]) p:=…
A: Python code :- for the above algorithm, the above statement is true, it gives the longest sequence…
Q: in java, Demonstrate how the following array is sorted using insertion sort. Show the array after…
A: Algorithm: Step-1: Start Step-2: Create an array 'ar' and store values [16,3,12,13,8,1,18,9].…
Q: A palindromic number is a number that is the same if read forwards or backwards: 12321 and 641146…
A: Important:- As per our guidelines, we are allowed to answer only the first three questions of…
Q: A run is a sequence of adjacent repeated values. Write a program that generates a sequence of 20…
A: These programs can be asked from control statements, array, string, oops etc. Java basic programs…
Q: See the pseudo-code of the Binary Search using recursion below. Fill in the XXXX and YYYY in the…
A: An array refers to a simple data storage structure that is capable of holding some given elements of…
Q: Arrays.sort() uses dual-pivot quicksort, an optimized version of quicksort, to sort an array of n…
A: When we use dual-pivot quicksort Arrays.sort() O(n^2) = worst case time complexity Timesort is…
Q: X173: array220 Given an array of int s, compute recursively if the array contains somewhere a value…
A: Here I have created a function named array220(). In this function, I have used conditional…
Q: Implement stack in array implementation using the following code : #include #include #include…
A: In the given program undo() and redo() are similar to pop() and push() operations on stack. The…
Q: 8. Find the complexity of the function used to find the kth smallest integer in an unordered array…
A: Given: Calculate the complexity of the function that finds the kth smallest integer in an unordered…
Q: Write a java program to test if the array S contains this value (15) by using Binary Search…
A: The binary search algorithm is one of among the other algorithms in the data structures and…
Q: Read in two integers n and m (n, m < 50). Read n integers in an array A. Read m integers in an array…
A: #include <stdio.h> int main(){ int a[50], b[50],m,n,i,j; int x,y,z; printf("Enter…
Q: IN JAVA Exploration: Test the sorting algorithms as follows. For input sizes n = 500, n = 1,000, n…
A: Solution :: Java code :: package com.example.sorting; import java.util.Random; public class…
Q: a) Consider a recursive function to return the Number of Binary Digits in the Binary Representation…
A: Since you are asking multiple questions, we are doing first question for you. a. Given algorithm…
Q: Implement MaxHeap sort algorithms on your computer. Run timings for each algorithm on arrays of size…
A: public class deletionHeap { static void heapify(int arr[], int n, int i) { int…
Q: Find f (1), f (2),f (3), and f (4) if f (n) is defined recursively by f (0) =1 and for n = 0, 1, 2,…
A: Here there are multiple questions given, so I have provided solutions of 1st 3 questions a,b, and c…
Q: in C Implement the QuickSort algorithm. - For n=3 the algorithm uses the rearrange function with…
A: Quick sort algorithm is a sorting algorithm which uses partition procedure to sort. It is best…
Q: Consider the following C++ code fragment for Selection Sort (the numbers on the left-hand are line…
A: Answer: We have discussed about selection sort in brief explanation
Q: Explain this c code in details. #include int main() { int max_weight_truck, n; scanf("%d",…
A: #include <stdio.h> int main() { int max_weight_truck, n; scanf("%d", &max_weight_truck);…
Q: Define the following variant of the Fibonacci sequence called Fib3 using recursion : ● fib3(0) = 0…
A: Below is the code in C++ as language is not mentioned and sample output:
Q: Write a java program to arrange elements in array X [1,99,70,75,100, -2, -4] in decreasing order…
A: Generally, programs are used to perform certain tasks according to the instructions given by the…
Q: (Python Code, polynomial interpolation)We implement a routine that evaluates a polynomial, given by…
A: Input to the Function : c: The vector for the coefficient of the polynomial x0: The data point…
Q: Java: Consider the following algorithm for searching in an unsorted array. If the size of the array…
A: This Algorithm is based on Merge sort. Pseudocode for Merge sort: We shall now see the pseudocodes…
Q: Implement the binary search function below that returns the index of the target value in an integer…
A: ALGORITHM:- 1. Initialize the array with the given values. 2. Take input for the target number to be…
Q: Consider the Insertion Sort Function below: public static void insertionSort(int array[]) { int n =…
A: In Insertion sort the array is virtually split into a sorted and an unsorted part. Values from the…
Q: Count consecutive summers def count_consecutive_summers(n): Like a majestic wild horse waiting for…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Step by step
Solved in 2 steps
- my code is getting errors and i cant figiure out why , can you check my code and help me fix the errors . written in c code. It needs to print out a maze and as you hit enter you go through the maze. #include <stdio.h>#include <stdlib.h> #define XSTART 2#define YSTART 0 #define DOWN 0#define RIGHT 1 #define UP 2#define LEFT 3 void mazeTraverse(char maze [12][12],int xCor,int yCor,int dir);int checkForEdge(int x , int y);int correctMoves (char maze[][12],int r , int c );void displayMaze (char maze [][12]); int main (void){ char maze [12] [12] ={{'#','#','#','#','#','#','#','#','#','#','#','#'}, {'#','.','.','.','#','.','.','.','.','.','.','#'}, {'.','.','#','.','#','.','#','#','#','#','.','#'}, {'#','#','#','.','#','.','.','.','.','#','.','#'}, {'#','.','.','.','.','#','#','#','.','#','.','.'}, {'#','#','#','#','.','#','.','#','.','#','.','#'}, {'#','.','.','#','.','#','.','#','.','#','.','#'}, {'#','#','.','#','.','#','.','#','.','#','.','#'},…In C, Assume that the int variables i and j have been declared, and that n has been declared and initialized.Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consisting of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be******You should not output any space characters.in c++ You are given an array A of non-negative integers of size m. Your task is to sort the array in increasing order and print out the original indices of the new sorted array. Example: A= {12, 2, 6, 10, 9, 24,23, 33} After sorting the new array becomes A= {2,6,9,10,12,23,24,33}. The required output should be sorted array and original indexes "1 2 4 3 0 6 7", index of 2 in original array was 1 , index for 6 was 2 and so on.
- Please help me to solve the error in the following java code. The question requirement is to merge k arrays into a single sorted array, the output should be: (Winnie, 0), (Eason Chan, 40), (Gloria Tang, 60), (Andy Lau, 60), (McDull, 60), (Denise Ho, 60), (Jennifer Chan, 70), (Joey Yung, 80), (Kay Tse, 90), (Mickey, 90), (Jacky Cheung, 95), (Teddy, 95), (Anita Mui, 100), (Peppa, 100) import java.util.*;import java.util.Arrays; public class StableMerger { static class Student { String name; double grade; public Student(String n, double g) { name = n; grade = g; } public String toString() { return "(" + name + ", " + grade + ")"; } } public static Student[] merge(Student[][] a) { //↓↓↓↓↓↓error code↓↓↓↓↓↓ PriorityQueue<Student> queue = new PriorityQueue<Student>(); int total=0; //add arrays to heap for (int i = 0; i < a.length; i++) {…iv) Write a JAVA program to merge two sorted arrays into a single sorted array. Take the sample arrays given below and print the result in the output. The time complexity of the program should be O(N+M) where N and M are the sizes of both the arrays. int []arr1 = {1, 6, 10, 14} int []arr2 = {2, 4, 5, 11, 16, 19} Print the merged array in the output.I need to complete this table, JAVA. Assuming an unsorted Map starting with no contents, describe the return values and contents of the map (initial values on the left) after the operation, when done in order. Also Assume entries are in (key,value) format. The first three function calls are completed. FUNCTION CONTENTS RETURN VALUE isEmpty() {} true put(5,X) {(5,X)} null put(7,F) {(5,X),(7,F) null put(2,C) put(8,D) put(2,E) get(7) put(7,Y) get(4) put(4,X) get(4) size() remove(5) isEmpty() size()
- Im facing problem with this code. #include<stdio.h> #include<math.h> void putnqueen(int); int okqueen(int, int); int setqueen(int); void queen(); char p[10][10]; int n; int main() { int a, b; clrscr(); printf(" Enter the no. of queens : "); scanf("%d", &n); for (a = 0; a < n; ++a) for (b = 0; b < n; ++b) p[a][b] = '.'; putnqueen(0); getch(); return (0); } void putnqueen(int x) { int a; if (x < n) { for (a = 0; a < n; ++a) { if (okqueen(x, a)) { p[x][a] = 'Q'; putnqueen(x + 1); p[x][a] = '.'; } } } else { printf("\n The solution is "); queen();…Q#2 Write a recursive function zeroCount ( int a[ ], int s, int e) that receives an array of integers a [], a start index s, and an end index e. The function should return the number of zeros in that array between s and e. int zeroCount ( int a[ ], int s, int e); Trace your function given the following array and function call. Draw your steps. int a[ ] = {1, 0, 0, 5}; int zeros = zeroCount(a, 0, 3); language c++Answer in java code a) Given this: int [][] tda = new int [12][25];Write a loop to print the fourth row of this two-dimensional array tda {assume the array is filled with data..}b) Write Java code (only the loop) to find the maximum value in the array Ab of type integer (use enhancedfor-loop): c) Write the output of this code:int [][] tda = {{5,99,88,2},{22,76,12,87,77,66},{34,88,13,4},{9,76,77,11}};tda[1][4] = -22;for(int q=0; q<tda[3].length; q++) System.out.print(tda[2][q] + " ");
- PYTHON CODE: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation skills.Today, Hikaru took a big chessboard with N rows (numbered 1 through N) and N columns (numbered 1 through N). Let's denote the square in row r and column c of the chessboard by (r,c). Hikaru wants to place some rooks on the chessboard in such a way that the following conditions are satisfied:• Each square of the board contains at most one rook.• There are no four rooks forming a rectangle. Formally, there should not be any four valid integers r1, c1, r2, c2 (≠r2,c1≠c2) such that there are rooks on squares (r1,c1), (r1,c2 (r2,c1)and (r2,c2).• The number of rooks is at least 8N.Help Hikaru find a possible distribution of rooks. If there are multiple solutions, you may find any one. It is guaranteed that under the given constraints, a solution always exists.InputThe first line of the input contains a single integer T denoting the number of test cases. The first and only line of each test…Java Programming- Need the code- Suppose we have a string holding the text of an entire book. If we want to analyze segments of the text, it is inefficient to make substrings. Instead, we should just store a reference to the original text and the starting and ending positions. Design a class Segment that does this, and have it implement the CharSequence interface of the standard library. Write a test program in which you demonstrate that you can pass your Segment objects to methods that accept CharSequence instances, such as String.join and PrintStream.append.. What will be the output of the following code, consider the memory address of variable x is 0x0044c and pointer variable ptr is 0x0066f, and consider int data type take 2 byte in the memory void main() { int x[5] = { 1,2,3,4,5 }; int *ptr = x; ptr = ptr + 1; cout << ptr << endl; cout << *ptr << endl; cout << &ptr << endl; cout << &x[0] << endl; cout << *x << endl; x += 2; cout << x << endl; }