Data Structures and Algorithms - Old Questions

Question Answer Details

6. What is ADT? Discuss stack as an ADT.

5 marks
Asked in 2075

Answer

AI Generated Answer

AI is thinking...

Official Answer

Abstract data types are a set of data values and associated operations that are precisely independent of any particular implementation. Generally the associated operations are abstract methods. E.g. stack, queue etc.

Stack as an ADT

stack of elements of type is a finite sequence of elements of together with the operations

  • CreateEmptyStack(S): Create or make stack be an empty stack
  • Push(S, x): Insert at one end of the stack, called its top
  • Top(S): If stack is not empty; then retrieve the element at its top
  • Pop(S): If stack is not empty; then delete the element at its top
  •  IsFull(S): Determine if is full or not. Return true if is full stack; return false otherwise
  • IsEmpty(S): Determine if is empty or not. Return true if is an empty stack; return false otherwise.

Thus by using a stack we can perform above operations thus a stack acts as an ADT.