import math array = [4, 5, 6, 7, 8, 9, 33, 24, 15, 11] print("Original array") print(array) print() # Get no. of elements n = len(array) s = math.floor((n-1)/2) e = math.floor(n/2) # while loop while (s >= 0 and e <= n-1): # swap the numbers array[s], array[e] = array[e], array[s] s = s-1 e = e+1 # now array is reversed print("Reversed array") print(array) Check this code and ,using time measurements, test your algorithm and plot a graph that shows its growth rate when variating the size.
import math array = [4, 5, 6, 7, 8, 9, 33, 24, 15, 11] print("Original array") print(array) print() # Get no. of elements n = len(array) s = math.floor((n-1)/2) e = math.floor(n/2) # while loop while (s >= 0 and e <= n-1): # swap the numbers array[s], array[e] = array[e], array[s] s = s-1 e = e+1 # now array is reversed print("Reversed array") print(array) Check this code and ,using time measurements, test your algorithm and plot a graph that shows its growth rate when variating the size.
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
Related questions
Question
import math
array = [4, 5, 6, 7, 8, 9, 33, 24, 15, 11]
print("Original array")
print(array)
print()
# Get no. of elements
n = len(array)
s = math.floor((n-1)/2)
e = math.floor(n/2)
# while loop
while (s >= 0 and e <= n-1):
# swap the numbers
array[s], array[e] = array[e], array[s]
s = s-1
e = e+1
# now array is reversed
print("Reversed array")
print(array)
Check this code and ,using time measurements, test your
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
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.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage