Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem: Write a piece of code that given an STL (standard template library) stack of doubles, it will remove the negative entries from the stack.

Problem: Write a piece of code that given an STL (standard template library) stack of doubles, it will remove the negative entries from the stack. The order of the remaining entries must be preserved.

Header code:

image text in transcribed

template struct nodeType T data nodeType class myLL public: myLL(); //the default constructor void insert (T) //insert at the beginning of the list void print(); void inserts(T x); //insert x immediately before the first element that is bigger than x int getSize() { return size; } bool isEmpty() return head--nullptr;) bool remove(T) //remove the first occurrence of the specified element bool search (Tx); //returns true if x is in the list; void split(myLL &L1, myLL&L2); //splits the list into two lists L1 and L2 //where L1 is contains the first size/2 elements, // and the second list contains the rest of the elements //at the end of the operation the original list must be empty // e.g. if the original 1ist L-(21,1,12,34,56, /1 then after the operation L-, L1-(21,1,12), L2-(34,56) int numPosElements() //returns the number of elements for which the field data>e /ote this will only work for those list that the comparison data? is defined private: nodeType

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions