
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
thumb_up100%
![A vector is given by x=[ 9 -1.5 13.4 13.3 -2.1 4.6 1.1 5 -6.1 10 0.2]. Using conditional statements and loops, write a
program that rearranges the elements of x in order from the highest numeric value to the lowest numeric value. Do not
use Matlab's built-in sort function. For extra credit, make an input command for vector x that accepts input from the
user for a vector x to sort!
MATLAB
ONLY
or making vector x
or correct outer loop of sort
ror correct inner loop of sort](https://content.bartleby.com/qna-images/question/eb75a221-1cc6-4439-8f26-788078286c3b/9517b167-45bd-4121-bae7-74fb763f50be/nfdq45ch_thumbnail.jpeg)
Transcribed Image Text:A vector is given by x=[ 9 -1.5 13.4 13.3 -2.1 4.6 1.1 5 -6.1 10 0.2]. Using conditional statements and loops, write a
program that rearranges the elements of x in order from the highest numeric value to the lowest numeric value. Do not
use Matlab's built-in sort function. For extra credit, make an input command for vector x that accepts input from the
user for a vector x to sort!
MATLAB
ONLY
or making vector x
or correct outer loop of sort
ror correct inner loop of sort
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a function called unroll, which takes in a square array of arrays (i.e. a grid with n rows and n columns). An input could look like this: constsquare=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]; unroll should take in such a square array and return a single array containing the values in the square. You should obtain the values by traversing the square in a spiral: from the top-left corner, move all the way to the right, then all the way down, then all the way to the left, then all the way up, and repeat. For the above example, unroll should return [1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10].arrow_forwardImplement in python please Write a function named "sort_word" that declares a parameter for a word and returns a string with the characters from the original word in sorted order. Hint: use the built-in Python sorted() function to convert the string into a sorted list of characters, and then use a for loop to convert the list back into a string. For example, given the word "tea", you would translate it into the String "aet". and return it.arrow_forwardWrite a script that finds the smallest of several nonnegative integers. Assume that the first value read specifies the number of values to be input from the user. Hint: No need for Array declaration. Think like a while loop and iterate as many number as users will input. Then keep a temporary variable to keep track of the minimum.arrow_forward
- Write a program to apply a cyclic shift in an array of characters (cstring) given number of spaces to shift. For example, if the input characters are abcadebcaand the number of spaces to shift is 3, the output will be: bcaabcadeIf the number of spaces is negative, the shift will be to the left. Note: You should NOT use any additional arrays (Apply the shift in-place). using Arrays and Vectors/ User-defined Functionsarrow_forwardYou have a long thin data set (THIN) created by running the following DATA step. You want a wide data set as shown in the folowing listing. Using arrays, write a program to do this (SAS). Data THIN; Input ID $ Time X @@; Datalines; 001 1 10 001 2 12 001 3 15 004 1 17 003 1 14 003 2 18 003 3 22 003 4 28 002 1 18 004 2 28 ;arrow_forwardIn c++, please! Thank you! Write a void function SelectionSortDescendTrace() that takes an integer array and sorts the array into descending order. The function should use nested loops and output the array after each iteration of the outer loop, thus outputting the array N-1 times (where N is the size). Complete main() to read in a list of up to 10 positive integers (ending in -1) and then call the SelectionSortDescendTrace() function. If the input is: 20 10 30 40 -1 then the output is: 40 10 30 20 40 30 10 20 40 30 20 10 The following code is given: #include <iostream> using namespace std; // TODO: Write a void function SelectionSortDescendTrace() that takes// an integer array and the number of elements in the array as arguments,// and sorts the array into descending order.void SelectionSortDescendTrace(int numbers [], int numElements) { } int main() { int input, i = 0; int numElements = 0; int numbers [10]; // TODO: Read in a list of up to 10 positive…arrow_forward
- Create a function append(v, a, n) that adds to the end of vector v a copy of all the elements of array a. For example, if v contains 1,2, 3, and a contains 4, 5, 6, then v will end up containing 1, 2, 3, 4, 5,6. The argument n is the size of the array. The argument v is a vector ofintegers and a is an array of integers. Write a test driver.arrow_forwardin C++ solve the following question in the picture :arrow_forwardYou’re writing a function that accepts an array of numbers and computes the highest product of any two numbers in the array. At first glance, this is easy, as we can just find the two greatest numbers and multiply them. However, our array can contain negative numbers and look like this: [5, -10, -6, 9, 4] We could use nested loops to multiply every possible pair of numbers, but this would take O(N^2) time. Your job is to optimize the function so that it’s a speedy O(N).arrow_forward
- 2. Fill in the for-loop below with the correct parameters to make room for the new value. saved Let's say that you have to write a function to insert an element into an ordered array. It takes an array A, a size, an index and a value. The value needs to be inserted at Aſindex] without losing values that are already in the array. // Assume that the index is found to be within array bounds and there is room to insert. for (int i = ?; ?; ?) { A[i]=A[i-1]; } A[index]=value; size++; O 0; i 0; - O size; i> index; -- O size-1; i>= index; i--arrow_forwardBelow is the recursive implementation of binary search from lab with one change (in red): the print statement at the top of the function which prints "BOO" There is also a main function which calls bsearchR on the sorted array data[] with 7 elements and searching for 10. QUESTION: How many BOOS will be printed by this program? // Recursive Binary Search Routine that does the "Real" Work int bsearchR(int a[], int lo, int hi, int x) { int m; printf("BO0\n"); // <<<<==== NEW STATEMENT if(hi < lo) return -1; m = (lo + hi) / 2; if(a[m] == x) return m; else if(x < a[m]) return bsearchR(a, lo, m-1, x); else return bsearchR(a, m+1, hi, x); } int main() { int data[] = {5, 8, 12, 15, 20, 25, 30}; int idx = bsearchR(data, e, 6, 10); return 0; }arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education