Write a SplitStack( ) function that divides a sorted linked Stack S, which conta
ID: 3637855 • Letter: W
Question
Write a SplitStack( ) function that divides a sorted linked StackS, which contains Objects of Character, into two linked stacks (S1 and
S2) according to the key (keyItem), where S1 contains all the items of
Stack whose keys are less than or equal to item’s key (keyItem)and S2
contains all the items of Stack whose keys are greater than to item’s
key (keyItems).
void SplitStack (LStack S , LStack S1, LStack S2,Character keyItem)
Note: To compare two objects of Character, you can use the character
method compareTo() as follows:
Character c = new Character('a');
Character c1 = new Character('b');
int x = c.compareTo(c1);
// x will hold number < 0 if c < c1 alphabetically
// x will hold number > 0 if c > c1 alphabetically
// x will hold number = 0 if c = c1 alphabetically
Explanation / Answer
splitstack() { char s[],s1[],s2[],c; int x; pritf("entr the key); scanf("%c',& c); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.