From d7875947ae262c8292b2cd19f51c79e7167b91e9 Mon Sep 17 00:00:00 2001 From: mukesh9696 <9696mks@gmail.com> Date: Wed, 2 Oct 2019 11:35:23 +0530 Subject: [PATCH] Add Some comments at proper place and remove indentation error --- HashTables/hashTable.cpp | 16 +++++------ Heap/Heap.cpp | 17 ++++++------ LinkedList/LinkedList.cpp | 57 +++++++++++++++++++-------------------- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/HashTables/hashTable.cpp b/HashTables/hashTable.cpp index ed2f72d..155bceb 100644 --- a/HashTables/hashTable.cpp +++ b/HashTables/hashTable.cpp @@ -5,7 +5,7 @@ using namespace std; -class hashTable +class hashTable //creating a class { char keys[SIZE][20]; int values[SIZE]; @@ -29,8 +29,8 @@ void hashTable :: get() cout<<"Enter the key: "; cin>>key; - int index = hashFunction(key); - + int index = hashFunction(key); //initialising + while (strcmp(keys[index],"\0") != 0) { /* Loop runs till it gets an NULL string */ @@ -44,7 +44,7 @@ void hashTable :: get() index = (index+1) % SIZE; } - + cout<<"Key not found!"<>value; @@ -83,7 +83,7 @@ int hashTable :: hashFunction(char key[]) e.g- "Hello" has ASCII value of 500, so index is 0 */ int sum=0; - + for(int i=0; i < strlen(key); i++) { sum = sum + key[i]; @@ -106,7 +106,7 @@ int main() system("clear"); char choice[2]; int quit = 0; - + hashTable obj; menu(); while (!quit) @@ -124,7 +124,7 @@ int main() case 3: quit++; break; - + default: cout<<"Wrong Input!"<>value; obj.insert(value); break; - + case 2: cout<<"Deleted Item is :"<next; - free(prev); - } - } + void insertAtHead(int); //Declaring the functions + void insertAtTail(int); + void displayData(); + void displayDetail(); + int deleteHead(); + int deleteTail(); + node* find(int, node**); + int deleteTarget(int); + void printReverse(); + void reverse(node*); + + ~linkedList() + { + node* prev=NULL; + node* temp=head; + while(temp!=NULL) + { + //cout<<"Memory is being freed"<next; + free(prev); + } + } }; void linkedList :: insertAtHead(int value) @@ -79,8 +80,8 @@ void linkedList :: insertAtTail(int value) temp=(node*)malloc(sizeof(node)); if(temp==NULL) { - cout<<"Unable to allocate memory for Node"<data=value; temp->next=NULL; @@ -346,7 +347,3 @@ int main() } } } - - - -