EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 1, Problem 13E
Explanation of Solution
Transformed Declaration for “genClass” :
Refer question 13 from chapter 1 for given declaration syntax
A new declaration of genClass is:
Declaration:
//Decalare a template class
template<class T>
class genClass2
{
T *storage;
//Declare the variables
int size;
//Define the function “memberFun()”
void memberFun()
{
/* Check whether value of “someVar” is less than “size” */
if (someVar < size)
{
}
}
//Define a function “genClass2” with integer parameter
public:
genClass2(int n = 50)
{
/*Declare “storage” with type “T” and integer size*/
sto...
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Declare and implement 5 classes: FloatArray, SortedArray, FrontArray, PositiveArray & NegativeArray
1- The FloatArray class stores a dynamic array of floats and its size. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the end of the array.- Overloading for the insertion operator << to write the array to afile (ofstream)- Overloading for the extraction operator >> to read the array elements from the file (ifstream) and add them to the array.- A destructor to deallocate the array
2- The SortedArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the right place in the arraysuch that the array remains sorted with every add. Don’t add to the array then sort but rather add in the right place.
3- The FrontArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the front…
Declare and implement 5 classes: FloatArray, SortedArray, FrontArray, PositiveArray & NegativeArray. 1- The FloatArray class stores a dynamic array of floats and its size. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the end of the array.- Overloading for the insertion operator << to write the array to afile (ofstream)- Overloading for the extraction operator >> to read the array elements from the file (ifstream) and add them to the array.- A destructor to deallocate the array2- The SortedArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the right place in the arraysuch that the array remains sorted with every add. Don’t add to the array then sort but rather add in the right place.3- The FrontArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the front…
Write Java code
Objectives
•Use an abstract data type for a list
•Use a method that contains an Object type as a formal parameter
•Use methods in an existing class
•Access data members within a class
Required Files:
•ListInterface.java
•ListException.java
•ListOutOfBoundsException.java
•ListArrayBased.java
Description A list is an abstract data type used to store ordered data, and contains operations that fall into the following categories: (1) add data to a data collection, (2) remove data from a data collection, and (3) ask questions about data in a data collection. The operations which ask questions about the data in a data collection may include operations that determine if a data collection is empty, determine the size of a data collection, and retrieve the item at a given position in a data collection. A list should be able to contain any type of object. The methods for the List support any object as specified in the interface. In this assignment, the objects will be S trings.…
Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Similar questions
- Main Class Implement a main class that implements our ParkingOffice.java class. Parkingoffice.java public class ParkingOffice {String name;String address;String phone;String parkingOfficeName;List<Customer> customers;List<Car> cars;List<ParkingLot> lots;List<ParkingCharge> charges; public ParkingOffice(){customers = new ArrayList<>();cars = new ArrayList<>();lots = new ArrayList<>();charges = new ArrayList<>();} public String getParkingOfficeName(){return this.parkingOfficeName;} /* to implement the desired park function */ public String park(Date date,String ParkingPermit,ParkingLot pl){ /* to have the amount paid during the transaction forthe specified parking lot */double amount=pl.amount;/* to have the date on which the parking lot is booked */String onDate=date.toString();/* to know the permit id */String permitId=ParkingPermit;/* to print the transaction receipt */String s="Amount paid on date: ";s=s+onDate;s=s+" is…arrow_forwardin c++ Declare and implement 5 classes: FloatArray, SortedArray, FrontArray, PositiveArray & NegativeArray. 1- The FloatArray class stores a dynamic array of floats and its size. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at the end of the array. - Overloading for the insertion operator << to write the array to a file (ofstream) - Overloading for the extraction operator >> to read the array elements from the file (ifstream) and add them to the array. - A destructor to deallocate the array 2- The SortedArray inherits from FloatArray. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at the right place in the array such that the array remains sorted with every add. Don’t add to the array then sort but rather add in the right place. 3- The FrontArray inherits from FloatArray. It has: - A parameterized constructor that takes the array size. - An add method that adds a…arrow_forwardDeclare and implement 5 classes: FloatArray, SortedArray, FrontArray, PositiveArray & NegativeArray. 1- The FloatArray class stores a dynamic array of floats and its size. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at the end of the array. - Overloading for the insertion operator << to write the array to a file (ofstream) - Overloading for the extraction operator >> to read the array elements from the file (ifstream) and add them to the array. - A destructor to deallocate the array 2- The SortedArray inherits from FloatArray. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at the right place in the array such that the array remains sorted with every add. Don’t add to the array then sort but rather add in the right place. 3- The FrontArray inherits from FloatArray. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at…arrow_forward
- Declare and implement 5 classes: FloatArray, SortedArray, FrontArray, PositiveArray & NegativeArray. 1- The FloatArray class stores a dynamic array of floats and its size. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at the end of the array. - Overloading for the insertion operator << to write the array to a file (ofstream) - Overloading for the extraction operator >> to read the array elements from the file (ifstream) and add them to the array. - A destructor to deallocate the array 2- The SortedArray inherits from FloatArray. It has: - A parameterized constructor that takes the array size. - An add method that adds a float at the right place in the array such that the array remains sorted with every add. Don’t add to the array then sort but rather add in the right place. 3- The FrontArray inherits from FloatArray. It has: - A parameterized constructor that takes the array…arrow_forwardStringSorter.java is below: import java.io.*; // for Reader (and subclasses), Writer (and subclasses) and IOExceptionimport java.util.*; // for List, ArrayList, Iterator public class StringSorter { ArrayList lines; // given that we don't really know how to deal with a read/write error (IOException) // inside the functions, we'll let it pass through public void readFromStream(Reader r) throws IOException { BufferedReader br=new BufferedReader(r); lines=new ArrayList(); while(true) { String input=br.readLine(); if(input==null) break; lines.add(input); } } public void writeToStream(Writer w) throws IOException { PrintWriter pw=new PrintWriter(w); Iterator i=lines.iterator(); while(i.hasNext()) { pw.println((String)(i.next())); } } // returns the index of the largest element in the list static int findIdxBiggest(List l, int from, int to) { String…arrow_forwardDeclare and implement 5 classes: FloatArray, SortedArray,FrontArray, PositiveArray & NegativeArray.1- The FloatArray class stores a dynamic array of floats and itssize. It has:- A parameterized constructor that takes the array size.- An add method that adds a float at the end of the array.- Overloading for the insertion operator << to write the array to afile (ofstream)- Overloading for the extraction operator >> to read the arrayelements from the file (ifstream) and add them to the array.- A destructor to deallocate the array2- The SortedArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size.- An add method that adds a float at the right place in the arraysuch that the array remains sorted with every add. Don’t add tothe array then sort but rather add in the right place.3- The FrontArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size.- An add method that adds a float at the front of the…arrow_forward
- Declare and implement 5 classes: FloatArray, SortedArray,FrontArray, PositiveArray & NegativeArray.1- The FloatArray class stores a dynamic array of floats and itssize. It has:- A parameterized constructor that takes the array size.- An add method that adds a float at the end of the array.- Overloading for the insertion operator << to write the array to afile (ofstream)- Overloading for the extraction operator >> to read the arrayelements from the file (ifstream) and add them to the array.- A destructor to deallocate the array2- The SortedArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size.- An add method that adds a float at the right place in the arraysuch that the array remains sorted with every add. Don’t add tothe array then sort but rather add in the right place.3- The FrontArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size.- An add method that adds a float at the front of the…arrow_forwardIN c++ See the specification of the HugeInt class.Complete the implementation of this class.Provide a driver to demonstrate the features of the HugeInt class. HugeInt.h #ifndef HUGEINT_H_#define HUGEINT_H_ enum SignType {PLUS, MINUS}; class HugeInt{private: struct Node { int digit; // SINGLE DIGIT ONLY ie: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) Node *next; // Next More Significant Digit }; /* Integer 345 is stored in List: 3 <- 4 <- 5 <- digits Integer 123 is stored in List: 1 <- 2 <- 3 <- digits To add: add the least significant digits, potentially keeping track of a carry value. Then move to the next left nodes in both HugeInts. Add these and the carry. Create a new carry value. Continue until both HugeInt lists are empty. If one list is empty, keep processing the non-empty list. */ Node *digits; //Linked list of digit nodes SignType sign; //enum of the sign of the HugeInt int…arrow_forwardQ# In Java, if you see a class name followed by “<T>”, as in List<T>, what does this mean?Group of answer choices 1.It is what is called a lambda-function. 2.It’s for making collections of objects of many types at the same time. For example, if I make List<T> myList = new List<T> I can put a String as one item, an int as another, and a Random as a third item. 3.You must specify an object type in place of the T; eg. List<Shape> will make a list of Shape objects. 4. It means that the object is of type Time.arrow_forward
- Java programming I have to do the "Resize method" which I believe if the array is full, it should resize so there is space. Ill paste the code below: package circularQueue; /* * Design the class that would implement the interfaceiQueue. */ public class cirQueue <T> implements iQueue <T> { //Array of T objects private T[] Ar; //reference to array of objects //int size keeps track of how many elements in the queue int size = 0; //first the index to the head of the queue int first = -1; //last the index the last element of the queue int last = -1; public cirQueue() { Ar = (T[]) new Object[5]; size = 0; first = last = -1; } public int size() { return size; } public boolean empty() { return (size == 0); } private void resize() { //HW TODO } //inserts element e at the back of the queue public void insert(T e) { if(this.empty()) { first = last = 0; //insert e at indx 0; Ar[first] = e; size = 1; return; } if(size == Ar.length) { //resize HW complete this one.…arrow_forwardC#: PLease add inheritance and polymorphism in the code. And display the vehicle/s. Thanks!using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace DemoApplication{ public class Vehicle { protected int VehicleID; protected string VehicleName; public void SetTutorial(int pID,string pName) { VehicleID=pID; VehicleName=pName; } public String GetVehicle() { return VehicleName; } } public class VehicleDetails:Vehicle { public void RenameVehicle(String pNewName) { VehicleName=pNewName; } static void Main(string[] args) { VehicleDetails VD=new VehicleDetails(); VD.RenameVehicle("CarName:Audi"); VD.RenameVehicle("Number of doors:4"); VD.RenameVehicle("Number of wheels:4"); VD.RenameVehicle("Maxspeed:180 KMPH"); VD.RenameVehicle("Fuel capacity:50 lts"); Console.WriteLine(VD.GetVehicle()); Console.ReadKey(); } }}arrow_forwardProgramming Exercise 8 asks you to redefine the class to implement the nodes of a linked list so that the instance variables are private. Therefore, the class linkedListType and its derived classes unorderedLinkedList and orderedLinkedList can no longer directly access the instance variables of the class nodeType. Rewrite the definitions of these classes so that these classes use the member functions of the class nodeType to access the info and link fields of a node. Also write programs to test various operations of the classes unorderedLinkedList and orderedLinkedList. template <class Type>class nodeType{public:const nodeType<Type>& operator=(const nodeType<Type>&);//Overload the assignment operator.void setInfo(const Type& elem);//Function to set the info of the node.//Postcondition: info = elem;Type getInfo() const;//Function to return the info of the node.//Postcondition: The value of info is returned.void setLink(nodeType<Type>…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education