Skip to content

Instantly share code, notes, and snippets.

View devansh42's full-sized avatar

Devansh Gupta devansh42

View GitHub Profile
package main
import (
"database/sql"
"fmt"
"strings"
_ "github.com/go-sql-driver/mysql"
)
#ifndef LINKED_H
#define LINKED_H
struct Node;
typedef struct Node Node;
struct Node
{
int value; //value will hold the value of our node
void push_list(LinkedList* list, int value){
Node* n;
n=(Node*)malloc(sizeof(Node)); //intializing new node
n->value=value; //setting value of new node
if(!list->tail){
//It means we are pushing our first node, so intially header and tail node will be same
int pop_list(LinkedList* list){
if(!list->head) return -1; //It means, linked list is empty
int value; //holds value of node
value=list->head->value; //accessing node
LinkedList* new_linked_list(){
LinkedList* x; //Declaring a new instance of linked list
Node* n;//to do some temporary arrangements
x=(LinkedList*)malloc(sizeof(LinkedList)); // allocating memory for the linked list
return x; //returing it back
}
int length_list(LinkedList* list){
return list->length; //returning length of the linked list
}
void delete_list(LinkedList* list){
Node* i;
/**
* Deallocating memory associated with each node
* Starting from head node
* Ends whenever we reach at the end
* We go to next node in each iteration
#ifndef STACK_H
#define STACK_H
/**
* Defination of Basic Stack Structure
*/
typedef struct
{
//size of stack
int size;
#ifndef STACK_H
#define STACK_H
/**
* Defination of Basic Stack Structure
*/
typedef struct
{
//size of stack
int size;
#include "stack.h"
#include<stdlib.h>
BasicStack* new_basic_stack(int cap){
BasicStack* s;
//Allocating memory for Basic Stack Structure
s=(BasicStack*)malloc(sizeof(BasicStack));
//Allocating memory for Array used to hold stack
s->ar=malloc(sizeof(int)*cap);