0% found this document useful (0 votes)
28 views2 pages

Data Strucuture - Linked List

This document contains 12 questions related to data structures and algorithms. The questions cover topics like: 1) Converting a decimal number to binary using a stack 2) Evaluating postfix expressions using a stack 3) Converting infix expressions to postfix form using a stack 4) Drawing the contents of a stack during an infix to postfix conversion 5) Writing a simple calculator to evaluate infix expressions 6) Implementing two stacks within a single array 7) Reversing the order of elements on a stack using additional stacks or queues 8) Checking if a string is a palindrome using stacks and queues 9) Sorting elements of one stack in ascending order using another stack 10) Adding very

Uploaded by

bina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Data Strucuture - Linked List

This document contains 12 questions related to data structures and algorithms. The questions cover topics like: 1) Converting a decimal number to binary using a stack 2) Evaluating postfix expressions using a stack 3) Converting infix expressions to postfix form using a stack 4) Drawing the contents of a stack during an infix to postfix conversion 5) Writing a simple calculator to evaluate infix expressions 6) Implementing two stacks within a single array 7) Reversing the order of elements on a stack using additional stacks or queues 8) Checking if a string is a palindrome using stacks and queues 9) Sorting elements of one stack in ascending order using another stack 10) Adding very

Uploaded by

bina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

HiLCoE

School of Computer Science and Technology


Data Structure and Algorithm Analysis (CS551)
1. Implement a function decimalToBinary() which changes a decimal number to binary using
stack. The function returns the binary number as string.
2. Evaluate the following postfix expressions using a stack and show the Content of the stack
after each step:

(i) 50,40,+, 18,14,-,4,*,+ (ii) 100,40,8,+,20,10,-,+,*

3. Give postfix form of the following expressions (use stack):

(i) A*(B+(C+D)*(E+F)/G)*H (ii) A+[(B+C)*(D+E)*F]/G

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:

A. A number: B. A left parenthesis: E. A division sign

C. A right parenthesis: D. A minus sign:

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.

7. Reverse the order of elements on stack.

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

You might also like