Skip to main content

Posts

Showing posts from January, 2019

Queue

Queue is a FIFO structure. FIFO means first in first out. For queue, there is a front and a back just like linked list has head and tail. Its just like a physical queue, one ends through the back and leaves from the front. Without much ado, Here is a C program for queue: #include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE  100 int count=0; typedef struct node{  int value;  struct queue *next;  struct queue *prev; }queue; queue *front=NULL; queue *back=NULL; queue *createnode(int a) {  queue *newstack;  newstack=(queue*)calloc(1,siz eof(queue));  newstack->value=a;  newstack->prev=NULL;  newstack->next=NULL;  return newstack; } int isempty()    {        if(count==0)        {return 1;}        else        {return 0;}     } int isfull()     {      if(count==SIZE)      {return 1;}      else      {return 0;}     } void enqueue(int a) {   if(isfull()==1)    {     printf("overflow condition: queue

infix to postfix conversion and postfix evaluation

definition: infix: an arithmetic expression is called infix, when it has the operators between the operands. example: a+b is a infix expression. postfix: When the operators appear after the operands, then it is called postfix. postfix is actually meant for machines. an example of postfix is: ab+ prefix: when the operators appear before the operands, it is called prefix. prefix is also a machine oriented expression. an example of prefix is: +ab It is a very classic task to transform infix to postfix and postfix evaluation. We will write functions for both of them and also we will use the driver program to show whether it works or not.  Infix to postfix conversion: This can be done using stacks. Here is a brief of the algorithm:  We read one character at a time from the infix expression.  If this is a operand then we send it to the output string. The output string is supposed to be the postfix expression at the end.  If it is an operator, we store it to a s

stack

Introduction: The stack is a linear data structure. A stack can be conceptualized by a stack of dishes, kept one upon another. As the dish which is at the top has to be removed at the first to get the depth of the stack, the stack is called a first in last out or last in first out structure. This is abbreviated as LIFO. A stack, as it can be imagined as a one-side open tube, has one opening only and therefore it has to store this opening as a pointer when it is implemented. This pointer is named "top". A stack has 5 normal functions to work with. It has a peek function which helps to look at the top of the stack and know the value. It has a push function to push a value from the top. And then there is a pop function which deletes the top value each time it is called. The other two functions are rather technical as such isempty() is a standard function to check whether the stack is empty or not and the isfull() is a similar one to check whether the stack is full or

Web scrapping: things you will not know before getting your hand dirty

What is Web scrapping? Web scrapping is a important part of data science. Data science is not only use and analysis of the already created, usable data; but also part of it is to search and create that data. Many times, you will come across a general question in data science field for which you may not find a ready made data in CSV or JSON. So, the solution is Web scrapping.  Web scrapping means to scrap the web, i.e. programatically extracting information needed from one or more than one web page. Web scrapping also goes into detailed soft-wares named web crawlers or so called spiders.   Web scrapping can be done in many languages. For this and the coming posts, I am going to use python for web scrapping. I will show examples where the easiest approach for web scrapping works and where it does not. Also, on later posts, we will explore a bit complex methods and modules to do web scrapping. Introduction to methods: There are broadly two methods to do web scraping. One

linked list in c, node traversal, addnode,createnode search

Caution/disclaimer:  This post only depicts a idea for the programs, and are not fit for all the marginal cases like values above 10^6, inputs other than expected formats and some other things. So please take just the idea from the codes and try to correct this more. You can mail me better versions too.  linked list introduction: #include <stdio.h> #include <stdlib.h> #include <string.h> //linked list program   // defining the type block with struct typedef struct block { char transactions[100]; int hash; struct block *next; struct block *prev; }block; // setting head and tail as global block *head=NULL; block *tail=NULL; // function to create a node with custom value block *createnode(char *transactions, int hash) { block *newblock; newblock=(block *)malloc(sizeof(block)); strcpy(newblock->transactions,transactions); newblock->hash=hash; newblock->prev=NULL; newblock->next=NULL; return newblock;

SQL in Azure ml part 2

Previously, we started with the basics of the SQL queries and explored what type of questions can be asked using SQL. But we did not write the queries in the part 1 post. If you want to read the first part, i.e. the basics of using sql in Azure ml, then refer  here  to the previous post. Now we will write queries and execute them and show how to visualise the results; create a network of sql application to perform complex tasks. Although this post will be as self-contained as possible, reader will be in a better context in this post if (s)he reads the last post mentioned above. So, we have a data about school inspections in UK uploaded in a experiment named blogarithm in my free workspace in Azure ml. We have already cleaned the data and connected a basic "Apply SQL transformation" function to the cleaned data. Remember to clean your data always before you try to proceed in any analysis as otherwise many of the queries or formula do not work. i.e. in excel, if you try SUM