write an algorithm using stack to determine if an input of string is in the form xCy where y is the reverse of x.x and y are strings of A and B.
eg AABACABAA
please help me out!
write an algorithm using stack to determine if an input of string is in the form xCy where y is the reverse of x.x and y are strings of A and B.
eg AABACABAA
please help me out!
What are you having a problem with? You should post any code you're having trouble with (in code tags) and ask specific questions about where you're stuck.
I want the algorithm.I have no idea how to go about!!I have to submit this assignment by monday .If you or anyone can give me the the algorithm i would be saved .
write an algorithm using stack to determine if an input of string is in the form xCy where y is the reverse of x.x and y are strings of A and B.Not likely going to happen - we have a homework policy here.If you or anyone can give me the the algorithm i would be saved .
Since this is an assignment, it stands to reasons that you've learned something about this problem (or something that can be used for solving it) during class. For instance, have you worked with stacks yet?
Think about it, come up with some ideas, and ask questions about those ideas if you're uncertain.
But don't expect a hand-out.
No I have not worked with stack ever before.Its ok.whatever.
Since that's required for the assignment, it seems like a good place to start: Stack (abstract data type) - Wikipedia, the free encyclopedia
There is virtually nothing more to the algorithms for stack operations than their description.
Simply read what the stack operations do and implement that.
Do not expect anyone here to write code for you.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Since a stack only has two operations - push and pop, there isn't really much to figure out.
> eg AABACABAA
Or
A - push or pop - you decide. Well since you haven't done anything yet, the only real choice is push
A - push or pop - try both (on paper)
B - and so on....
A
C
A
B
A
A
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Stack can be represented as an infinite array and the index of the empty element. In order to push the letter we put it into an array and increment the index. For popping just decrease index and get element by it.
Our goals are clear, tasks are defined! Let's work, comrades! -- Nikita Khrushchev