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
Question
: In an array of integers, a "peak" is an element which is greater than or equal to
the adjacent integers and a "valley" is an element which is less than or equal to the adjacent integers. For example, in the array {5, 8, 6, 2, 3, 4, 6}, {8, 6} are peaks and {5, 2} are valleys. Given an array
of integers, sort the array into an alternating sequence of peaks and valleys.
EXAMPLE
Input: {5, 3, 1, 2, 3}
Output: {5, 1, 3, 2, 3}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 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
- D3 no. D4. Coding. Thearrow_forwardSuppoce we're given numpy arrays of names and scores, where each row in the scores array lists the midterm and final scores for that respective student. For example, Carol has a 75 on the midterm and 99 on the final. names = np. array([ "Alice" "Bob". "Carol","Derek ","Erin"]) Scores = np.array([ [95, 98], [82, 88], [75, 99], [80, 90], 85, 82 ]]) Write function avgMidtermNoC that takes ve parameters names and score arrays, and returns the average score on the midterm, exduding anyone who's name starta with C.arrow_forwardYou are given an array J[1 : n] which includes the scores of n players in a game. You are additionally given an array P[1 : m] with the score of m new players. Design and analyze an algorithm that given both arrays J and P, can find the rank of each player P inside the array J, i.e., for each P[i], determines what would be the rank of P[i] in the array consisting of all elements of J plus P[i]. Your algorithm should run in O((n + m) ·log n) time.arrow_forward
- import numpy as np a = np.array([1,2,3]) b = np.array([4,5,6]) You may need to use NumPy methods to answer the following questions. What is the cross product of the two vectors a and b given above? What is the dot product of the two vectors a and b given above?arrow_forwardAn array is positive dominant if it contains strictly more unique positive values than unique negative values. Write a function that returns true if an array is positive dominant. Examples ispositiveDominant([1, 1, 1, 1, -3, -4]) // There is only 1 unique positive value (1). // There are 2 unique negative values (-3, -4). ispositiveDominant([5, 99, 832, -3, -4]) → true ispositiveDominant([5, 0]) → true ispositive Dominant([0, -4, -1]) → falsearrow_forwardIn [ ]: We obtained an array with N = 10 values, scattered about mean of 25 (mm). Let's calculate the mean, standard deviation, standard deviation of the mean and 20-uncertainty SL of these numbers. In the following code, do these steps: • In the first cell, add a brief comment that explains what each statement does. Start each comment with a # sign. • In the second cell, delete the raise Not ImplementedError() code line and print the standard deviation and 20-uncertainty on the screen (follow the example for mean_L) mean_L = np.mean (L) print("Mean length: ", mean_L) stddev_L = np. std (L, ddof=1) stddev_mean_L = stddev_L/np.sqrt(N) uncertainty_L = 2*stddev_mean_L In [ ] V #YOUR CODE HERE raise NotImplementedError() #calculates the mean of L In the above code, the green expressions on the right hand side, such as np.mean, np. std and np.sqrt are functions built into the numpy package of Python. The names on the left hand side are variable names invented by me.arrow_forward
- Given an array, find the next greater element for each element in the array, ifavailable. If not available, print the element itself. The next greater element y for anelement x in the array is the first element that is greater than x and occurs on its rightside. The next greater element of the right most element in an array is the elementitself.Example: Given A = [ 6 8 4 3 9] the next greater element listB = [8 9 9 9 9].arrow_forwardNote: Set a random seed of 100 for this assignment. All arrays should contain random numbers between 0 and 1 (zero is inclusive). Create a one-dimensional array of twenty float random numbers. Assign the sum of these values to Q1. Assign the max of these values to Q2. Create a four by five array of random numbers. Take the minimum values in each array and create an array of those values. Assign it to Q3. Assign the mean of all the array values to Q4. Create an array with the following values: 2, 3, np.nan (this should represent a missing value), and 5. Use a numpy function to find the sum of the values in this array. Assign the sum to Q5 (you should expect a numerical value here). Create two separate arrays each containing four random numbers. Concatenate the two arrays and assign it to Q6. Create a four by four array of random numbers and call it q7. Concatenate this array with itself and assign it to Q7. Create a two by four array of…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