Data Strucuture - Linked List
Data Strucuture - Linked List
4. Consider the usual algorithm to convert a fully parenthesized infix expression to a postfix
expression. Suppose that you have read 10 input characters during a conversion and that the
stack now contains these symbols:
| |
| + |
| ( |
Bottom | ___*___|
Now, suppose that you read and process the 11th symbol of the input. Draw the stack for
the case where the 11th symbol is:
5. Using the technique to implement compiler (discussed in the class), write a simple
calculator that evaluate infix expressions that supports addition, subtraction,
multiplication, division, and exponentiation. Assume the values as double data type.
6. Define a method for keeping two stacks within a single linear array S in such a way that
neither stacks overflows until entire array is used and an entire stack is never shifted to a
different location within the array. Write routines for pushing and popping elements in two
stacks.
1|Page
HiLCoE
School of Computer Science and Technology
Data Structure and Algorithm Analysis (CS551)
a. Using two additional stack
b. Using one additional stack
c. Using one additional queue
8. Using the operations of the Stack and Queue, write a function that determines if a string is a
palindrome. The prototype for this function is: Int isPalindrome(const char * theString);
9. Put the elements on one stack in ascending order using one additional stack.
10. Write a program that adds very large floating numbers using stack.
11. Write a C++ function that takes a C++ source code file and checks whether symbols
(parentheses, braces, and brackets) are balanced. Note we should not consider a
parenthesis as a symbol if it occurs inside a comment, string constant, or character
constant. The function should report for the calling module the line number and the
position of the offending symbol.
12. Implement queue using.
a. Using circular array. You must let the queue elements to wrap around the end of the
array. In other words you can treat the array as a circular structure in which the last
slot is followed by the first slot. Hint: to differentiate between an empty queue and a
full queue
i. Redefine your queue structure definition to include the count of the element
or
ii. Let front indicates the index of the array preceding the front element in the
queue rather than the index of the front element itself. To implement this
scheme it is necessary that the slot indicated by front must be reserved i.e., it
can’t contain a queue element. Note that with this condition the list is empty
when rear=front.
b. Circular linked list
2|Page