Sets and bags, Computer Engineering

Task: Sets and bags

In mathematics, the notion of multiset (or bag) is a generalisation of the notion of set.

A bag is a special kind of container in which the items may be repetitive, and without any order. A set is a container in which items may NOT be repetitive (each element in a set is unique).

Our purpose in this assignment is to implement the set and bag concept by using an array-based list structure.

The program

This assignment will be implemented by the use of 2 interfaces named:
1. SetList
2. BagList

The SetList interface will contain the following method headers: 

Sets

The implementation of the SetListType has to take into account the fact that repeat values are not stored. The only requirement as far as this assignment is concerned, is that you use an array-based list structure to implement both sets and bags.

Bags

The implementation of the BagListType has to take into account the fact that repeat values are stored. For the purposes of this assignment , we will employ a dual array technique so as to eliminate having to physically store a value (object) we have already put into our bag structure. One array will store the object, the second array will store the number of times this object is present in our bag structure (i.e., the second array is of type  int)For example, for an input of Integers of the following values:

1 2 3 4 5 3 2

These values would normally be stored in a single array as shown below.

1021_Sets and bags.png

Posted Date: 2/26/2013 2:03:36 AM | Location : United States







Related Discussions:- Sets and bags, Assignment Help, Ask Question on Sets and bags, Get Answer, Expert's Help, Sets and bags Discussions

Write discussion on Sets and bags
Your posts are moderated
Related Questions
Bitwise-Inclusive-OR Operator: inclusive-OR-expression : exclusive-OR-expression inclusive-OR-expression | exclusive-OR-expression The  bitwise-inclusive-OR  operator

Q. When an object travels with constant velocity does its average velocity during any time interval differ from its instantaneous velocity at any instant? Answer:- No It i

Q. Explain Register Addressing Mode? Operand can be a 16-bit register: Addressing Mode Description Example AX, BX, CX, DX, SI,

Question: (a) Provide types of computer systems and briefly describe each one. (b) With the help of example, explain the difference between open source software, freeware a

What is CMP instruction Comparison instruction (CMP) is a subtraction that changes only the flag bits; destination operand never changes. A comparison is useful for checking th

In the message-passing model, there exists a set of tasks that use their own local memories during computation. Multiple tasks can reside on the similar physical machine as well ac

Write a recursive algorithm to count the number of right children in a binary search tree. Write the method levelCount whose header is given below. Method levelCount returns

Simple instruction formats: RISC uses simple instruction formats. Usually only one or a few instruction formats are used. In these machines instruction length is fixed and alig

how to make a dec oder

WAR (write after read) - Data hazards in computer architecture: WAR (write after read) - j tries to write at destination before it is read by i , hence i  wrongly gets the n