From 294e7c3ad390ca87359b4bf60446eab77646c114 Mon Sep 17 00:00:00 2001 From: jeevansai Date: Mon, 4 Apr 2016 00:44:22 +0530 Subject: [PATCH 1/4] Update LinkedList.py --- LinkedList.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/LinkedList.py b/LinkedList.py index 1675e0c..feb7b85 100644 --- a/LinkedList.py +++ b/LinkedList.py @@ -1,8 +1,6 @@ #!/usr/bin/python3 # Linked list implementation in python (python 3) -#include -using namespace std; class Node: def __init__ (self, data): @@ -33,7 +31,7 @@ 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 @@ -41,7 +39,7 @@ def delAtBeg (self) 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 @@ -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): @@ -67,7 +65,7 @@ def delAtEnd (self, data): -l = linkedlist() +l = LinkedList() l.insertAtBeg(10) l.insertAtEnd(100) l.insertAtBeg(1000) From f3997c322a12851868206faac62a0af5cc262483 Mon Sep 17 00:00:00 2001 From: jeevansai Date: Mon, 4 Apr 2016 00:44:52 +0530 Subject: [PATCH 2/4] Update linkedlist.h --- linkedlist.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/linkedlist.h b/linkedlist.h index 2107b7e..4bdfa25 100644 --- a/linkedlist.h +++ b/linkedlist.h @@ -3,7 +3,7 @@ #define llist linkedlist #include - +#include /* overview : struct node ; struct llist; @@ -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; } @@ -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) @@ -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) @@ -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; @@ -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++; @@ -203,6 +203,6 @@ void reverse(struct llist *l) prev = cur; cur = next; //} - l>head = prev; + l->head = prev; +} } - From 21cbf04b55d024758cffd7d8fc5a929d3d634f23 Mon Sep 17 00:00:00 2001 From: jeevansai Date: Mon, 4 Apr 2016 00:45:29 +0530 Subject: [PATCH 3/4] Update infixToPostfix.c --- infixToPostfix.c | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/infixToPostfix.c b/infixToPostfix.c index e603209..a03762c 100644 --- a/infixToPostfix.c +++ b/infixToPostfix.c @@ -1,25 +1,13 @@ -//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 #include #include #include #define N 100 - - typedef struct stack { int top; char A[N]; }stack; - bool empty(stack *ps) { if(ps->top==0) @@ -27,8 +15,6 @@ bool empty(stack *ps) else return false; } - - void push(stack *ps, int x) { if(ps->top==N-1) @@ -39,7 +25,6 @@ void push(stack *ps, int x) (ps->top)++; ps->A[(ps->top)]=x; } - char pop(stack *ps) { if(empty(ps)) @@ -51,7 +36,6 @@ char pop(stack *ps) ps->top--; return a; } - void print(stack *ps,int d) { int t= ps->top; @@ -65,8 +49,6 @@ void print(stack *ps,int d) } printf("\n"); } - - bool isoperand(char c) { switch(c) @@ -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; @@ -155,7 +125,7 @@ int main() } else if(str[i][0]==')') { - while(!empty(s)) + while(!empty(&s)) { char t = pop(&s); @@ -189,15 +159,4 @@ int main() printf("\n"); } return 0; - - - - } - - - - - - - From da21bac5640f4d312a78ed1ca6f16a65b8ed7a42 Mon Sep 17 00:00:00 2001 From: jeevansai Date: Mon, 4 Apr 2016 00:46:08 +0530 Subject: [PATCH 4/4] Update md5gen.sh --- md5gen.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/md5gen.sh b/md5gen.sh index 0dcb1d6..f888500 100644 --- a/md5gen.sh +++ b/md5gen.sh @@ -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. @@ -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;