ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 19 May 2017 My Price 10.00

package edu.buffalo.cse116

1. For the first question, only need to finish toArray() and fromArray(E[] arr) these two methods.

1) toArray()-- this method returns a newly allocated array containing the elements in the multiset. The array this method returns must only contain the elements in the multiset and not any nulls or other values that are stored in the backing store, but are not in the multiset.

2) fromArray(E[] arr) this method updates the multiset so that it contains the data in arr. Check if arr is larger than the backing store and, if it is, allocate a new array to be used by the backing store. You should then set the size of the multiset equal to the length ofarrand assign those entries in the backing store to the entries in arr.

2. Implement the add() method and also complete the removeAtIndex(). removeAtIndex(int i) should remove the element current at index i, decrease the multi-set's size, and make certain that the class invariant holds.

For this question I have finished the add() method, but I did not figure out the removeAtIndex() method...

 

package edu.buffalo.cse116;import java.util.Arrays;import java.util.Collection;import java.util.Iterator;import java.util.List;import java.util.Set;/*** Class which implements the concept of a multiset -- an unorganized collection* which does not limited the number of times an instance can be added.** @author Carl Alphonse* @author Matthew Hertz* @param <E> Type of data contained with the instance.*/public class InitialArrayMultiSet<E> implements Collection<E> {/** Array in which the elements in this multiset are stored. */protected E[] _store;/*** Array indices below this amount contain the active elements in this* collection.*/protected int _size;/*** Modification counter used to preserve the fail-fast nature of its* iterators.*/protected long _modCount;/*** Create a new empty multiset.*/public InitialArrayMultiSet() {_modCount = 0;clear();}/*** Remove all of the elements within the instance and invalidate any current* iterators.*/@SuppressWarnings("unchecked")public void clear() {_store = (E[]) (new Object[16]);_size = 0;// maintains the class invariant_modCount += 1;}/*** Update the multiset so that it includes all of the elements from before the* call AND the given element.** @param e Item to be added to this collection.*/public boolean add(E e) {// To be discussed on Wednesday!throw new UnsupportedOperationException();}/*** Return true if at least one element in the multiset is equal to the given* object. When {@code obj} is null, it must use the {@code ==} operator to

package edu.buffalo.cse116;import java.util.Collection;import java.util.Iterator;/*** Class which implements the concept of a multiset -- an unorganized collection* which does not limited the number of times an instance can be added.** @author Carl Alphonse* @author Matthew Hertz* @param <E> Type of data contained with the instance.*/public class PartialArrayMultiSet<E> implements Collection<E> {/** Array in which the elements in this multiset are stored. */protected E[] _store;/*** Array indices below this amount contain the active elements in this* collection.*/protected int _size;/*** Modification counter used to preserve the fail-fast nature of its* iterators.*/protected long _modCount;/** Class invariants:* _store has all of the elements in the multi-set.* All elements in _store are in indices < _size*//*** Create a new empty multiset.*/public PartialArrayMultiSet() {_modCount = 0;clear();}/*** Remove all of the elements within the instance and invalidate any current* iterators.*/@SuppressWarnings("unchecked")public void clear() {_store = (E[]) (new Object[16]);_size = 0;// maintains the class invariant_modCount += 1;}/*** Update the multiset so that it includes all of the elements from before the* call AND the given element.** @param e Item to be added to this collection.*/@SuppressWarnings("unchecked")public boolean add(E e) {if(_size == _store.length){

Answers

(11)
Status NEW Posted 19 May 2017 06:05 AM My Price 10.00

-----------

Attachments

file 1495176666-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)