Tag Archives: C program

Balancing of symbols using stacks – Data structures

Balancing of symbols

Given a string consisting of symbols consisting (, {, [. You have to check whether these symbols are balanced or not.

balancing of symbols
Title – balancing of symbols

Example :

  1. (a+b)-(c+d) is balanced .
  2. ((a+b) is not balanced .

Algorithm

  1. Create a stack.
  2. While (the end of character i.e ‘\0’ is not reached){
  • If the character read is not a symbol to be balanced, ignore it.
  • If it is an opening symbol i.e (, {, [, the push it into the stack.
  • If it is a closing symbol ), }. ] then pop the elements ( if the stack is empty return an error ) unless the same opening symbol is encountered else report an error.

}

3. At the end, the stack must be empty, else report an error.

Continue reading Balancing of symbols using stacks – Data structures

Implementation of stack using array

Stack using array

Please go through this article for good understanding of stacks concept.

READ  Basic Concept of a stack - Push and pop
stack implementation
Implementation – Stack using array

Continue reading Implementation of stack using array

Deletion operation in doubly linked list

Deletion operation

Task: Create a doubly linked list and delete the first , last or any intermediate node. i.e perform deletion operation .As in single linked list three types of deletion( deletion operation) are possible in doubly linked list:

  • Deleting the first node
  • Deleting the last node
  • Deleting any intermediate node

Title

Continue reading Deletion operation in doubly linked list