Question

Given a circular array implemented in Python: blockCapacity=100, dataStartIndex=80, dataCount=87. Figure out the index of the...

Given a circular array implemented in Python: blockCapacity=100, dataStartIndex=80, dataCount=87. Figure out the index of the last data item?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

The circular array will again start from index 0 when then block size is full.

Given:

Circular array

BlockCapacity = 100
dataStartIndex = 80
dataCount = 87

Answer:

The index of last element is 66

Explanation:

In a circular array of size 100 the index ranges from 0 - 99

Here the data startIndex is 80 while the count is 87

The first 20 elements will be in index 80 - 99.
The remaining number of elements are 87-20 = 67

These 67 elements will be in indexes 0-66.

So we can conclude the index of last data item is 66

Index and data element numbers:

index 80 81 82 83 84 85 86 87 88 89
data element 1 2 3 4 5 6 7 8 9 10
index 90 91 92 93 94 95 96 97 98 99
data element 11 12 13 14 15 16 17 18 19 20
index 0 1 2 3 4 5 6 7 8 9
data element 21 22 23 24 25 26 27 28 29 30
index 10 11 12 13 14 15 16 17 18 19
data element 31 32 33 34 35 36 37 38 39 40
index 20 21 22 23 24 25 26 27 28 29
data element 41 42 43 44 45 46 47 48 49 50
index 30 31 32 33 34 35 36 37 38 39
data element 51 52 53 54 55 56 57 58 59 60
index 40 41 42 43 44 45 46 47 48 49
data element 61 62 63 64 65 66 67 68 69 70
index 50 51 52 53 54 55 56 57 58 59
data element 71 72 73 74 75 76 77 78 79 80
index 60 61 62 63 64 65 66
data element 81 82 83 84 85 86 87
Add a comment
Know the answer?
Add Answer to:
Given a circular array implemented in Python: blockCapacity=100, dataStartIndex=80, dataCount=87. Figure out the index of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index...

    Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code. Consider the declaration: int v[1]; What is the index of the last element of this array? Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the...

  • 3. A queue implementation is being done using a circular array. It has a front and...

    3. A queue implementation is being done using a circular array. It has a front and a rear index for the array. Given that the queue length is q.length, give the following tests: How do you test if the queue is empty? How do you test if the queue is full? Assuming the queue is not empty, how do you remove an item from the queue? (How do you update the values for front and/or rear?) Assuming the queue is...

  • 2-dimensional array in python

    Using python 2-dimensional array to find the average marks of all subject for all the following students: Student IDMidTermProjectAssignmentFinal Exam140/5050/10015/2050/100250/5030/10010/2010/100322/5043/1008/2030/100440/5036/10019/2043/100520/5080/10011/2051/100  Rules to follow:Please make use of 2-Dimensional Array to store the above data and perform calculation. Make sure the average is printed in 2 decimal point. Please store your two dimension array with variable datass in the submission template. Do not use your own variable. This might affect the accuracy of system grading. Make sure your algorithm able to support different size...

  • (C++) Given an array with Job_id, Arrival_Time & Duration: Array[5][3] 0 0 100 1 20 80...

    (C++) Given an array with Job_id, Arrival_Time & Duration: Array[5][3] 0 0 100 1 20 80 2 30 60 3 40 50 4 50 40 Use simple array manipulation in C++ to implement "Shortest Job First" to show arrival start time, finish time and response time for each job.

  • Data Set given for pulse rates 68 78 79 80 85 85 87 88 90 91...

    Data Set given for pulse rates 68 78 79 80 85 85 87 88 90 91 92 95 96 97 100 102 103 110 114 125 What percentile is 97 located at?

  • In Python import numpy as np Given the array a = np.array([[1, 2, 3], [10, 20,...

    In Python import numpy as np Given the array a = np.array([[1, 2, 3], [10, 20, 30], [100, 200, 300]]), compute and print the sums over all rows (should give [6, 60, 600]) the sums over all columns (the sum of he first column is 111) the maximum of the array the maxima over all rows the mean of the sub-array formed by omitting the first row and column the products over the first two columns (hint: look for an...

  • Write a python nested for loop that prints out the following pattern 100 99 98 97...

    Write a python nested for loop that prints out the following pattern 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33...

  • IN JAVA please Given a sorted array and a target value, return the index if the...

    IN JAVA please Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. Your code will be tested for runtime. Code which does not output a result in logarithmic time (making roughly log(2) N comparisons) will fail the tests. A sample main function is provided so that you may test your code on sample inputs. For testing purposes, the...

  • Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D...

    Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10. 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures...

  • [Java] Efficiency Comparison of two Implemented Queues : Circular Array Queue and SSQueue and its enqueue...

    [Java] Efficiency Comparison of two Implemented Queues : Circular Array Queue and SSQueue and its enqueue and dequeue operations Need to write a program that compares the efficiency of the queue implementations. To do so, you need to find and compare the running times of 1 the following two scenarios for both queue implementations: 3.1 Scenario 1: Alternating Sequence of Enqueues and Dequeues For every n ∈ {20, 50, 100, 1000, 10000, 100000, 1000000}, do the following: 1. long startTime...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT