The document describes two tasks for a data structures lab assignment involving stack implementation using arrays. Task 1 involves writing a program to convert a decimal number to binary by using a stack to push the remainders of successive divisions of the number by 2 onto the stack. Task 2 involves writing a program to find the middle element of a stack using array implementation.
1. Dated: feb/26/2015
Course Title: Data Structures
Lab # 2
Array Implementation of Stack
Task#1
Write a program to convert a decimal number into its binary form using stack implementation.(6 Points)
The Algorithm for transforming decimal number into its binary equivalent is as follows:
Step 1. Create a stack (using array)
Step 2. Enter a decimal number
Step 3. Iteration 1 (while number > 0)
digit = number %2
push digit into stack
if stack is full
Print an error
Stop the algorithm
End if condition
divide the number by 2
Step 4. End iteration 1
Step 5. Iteration 2 (while stack is not empty)
Pop digit from stack
Print the digit
Step 6. End Iteration 2
Step 7. Stop program
Task#2
Write a program to find the middle element of the stack using array. (4 Points)