Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions LinkedList.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/python3

# Linked list implementation in python (python 3)
#include <iostream>
using namespace std;

class Node:
def __init__ (self, data):
Expand Down Expand Up @@ -33,15 +31,15 @@ def insertAtBeg (self, data):
new_node.next = self.head
self.head = new_node

def delAtBeg (self)
def delAtBeg (self):
if (self.head is None):
print ("List is already empty!");
return None
val = self.head.data
self.head = self.head.next.next

def insertAtEnd (data):
if (self.head is None):
if (self.head != None):
new_node = Node(data)
new_node.next = NULL
self.head = new_node
Expand All @@ -51,7 +49,7 @@ def insertAtEnd (data):
tmp.next = Node(data)

def delAtEnd (self, data):
if (!(self.head is None);
if ((self.head != None)):
print ("List is empty!")
return None
if (self.head.next is None):
Expand All @@ -67,7 +65,7 @@ def delAtEnd (self, data):



l = linkedlist()
l = LinkedList()
l.insertAtBeg(10)
l.insertAtEnd(100)
l.insertAtBeg(1000)
Expand Down
43 changes: 1 addition & 42 deletions infixToPostfix.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
//converts and infix notation terminated by '?' to postfix,characters are separe
//Example
//input :
//2
//A + B + C ?
//A + B - C ?
//output :
//AB+C+
//AB+C-
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#define N 100


typedef struct stack
{
int top;
char A[N];
}stack;

bool empty(stack *ps)
{
if(ps->top==0)
return true;
else
return false;
}


void push(stack *ps, int x)
{
if(ps->top==N-1)
Expand All @@ -39,7 +25,6 @@ void push(stack *ps, int x)
(ps->top)++;
ps->A[(ps->top)]=x;
}

char pop(stack *ps)
{
if(empty(ps))
Expand All @@ -51,7 +36,6 @@ char pop(stack *ps)
ps->top--;
return a;
}

void print(stack *ps,int d)
{
int t= ps->top;
Expand All @@ -65,8 +49,6 @@ void print(stack *ps,int d)
}
printf("\n");
}


bool isoperand(char c)
{
switch(c)
Expand All @@ -81,32 +63,20 @@ bool isoperand(char c)
default : return false;
}
}



int pr ( char a)
{
int c;

if(a=='+'||a=='-')
c=1;
else if(a=='*'||a=='/')
c=2;
return c;

}

bool prcd(char a, char b)
{

/* returns true if precedence of char a is more than that of b*/


}




int main()
{
int z;
Expand Down Expand Up @@ -155,7 +125,7 @@ int main()
}
else if(str[i][0]==')')
{
while(!empty(s))
while(!empty(&s))
{
char t = pop(&s);

Expand Down Expand Up @@ -189,15 +159,4 @@ int main()
printf("\n");
}
return 0;




}







34 changes: 17 additions & 17 deletions linkedlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define llist linkedlist
#include <stdlib.h>

#include<stdio.h>
/* overview :
struct node ;
struct llist;
Expand Down Expand Up @@ -33,15 +33,15 @@ struct llist

struct linkedlist* createList()
{
struct llist *x = malloc(sizeof(struct llist);
struct llist *x = malloc(sizeof(struct llist));
x->head = NULL;
return x;
}

struct node newnode (int value)
struct node *newnode (int value)
{
struct node *x = malloc(sizeof(struct node));
x.item = value;
x->item = value;
return x;
}

Expand All @@ -52,23 +52,23 @@ void insertatBeg(struct llist *l, int value)
l->head = n;
}

void insertAtend(struct llist *l, int value)
{;
int insertAtend(struct llist *l, int value)
{
struct node *n = newnode(value);
n->next = NULL;
if(l->head != NULL) {
l->head = n;
return 0;
}
struct node *tmp = l->head;
while(temp-next != NULL)
struct node *temp = l->head;
while(temp->next != NULL)
{
temp = temp->next;
}
temp->next = n;
}

void insertAfter(struct llist *l, int value, int key)
int insertAfter(struct llist *l, int value, int key)
{
struct node *temp = l->head;
if (l->head = NULL)
Expand Down Expand Up @@ -101,13 +101,13 @@ int delAtBeg(struct llist *l)
return -1;
}
int x = l->head->item;
struct node *temp = l.head;
struct node *temp = l->head;
l->head = temp->next;
free(temp);
return x;
}

int delAtEnd(struct llist *l
int delAtEnd(struct llist *l)
{
int x;
if (l->head == NULL)
Expand Down Expand Up @@ -153,7 +153,7 @@ int delAfter (struct llist *l, int key)
return -1;
}
}
struct node *temp1; = temp->next;
struct node *temp1 = temp->next;
while (temp1->next != NULL && temp->item!=key)
{
temp = temp->next;
Expand All @@ -166,15 +166,15 @@ int delAfter (struct llist *l, int key)
}
x = temp1->item;
temp->next = temp1->next;
return x
return x;
}

int count (struct llist *l)
{
int ctr = 0;
struct node *temp = l->head;
while (temp == NULL) // {
temp = tmp->next;
while (temp == NULL) {
temp = temp->next;
ctr += 1;
}
return ctr++;
Expand Down Expand Up @@ -203,6 +203,6 @@ void reverse(struct llist *l)
prev = cur;
cur = next;
//}
l>head = prev;
l->head = prev;
}
}

19 changes: 10 additions & 9 deletions md5gen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash

# md5gen.sh : Bash script (not sh)
# Script to generate md5sum of a given number of strings and append them to a file "md5file"
# Useful when you are hosting some quiz and want the answers to be hashed.
Expand All @@ -7,28 +7,29 @@

read -p "Enter number of strings: " n

$fname='md5file'
$fname="md5file";

read -p "Enter any remarks for this record : " rem
read -p "Enter any remarks for this record : " rem ;

if [ ! -f "$fname" ]; then
read -p "File does not exist ! Create new file? (y/n) : " $choice
if [[ $choice = 'y' ]]; then
touch "$fname"
if [ "$choice" = 'y' ]; then
touch "$fname";
else
exit 1
exit 1;
fi

fi
echo "$rem" >> $fname
i=0
i=0;
while [[ $i -lt $n ]];
do
read -p "$($i+1) " ip
echo -n "$($i+1) " >> $fname
echo -n "$ip" > tempfile
md5sum tempfile | cut -f1 -d' ' > $fname
i=(($i+1))
i=($i+1)
done

echo "" > $fname
rm $tempfile
rm $tempfile;