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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
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 algorithm and plot a graph that shows its growth rate when variating the size.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage