2. (15 marks) Consider the abstract datatype SEQ whose objects are sequences of elements and which...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. (15 marks) Consider the abstract datatype SEQ whose objects are sequences of elements and which supports two operations: PREPEND(x, S), which inserts element r at the beginning of the sequence S and ACCESS(S, i), which returns the i'th element in the sequence. Suppose that we represent S by a singly linked list. Then PREPEND(x, S) takes 1 step and ACCESS(S, i) takes i steps, provided S has at least i elements. Suppose that S initially has exactly one element. A sequence of n operations are performed. Each operation in the sequence is (independently) chosen to be a PREPEND with probability p and an ACCESS with probability 1-p. For each ACCESS operation, the value of the parameter i is chosen uniformly from [1..|S|]. (d) (4 marks) Derive the expected number of steps taken to perform all n operations. 2. (15 marks) Consider the abstract datatype SEQ whose objects are sequences of elements and which supports two operations: PREPEND(x, S), which inserts element r at the beginning of the sequence S and ACCESS(S, i), which returns the i'th element in the sequence. Suppose that we represent S by a singly linked list. Then PREPEND(x, S) takes 1 step and ACCESS(S, i) takes i steps, provided S has at least i elements. Suppose that S initially has exactly one element. A sequence of n operations are performed. Each operation in the sequence is (independently) chosen to be a PREPEND with probability p and an ACCESS with probability 1-p. For each ACCESS operation, the value of the parameter i is chosen uniformly from [1..|S|]. (d) (4 marks) Derive the expected number of steps taken to perform all n operations.
Expert Answer:
Answer rating: 100% (QA)
To derive the expected number of steps taken to perform all n operations we need to consider the exp... View the full answer
Related Book For
Discrete Mathematics and Its Applications
ISBN: 978-0073383095
7th edition
Authors: Kenneth H. Rosen
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Assume that 3-month Treasury bills totaling $23 billion were sold in $10,000 denominations at a discount rate of 5.200%. In addition, the Treasury Department sold 6-month bills totaling $21 billion...
-
Only LCD produces LCD touch screen products. The company reports the following information at December 31. Only LCD began operations on January 31 earlier that same year. Requirements 1. What is the...
-
A circuit has four inputs and two outputs. The inputs 3:0 represent a number from 0 to 15. Output P should be TRUE if the number is prime (0 and 1 are not prime, but 2, 3, 5, and so on, are prime)....
-
Find the response of a simple pendulum numerically by solving the nonlinear equation: \[\ddot{\theta}+\frac{g}{l}\left(\theta-\frac{\theta^{3}}{6} ight)=0\] with \(\frac{g}{l}=0.01\) and plot the...
-
Henley Horticulture provides and maintains live plants in office buildings. The company's 850 customers are charged $30 per month for this service, which includes weekly watering visits. The variable...
-
Identify the demand elasticity of the following products. Product #1: Natural Gas (used for heating a home) (0.5 points) - Elastic or Inelastic - Circle, highlight, or bold your answer Product #2:...
-
Consider the following string of page references 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2. Complete a figure similar to Figure 8.14, showing the frame allocation for: a. FIFO (first-in-first-out) b. LRU...
-
Application requirements: At least 4 classes with at least 3 fields and 2 methods in every class The program should contain a minimum of two conditional statements(at least one switch statement) ...
-
Distributed computing is for Saved 1 ) Resource sharing 2 ) Computing speed 3 ) Resource sharing and Fault - tolerance 4 ) Fault - tolerance
-
Describe a Distributed Computing Project you know of.
-
The following reaction was set-up as follows: R-OH HBr R-Br Where R-OH could be one of the following possible compounds 1-4
-
1. Create a new database named YourName.accdb. 2. Create a table named Employees. 3. Inspect the data.csv 4. Import the data.csv file into the Employees table. 5. Set the Employee_ID field as the...
-
You will use the annual reports to create financial statements. These statements will become the reference statements for your case. Annual reports for JNJ can be found on the companys website and...
-
Two blocks. A and B, are being pulled to the right along a horizontal surface by a horizontal 100-N pull, as shown in the figure. Both of them are moving together at a constant velocity of 20 m/s to...
-
In each of the following independent cases, document the system using whatever technique(s) your instructor specifies. a. Dreambox Creations (www.dreamboxcreations.com/) in Diamond Bar, California,...
-
Show that , , and form a functionally complete collection of logical operators.
-
Construct a K-map for F(x, y, z) = xz + xyz + yz. Use this K-map to find the implicants, prime implicants, and essential prime implicants of F(x, y, z).
-
The first nine digits of the ISBN-10 of the European version of the fifth edition of this book are 0-07-119881. What is the check digit for that book?
-
For a pure substance, if internal energy is considered to be the function of any two of the independent variables \(P, V\), and \(T\), then derive the following relations: (a) \(\left(\frac{\partial...
-
A gas obeys the equation of state \(V=\frac{R T}{P}-\frac{C}{T^{2}}+\frac{D}{T^{3}}\). Find out the variation \(C_{P}\) at constant temperature.
-
Deduce two \(T d S\) equations and mention why \(T d S\) equations are so useful.
Study smarter with the SolutionInn App