Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Value Sequences

Objectives
- Implement more advanced data structure.
- Practice using basic C++ data structures.
- Practice working with C++ classes.
- Practice working with partially provided code.

Introduction

There are times when certain simple functionality is best achieved by a data structure that builds on top of other, standard, data structures. Consider this example scenario. In our code, we are dealing with key/value pairs of integers. These are pairs of integers where the first integer is called key, and the second integer is called value. We want to store all key/value pairs such that for each key we know which values and in what order we have inserted. For example, for the following key/value pairs (0, 2), (-1, 3), (3, 7), (0, 5), (3, 2), (3, 5), (-1, 3), (-1, 0) we would like to be able to retrieve sequence (3, 3, 0) for key -1, sequence (2, 5) for key 0 and (7, 2, 5) for
key 3.

Your task is to extend partially implemented, and provided to you, key_value_sequences class, to provide exactly that functionality. So for example, this simple code (that roughly corresponds to the example above):
key_value_sequences A;

A.insert(0, 2);
A.insert(-1, 3);
A.insert(3, 2);
A.insert(0, 5);
A.insert(3, 7);
A.insert(3, 5);
A.insert(-1, 3);
A. insert(-1, 0);

auto p = A.data(3);
for (int i = 0; i < A.size(3); ++i) std::cout << p[i] << " ";

when compiled with properly implemented key_value_sequences should produce: 2 7 5.

As usually, your implementation has to be efficient and you have to work under certain con- straints. Specifically, you cannot use any external or standard C++ headers except of ,
and .

Hints

The simplest and reasonably efficient approach to this assignment is to use a combination of double-linked list (std::list<>) and vector (std::vector<>). Do not be afraid to make a list of vectors or vector of lists. Do not hesitate to leverage std::list<>::iterator, it is a type as any other C++ type. std::vector<> provides method data() that perfectly meets requirements you will need to implement method data() in key_value_sequences. This is one of many ways in which this problem can be approached.

Instructions

1. Create directory A3 where you will place your code.

2.Download A3-handout.tar from:
http://www.jzola.org/courses/2016/Fall/CSE250/A/A3-handout.tar.

3. Untar handout, and move a3.hpp and a3.cpp to your A3 directory.

4. Implement missing elements in a3.hpp taking into account the following:

(a) a3.hpp is the only file you are allowed to modify. a3.cpp is a simple test program demonstrating functionality that your implementation of key_value_sequences must support. You must use it to perform the most basic initial testing of your code. If your code fails to work with a3.cpp you will not be graded. You are not allowed to make any changes to a3.cpp.

(b) Analyze carefully a3.hpp and a3.cpp to better understand key_value_sequences. This class should implement functionality of multiple sequences, where each sequence stores integers and is "identified" by an integer key.

(c) Missing parts of the code that you are expected to implement are marked with IMPLEMENT ME. In short, you have to implement three critical methods: insert(), size() and data().

(d) Method insert() is the workhorse of the class. Its purpose is to take a key/value pair,
i.e. two integers, and push back the second integer (which is a value) into the sequence identified by the first integer (which is a key).

This is the only modifying method.

(e) Method data() is the main method to access the stored values. Its purpose is to take one integer (which is a key), and return a pointer to a sequence of all integers inserted with that key. If no element had been inserted with given key it should return nullptr. If a sequence exists for the key, the method should return pointer to the continuous block with that sequence. Elements in the sequence must be in the same order in which they had been inserted (refer to examples above).

(f) Method size() is another access method. Its purpose is to take one integer (which is a key), and return the total number of elements inserted with that key. If no element had been inserted with given key the method should return -1.

(g) You can add, remove or modify code in key_value_sequences without limits as long as it correctly compiles and executes with the provided a3.cpp and the only included headers are , , . To compile a3.cpp with your a3.hpp you should use basic compiler setting, e.g.: g++ -std=c++11 -O2 a3.cpp -o a3. If your code satisfies the most basic requirements for grading, you should see pass printed when executing a3.

(h) You are encouraged to use C++11 containers std::vector and std::list with all their goods to avoid raw pointers.

(i) Your implementation must be efficient. You can expect millions of key/value pairs inserted and your class should be able to handle them in seconds.

(j) You should make no assumptions about the distribution of inserted elements, i.e. keys or values, and the order in which elements will be inserted.

(k) You should be careful with how you utilize memory. If you are too excessive in al- locating memory, your code will exhaust available resources and your code will be terminated and not graded.

1. Remove your binary code and other unrelated files (e.g. your test files).

2. Create a tarball with your A3 folder.

3. Follow tohttps://autograder.cse.buffalo.eduand submit A3.tar for grading.

4. You have unlimited number of submissions, however, any submission after the deadline will have 50% points deducted.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92006957

Have any Question?


Related Questions in Computer Engineering

Assume that the group has a portfolio of 6 stocks there is

Assume that the group has a portfolio of 6 stocks. There is 30% chance that any one of these stocks will increase in value. Find the probability that four of the six stocks increases in value.

Single purpose processors design the sequence recognizer

Single Purpose Processors Design the sequence recognizer for 110. Perform the following steps: - 1. the state diagram - 2. the state table -K-map - 3. Simplification of the function by using the K-map -Circuit (logic dia ...

Consider a normally distributed set of scores with a mean

Consider a normally distributed set of scores with a mean of 0 and a standard deviation of 5. If a value of 3.25 is sampled from this distribution, what is the corresponding z-score? If necessary, round your answer to tw ...

The second array programming assignment is from 474-483

The SECOND array programming assignment is from 474-483 Write an ArrayList program that: 1. Creates a list of 5 automobile names that you make up and then retrieves those 5 names and displays all of them. 2. Adds Mercede ...

Select two application areas for data mining not discussed

Select two application areas for data mining NOT discussed in the text book and briefly discuss how data mining is being used to solve a problem (or to explore an opportunity)?

Question the subnet mask for a class c network is

Question : The subnet mask for a class C network is 255.255.255.248. How many subnetworks are available? How many assignable hosts ids per subnet? The response must be typed, single spaced, must be in times new roman fon ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

Question state the considerations of selecting and handling

Question : State the considerations of selecting and handling participants for a usability experiment. Describe and compare types of usability testing.

What is a good analogy of subnetting whats a break down of

What is a good analogy of Subnetting? What's a break down of how it is used within a company?

Can you help me how i can connect 2 new sub java classes to

Can you help me how I can connect 2 new sub java classes to the main one with CSV file? I will attach the instruction and the CSV file if you guys accept this. Please help me do it. Please add descriptive comments so I c ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As