The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
HOMEWORK 2
CS512 -Â Data Structures
Â
Â
Â
Deadline: This assignment is due by the class on Friday, June 16 2016 at 5:30 pm.
Â
Provide efficient solutions for the questions asked.
Â
Don't forget to write your names on your stapled answer sheets.
Â
There are five questions. Each question is of 5 points.
Â
Â
Â
Â
1. Using stack data structure please determine if the following postfix expression is valid or not. Explain each step showing the current state of the stack and the top pointer.
Â
4 1 + 3 * 7 1 3 * 4 + -
Â
If the above expression is valid please evaluate using a stack. Show the current state of the stack and the top pointer at all steps.
Â
Â
Â
2. A palindrome is a word which reads the same backward or forward. Examples: civic, radar, malayalam. For the sake of this question, assume that all words given to you have odd number of letters in them. Every letter in your word is of the same case - upper or lower case.
Â
a)Â Â How would you use stacks to determine if a given word is a palindrome or not?
Â
b)Â Â Check if your approach works for the following two words: racecar, dalda. For both of these words show the stack (and the top pointer) at each step of your algorithm.
Â
c)Â Â What is the Big-O complexity of your approach?
Â
Â
Â
3. Using stacks please evaluate the following postfix expression:
Â
7 4 + 2 * 8 3 * 4 - +
Â
    Show the state of the stack and the top pointer at all steps.
Â
Â
Â
4. Suppose I give you a list of seven numbers. E.g.: 77, 3, 34, 6, 7, 8, 1. You need to reverse the list of given numbers. For instance, the reverse of above list will be: 1, 8, 7, 6, 34, 3, 77.
Â
How will you do this using Stacks? Explain your answer showing the operations you will use and the state of the stack at each step.
Â
What is the Big-O complexity of your approach?
Â
Â
Â
5. What do you understand by LIFO? Briefly explain the five operations of a stack.
----------- Â ----------- 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