Write a menu-driven program to perform the following operations of a stack using an array by using suitable user-defined functions for each case.
a) Check if the stack is empty
b) Display the contents of stack
c) Push
d) Pop
9. Implement a BST-Binary Search Tree (for integer numbers) that consists of following
operations:
(1) Insert
(2) Tree minimum
(3) Search
(4) In-order traversal
(5) Tree successor
(6) Delete
[Make it Menu driven: 1 means insert, 2 means tree minimum and so on….]
Write a C code to implement the following operations using stack.
Assume the Stack S is empty initially.
Read the given text character by character.
If the character read is an operand push it onto the stack.
If the character read is a special character do the following
* means pop
$ means two pops
# means pop and a duplicate of popped value
Example:
DAT*ASTRU$$CTURES**#ANDAL$$GOR##ITHM**S
Stack:
S
T
I
G
A
U
T
C
A
A
D
Output: TURTSSERRLADNRROOMH
Sales Commissions) Use a single-subscripted array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of
their gross sales for that week. For example, a salesperson who grosses $3,000 in sales in a week receives $200 plus 9% of $3,000, or a total of $470. Write a C program (using an array of counters)
that determines how many of the salespeople earned salaries in each of the following ranges (assume
that each salesperson’s salary is truncated to an integer amount):
a) $200–299
b) $300–399
c) $400–499
d) $500–599
268 Chapter 6 C Arrays
e) $600–699
f) $700–799
g) $800–899
h) $900–999
i) $1000 and over
Write a program to Detect Cycle in a Directed Graph. Suppose, you have a directed graph, check
whether the graph contains a cycle or not. Your function should return true if the given graph
contains at least one cycle, else return false
C programing: User Input, Error Conditions, and Math
Part A
DUE: Monday September 20, 2021 by midnight
Part B
DUE: Thursday September 23, 2021 by midnight
Part A
of lab = 4%
Part B
of lab = 1%
Given a Queue consisting of first n natural numbers (in random order). The task is to check whether the given Queue elements can be arranged in increasing order in another Queue using a stack in C. The operations allowed are:
a. Push and Pop elements in the stack. b. Delete from the given Queue.
c. Insert into another Queue.
Examples :
Input : Queue[] = { 5, 1, 2, 3, 4 }; Output : Yes
Delete the first element of the given Queue i.e 5.
Push 5 into the stack.
Now, Delete all the elements of the given Queue and Insert them into the second Queue.
Now, pop element 5 from the stack and Insert it into the second Queue.
Input : Queue[] = { 5, 1, 2, 6, 3, 4 }; Output : No