Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A certain program has to maintain an array, count, of N counters which are all initialized to zero. The value of counter i can be

A certain program has to maintain an array, count, of N counters which are all initialized to zero. The value of counter i can be incremented by one by the call increment (1), and this is the only way the program changes counter values. Two variables, mincount and max count, must always hold the smallest and largest of the counter values whenever the point of execution is not within the function increment. You may assume that increment is called about 1000N times when the program is run and that its argument is typically uniformly randomly distributed between 1 and N, but on some runs it cycles through the numbers 1 to N in order 1001 times. (a) Describe, in detail, an efficient data structure and algorithm to use when N is expected to be about 10 (b) Describe, in detail, an alternative data structure and algorithm to use when N is about a million Suppose your algorithm for (a) above were used when N = 109, estimate how much slower it would be compared with your algorithm for (b).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago