Tutorial by Examples

The stack is a LIFO (last-in, first-out) data-structure, i.e. the most recent (or "last in") element added to the stack will be the first element removed ("first out"). Let us consider the example of books in a box. Only one book can be added or removed from from the box at a ti...
A palindrome is a word that can be read both ways, like 'kayak'. This example will show how to find if a given word is a palindrome using Python3. First, we need to turn a string into a stack (we will use arrays as stacks). str = "string" stk = [c for c in str] #this makes an array: [&...
Array Implementation #include<stdio.h> #define MAX 100000 //Global variables int top = -1; int a[MAX]; void push(int x){ if(top == MAX-1){ // Check whether stack is full printf("Stack Overflow\n"); retur...
A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched p...

Page 1 of 1